linux/Documentation/dev-tools
David Gow 3ff16d30f5 kasan: test: improve failure message in KUNIT_EXPECT_KASAN_FAIL()
The KUNIT_EXPECT_KASAN_FAIL() macro currently uses KUNIT_EXPECT_EQ() to
compare fail_data.report_expected and fail_data.report_found.  This always
gave a somewhat useless error message on failure, but the addition of
extra compile-time checking with READ_ONCE() has caused it to get much
longer, and be truncated before anything useful is displayed.

Instead, just check fail_data.report_found by hand (we've just set
report_expected to 'true'), and print a better failure message with
KUNIT_FAIL().  Because of this, report_expected is no longer used
anywhere, and can be removed.

Beforehand, a failure in:
KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)area)[3100]);
would have looked like:
[22:00:34] [FAILED] vmalloc_oob
[22:00:34]     # vmalloc_oob: EXPECTATION FAILED at lib/test_kasan.c:991
[22:00:34]     Expected ({ do { extern void __compiletime_assert_705(void) __attribute__((__error__("Unsupported access size for {READ,WRITE}_ONCE()."))); if (!((sizeof(fail_data.report_expected) == sizeof(char) || sizeof(fail_data.repp
[22:00:34]     not ok 45 - vmalloc_oob

With this change, it instead looks like:
[22:04:04] [FAILED] vmalloc_oob
[22:04:04]     # vmalloc_oob: EXPECTATION FAILED at lib/test_kasan.c:993
[22:04:04]     KASAN failure expected in "((volatile char *)area)[3100]", but none occurred
[22:04:04]     not ok 45 - vmalloc_oob

Also update the example failure in the documentation to reflect this.

Link: https://lkml.kernel.org/r/20210606005531.165954-1-davidgow@google.com
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
Reviewed-by: Marco Elver <elver@google.com>
Acked-by: Brendan Higgins <brendanhiggins@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Daniel Axtens <dja@axtens.net>
Cc: David Gow <davidgow@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-06-29 10:53:52 -07:00
..
kunit Documentation: kunit: add tips for using current->kunit_test 2021-04-07 16:40:37 -06:00
checkpatch.rst docs: document all error message types in checkpatch 2021-03-25 11:47:42 -06:00
coccinelle.rst Documentation: Coccinelle: Improve command example for debugging patches 2020-12-03 15:45:18 -07:00
gcov.rst docs/gcov: Convert two tags to ref in dev-tools/gov.rst 2021-04-08 11:19:43 -06:00
gdb-kernel-debugging.rst scripts/gdb: add lx_current support for arm64 2021-05-07 00:26:33 -07:00
index.rst Documentation: dev-tools: Add Testing Overview 2021-04-15 14:53:02 -06:00
kasan.rst kasan: test: improve failure message in KUNIT_EXPECT_KASAN_FAIL() 2021-06-29 10:53:52 -07:00
kcov.rst Documentation: fix typos found in process, dev-tools, and doc-guide subdirectories 2020-12-03 15:55:04 -07:00
kcsan.rst kcsan: Add missing license and copyright headers 2021-03-08 14:27:43 -08:00
kfence.rst kfence: report sensitive information based on no_hash_pointers 2021-02-26 09:41:02 -08:00
kgdb.rst Documentation: kgdb: Fix a typo 2020-11-18 13:47:17 -07:00
kmemleak.rst mm,kmemleak-test.c: move kmemleak-test.c to samples dir 2020-10-13 18:38:27 -07:00
kselftest.rst Documentation: kselftest: fix path to test module files 2021-04-02 16:17:18 -06:00
sparse.rst doc: add link to sparse's home page/internal docs 2020-07-05 14:32:56 -06:00
testing-overview.rst Documentation: dev-tools: Add Testing Overview 2021-04-15 14:53:02 -06:00
ubsan.rst ubsan: remove UBSAN_MISC in favor of individual options 2020-12-15 22:46:19 -08:00