mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 21:57:43 +00:00
selftests: Add plan line and fix result line syntax
The TAP version 13 spec requires a "plan" line, which has been missing. Since we always know how many tests we're going to run, emit the count on the plan line. This also fixes the result lines to remove the "1.." prefix which is against spec, and to mark skips with the correct "# SKIP" suffix. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
parent
bf66078235
commit
b0df366bbd
2 changed files with 8 additions and 6 deletions
|
@ -111,7 +111,7 @@ static inline void ksft_test_result_skip(const char *msg, ...)
|
||||||
ksft_cnt.ksft_xskip++;
|
ksft_cnt.ksft_xskip++;
|
||||||
|
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
printf("ok %d # skip ", ksft_test_num());
|
printf("not ok %d # SKIP ", ksft_test_num());
|
||||||
vprintf(msg, args);
|
vprintf(msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ static inline int ksft_exit_skip(const char *msg, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
printf("1..%d # Skipped: ", ksft_test_num());
|
printf("not ok %d # SKIP ", ksft_test_num());
|
||||||
vprintf(msg, args);
|
vprintf(msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,15 +20,15 @@ run_one()
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
if [ ! -x "$TEST" ]; then
|
if [ ! -x "$TEST" ]; then
|
||||||
echo "$TEST_HDR_MSG: Warning: file $TEST is not executable, correct this."
|
echo "$TEST_HDR_MSG: Warning: file $TEST is not executable, correct this."
|
||||||
echo "not ok 1..$test_num $TEST_HDR_MSG [FAIL]"
|
echo "not ok $test_num $TEST_HDR_MSG"
|
||||||
else
|
else
|
||||||
cd `dirname $TEST` > /dev/null
|
cd `dirname $TEST` > /dev/null
|
||||||
(./$BASENAME_TEST >> "$logfile" 2>&1 &&
|
(./$BASENAME_TEST >> "$logfile" 2>&1 &&
|
||||||
echo "ok 1..$test_num $TEST_HDR_MSG [PASS]") ||
|
echo "ok $test_num $TEST_HDR_MSG") ||
|
||||||
(if [ $? -eq $skip_rc ]; then \
|
(if [ $? -eq $skip_rc ]; then \
|
||||||
echo "not ok 1..$test_num $TEST_HDR_MSG [SKIP]"
|
echo "not ok $test_num $TEST_HDR_MSG # SKIP"
|
||||||
else
|
else
|
||||||
echo "not ok 1..$test_num $TEST_HDR_MSG [FAIL]"
|
echo "not ok $test_num $TEST_HDR_MSG"
|
||||||
fi)
|
fi)
|
||||||
cd - >/dev/null
|
cd - >/dev/null
|
||||||
fi
|
fi
|
||||||
|
@ -39,6 +39,8 @@ run_many()
|
||||||
echo "TAP version 13"
|
echo "TAP version 13"
|
||||||
DIR=$(basename "$PWD")
|
DIR=$(basename "$PWD")
|
||||||
test_num=0
|
test_num=0
|
||||||
|
total=$(echo "$@" | wc -w)
|
||||||
|
echo "1..$total"
|
||||||
for TEST in "$@"; do
|
for TEST in "$@"; do
|
||||||
BASENAME_TEST=$(basename $TEST)
|
BASENAME_TEST=$(basename $TEST)
|
||||||
test_num=$(( test_num + 1 ))
|
test_num=$(( test_num + 1 ))
|
||||||
|
|
Loading…
Reference in a new issue