kunit: factor out kunit_base_assert_format() call into kunit_fail()
authorDaniel Latypov <dlatypov@google.com>
Thu, 13 Jan 2022 16:59:29 +0000 (08:59 -0800)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 25 Jan 2022 19:49:53 +0000 (12:49 -0700)
commitdd640d70874bd27fb081d444252677766321c32f
treebf2e203954fe8929d65b61848e28a902caa133ef
parenta91e9ade402c48ee35cd1e4b671e3938db798d17
kunit: factor out kunit_base_assert_format() call into kunit_fail()

We call this function first thing for all the assertion `format()`
functions.
This is the part that prints the file and line number and assertion type
(EXPECTATION, ASSERTION).

Having it as part of the format functions lets us have the flexibility
to not print that information (or print it differently) for new
assertion types, but I think this we don't need that.

And in the future, we'd like to consider factoring that data (file,
line#, type) out of the kunit_assert struct and into a `static`
variable, as Linus suggested [1], so we'd need to extract it anyways.

[1] https://groups.google.com/g/kunit-dev/c/i3fZXgvBrfA/m/VULQg1z6BAAJ

Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
lib/kunit/assert.c
lib/kunit/test.c