[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFd5g45j=_20YRU85bv3Vg4z2DDha=kqQJh-g4tcmjzaMhtv2g@mail.gmail.com>
Date: Tue, 18 May 2021 14:28:50 -0700
From: Brendan Higgins <brendanhiggins@...gle.com>
To: Daniel Latypov <dlatypov@...gle.com>
Cc: Kees Cook <keescook@...omium.org>, David Gow <davidgow@...gle.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
KUnit Development <kunit-dev@...glegroups.com>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>,
Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH v2] lib/test: convert test_overflow.c to use KUnit
On Tue, May 11, 2021 at 3:05 PM Daniel Latypov <dlatypov@...gle.com> wrote:
>
> This largely consists of:
> * replacing `err |= test_func(...)` calls with `test_func(test, ...)`.
> * changing pr_warn to KUNIT_*_MSG() macros to mark the failed test
> while printing a diagnostic message
> * dropping __init as there are concerns of this causing issues w/ KUnit
> when running on some other arches.
>
> With the exception of now needing to set CONFIG_KUNIT=y, the test can
> still be run as before, at boot time or as a test module.
> But now the output of the test will be TAP (Test Anything Protocol),
> the format used by kselftest instead of just warnings and printing
> "FAIL!" , see [1].
>
> But now the test can also be run more quickly via kunit.py
>
> $ ./tools/testing/kunit/kunit.py run --kunitconfig /dev/stdin <<EOF
> CONFIG_KUNIT=y
> CONFIG_TEST_OVERFLOW=y
> EOF
>
> Note: after a mrproper this took
> > Elapsed time: 38.683s total, 3.598s configuring, 32.141s building, 0.000s running
>
> (Normally would be less clunky as you wouldn't use a heredoc).
>
> [1] Here's an example failure message after tweaking the test array:
> TAP version 14
> 1..1
> # Subtest: lib_overflow
> 1..10
> # test_u8_overflow: u8 : 18 arithmetic tests
> # test_u8_overflow: EXPECTATION FAILED at lib/test_overflow.c:251
> Expected _got == p->sum, but
> _got == 0
> p->sum == 1
> wrong result for 0 + 0 (type u8)
> ...
> not ok 1 - test_u8_overflow
> # test_s8_overflow: s8 : 19 arithmetic tests
> ok 2 - test_s8_overflow
> ...
> # test_overflow_shift: ok: (s32)(0 << 31) == 0
> # test_overflow_shift: ok: (s64)(0 << 63) == 0
> ok 9 - test_overflow_shift
>
> Signed-off-by: Daniel Latypov <dlatypov@...gle.com>
> Tested-by: David Gow <davidgow@...gle.com>
Looks good to me.
Acked-by: Brendan Higgins <brendanhiggins@...gle.com>
Powered by blists - more mailing lists