Skip to content

Commit 7486440

Browse files
laura-naoshuahkh
authored andcommitted
selftests: Warn about skipped tests in result summary
Update the functions that print the test totals at the end of a selftest to include a warning message when skipped tests are detected. The message advises users that skipped tests may indicate missing configuration options and suggests enabling them to improve coverage. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Laura Nao <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent e8731ec commit 7486440

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

tools/testing/selftests/kselftest.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ static inline void ksft_set_plan(unsigned int plan)
149149

150150
static inline void ksft_print_cnts(void)
151151
{
152+
if (ksft_cnt.ksft_xskip > 0)
153+
printf(
154+
"# %u skipped test(s) detected. Consider enabling relevant config options to improve coverage.\n",
155+
ksft_cnt.ksft_xskip
156+
);
152157
if (ksft_plan != ksft_test_num())
153158
printf("# Planned tests != run tests (%u != %u)\n",
154159
ksft_plan, ksft_test_num());

tools/testing/selftests/kselftest/ksft.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def set_plan(num_tests):
2727

2828

2929
def print_cnts():
30+
if ksft_cnt['skip'] > 0:
31+
print(f"# {ksft_cnt['skip']} skipped test(s) detected. Consider enabling relevant config options to improve coverage.")
32+
3033
print(
3134
f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
3235
)

tools/testing/selftests/kselftest/ktap_helpers.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,9 @@ ktap_finished() {
107107
}
108108

109109
ktap_print_totals() {
110+
if [ "$KTAP_CNT_SKIP" -gt 0 ]; then
111+
echo "# $KTAP_CNT_SKIP skipped test(s) detected. " \
112+
"Consider enabling relevant config options to improve coverage."
113+
fi
110114
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
111115
}

0 commit comments

Comments
 (0)