Skip to content

Commit

Permalink
selftests/harness: Limit step counter reporting
Browse files Browse the repository at this point in the history
When the selftest "step" counter grew beyond 255, non-fatal warnings
were being emitted, which is noisy and pointless. There are selftests
with more than 255 steps (especially those in loops, etc). Instead,
just cap "steps" to 254 and do not report the saturation.

Reported-by: Ralph Campbell <rcampbell@nvidia.com>
Tested-by: Ralph Campbell <rcampbell@nvidia.com>
Fixes: 9847d24 ("selftests/harness: Refactor XFAIL into SKIP")
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
  • Loading branch information
Kees Cook authored and Shuah Khan committed Jul 17, 2020
1 parent 4c6614d commit 850d0cc
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions tools/testing/selftests/kselftest_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,8 @@
__bail(_assert, _metadata->no_print, _metadata->step))

#define __INC_STEP(_metadata) \
if (_metadata->passed && _metadata->step < 255) \
/* Keep "step" below 255 (which is used for "SKIP" reporting). */ \
if (_metadata->passed && _metadata->step < 253) \
_metadata->step++;

#define is_signed_type(var) (!!(((__typeof__(var))(-1)) < (__typeof__(var))1))
Expand Down Expand Up @@ -976,12 +977,6 @@ void __run_test(struct __fixture_metadata *f,
t->passed = 0;
} else if (t->pid == 0) {
t->fn(t, variant);
/* Make sure step doesn't get lost in reporting */
if (t->step >= 255) {
ksft_print_msg("Too many test steps (%u)!?\n", t->step);
t->step = 254;
}
/* Use 255 for SKIP */
if (t->skip)
_exit(255);
/* Pass is exit 0 */
Expand Down

0 comments on commit 850d0cc

Please sign in to comment.