Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: harness: Detect illegal mixing of kselftest and harness functionality

Users may accidentally use the kselftest_test_result_*() functions in
their harness tests. If ksft_finished() is not used, the results
reported in this way are silently ignored.

Detect such false-positive cases and fail the test.

A more correct test would be to reject *any* usage of the ksft APIs but
that would force code churn on users.

Correct usages, which do use ksft_finished() will not trigger this
validation as the test will exit before it.

Reported-by: Yuwen Chen <ywen.chen@foxmail.com>
Link: https://lore.kernel.org/lkml/tencent_56D79AF3D23CEFAF882E83A2196EC1F12107@qq.com/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://lore.kernel.org/r/20260302-kselftest-harness-v2-4-3143aa41d989@linutronix.de
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Shuah Khan
a0877a35 d431ea86

+9
+9
tools/testing/selftests/kselftest_harness.h
··· 1222 1222 t->exit_code = KSFT_FAIL; 1223 1223 } else if (child == 0) { 1224 1224 setpgrp(); 1225 + 1226 + /* Reset state inherited from the harness */ 1227 + ksft_reset_state(); 1228 + 1225 1229 t->fn(t, variant); 1230 + 1231 + if (__test_passed(t) && (ksft_get_fail_cnt() || ksft_get_error_cnt())) { 1232 + ksft_print_msg("Illegal usage of low-level ksft APIs in harness test\n"); 1233 + t->exit_code = KSFT_FAIL; 1234 + } 1226 1235 _exit(t->exit_code); 1227 1236 } else { 1228 1237 t->pid = child;