Skip to content

Commit 4d6d4c7

Browse files
committed
Merge tag 'linux-kselftest-fixes-6.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull Kselftest fixes from Shuah Khan: - sgx test fix for false negatives - ftrace output is hard to parses and it masks inappropriate skips etc. This fix addresses the problems by integrating with kselftest runner * tag 'linux-kselftest-fixes-6.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests/ftrace: Improve integration with kselftest runner selftests/sgx: Add "test_encl.elf" to TEST_FILES
2 parents 1b66c11 + dbcf763 commit 4d6d4c7

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

tools/testing/selftests/ftrace/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# SPDX-License-Identifier: GPL-2.0
22
all:
33

4-
TEST_PROGS := ftracetest
4+
TEST_PROGS_EXTENDED := ftracetest
5+
TEST_PROGS := ftracetest-ktap
56
TEST_FILES := test.d settings
67
EXTRA_CLEAN := $(OUTPUT)/logs/*
78

tools/testing/selftests/ftrace/ftracetest

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
1313
echo " Options:"
1414
echo " -h|--help Show help message"
1515
echo " -k|--keep Keep passed test logs"
16+
echo " -K|--ktap Output in KTAP format"
1617
echo " -v|--verbose Increase verbosity of test messages"
1718
echo " -vv Alias of -v -v (Show all results in stdout)"
1819
echo " -vvv Alias of -v -v -v (Show all commands immediately)"
@@ -85,6 +86,10 @@ parse_opts() { # opts
8586
KEEP_LOG=1
8687
shift 1
8788
;;
89+
--ktap|-K)
90+
KTAP=1
91+
shift 1
92+
;;
8893
--verbose|-v|-vv|-vvv)
8994
if [ $VERBOSE -eq -1 ]; then
9095
usage "--console can not use with --verbose"
@@ -178,6 +183,7 @@ TEST_DIR=$TOP_DIR/test.d
178183
TEST_CASES=`find_testcases $TEST_DIR`
179184
LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
180185
KEEP_LOG=0
186+
KTAP=0
181187
DEBUG=0
182188
VERBOSE=0
183189
UNSUPPORTED_RESULT=0
@@ -229,7 +235,7 @@ prlog() { # messages
229235
newline=
230236
shift
231237
fi
232-
printf "$*$newline"
238+
[ "$KTAP" != "1" ] && printf "$*$newline"
233239
[ "$LOG_FILE" ] && printf "$*$newline" | strip_esc >> $LOG_FILE
234240
}
235241
catlog() { #file
@@ -260,11 +266,11 @@ TOTAL_RESULT=0
260266

261267
INSTANCE=
262268
CASENO=0
269+
CASENAME=
263270

264271
testcase() { # testfile
265272
CASENO=$((CASENO+1))
266-
desc=`grep "^#[ \t]*description:" $1 | cut -f2- -d:`
267-
prlog -n "[$CASENO]$INSTANCE$desc"
273+
CASENAME=`grep "^#[ \t]*description:" $1 | cut -f2- -d:`
268274
}
269275

270276
checkreq() { # testfile
@@ -277,40 +283,68 @@ test_on_instance() { # testfile
277283
grep -q "^#[ \t]*flags:.*instance" $1
278284
}
279285

286+
ktaptest() { # result comment
287+
if [ "$KTAP" != "1" ]; then
288+
return
289+
fi
290+
291+
local result=
292+
if [ "$1" = "1" ]; then
293+
result="ok"
294+
else
295+
result="not ok"
296+
fi
297+
shift
298+
299+
local comment=$*
300+
if [ "$comment" != "" ]; then
301+
comment="# $comment"
302+
fi
303+
304+
echo $CASENO $result $INSTANCE$CASENAME $comment
305+
}
306+
280307
eval_result() { # sigval
281308
case $1 in
282309
$PASS)
283310
prlog " [${color_green}PASS${color_reset}]"
311+
ktaptest 1
284312
PASSED_CASES="$PASSED_CASES $CASENO"
285313
return 0
286314
;;
287315
$FAIL)
288316
prlog " [${color_red}FAIL${color_reset}]"
317+
ktaptest 0
289318
FAILED_CASES="$FAILED_CASES $CASENO"
290319
return 1 # this is a bug.
291320
;;
292321
$UNRESOLVED)
293322
prlog " [${color_blue}UNRESOLVED${color_reset}]"
323+
ktaptest 0 UNRESOLVED
294324
UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO"
295325
return $UNRESOLVED_RESULT # depends on use case
296326
;;
297327
$UNTESTED)
298328
prlog " [${color_blue}UNTESTED${color_reset}]"
329+
ktaptest 1 SKIP
299330
UNTESTED_CASES="$UNTESTED_CASES $CASENO"
300331
return 0
301332
;;
302333
$UNSUPPORTED)
303334
prlog " [${color_blue}UNSUPPORTED${color_reset}]"
335+
ktaptest 1 SKIP
304336
UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO"
305337
return $UNSUPPORTED_RESULT # depends on use case
306338
;;
307339
$XFAIL)
308340
prlog " [${color_green}XFAIL${color_reset}]"
341+
ktaptest 1 XFAIL
309342
XFAILED_CASES="$XFAILED_CASES $CASENO"
310343
return 0
311344
;;
312345
*)
313346
prlog " [${color_blue}UNDEFINED${color_reset}]"
347+
ktaptest 0 error
314348
UNDEFINED_CASES="$UNDEFINED_CASES $CASENO"
315349
return 1 # this must be a test bug
316350
;;
@@ -371,6 +405,7 @@ __run_test() { # testfile
371405
run_test() { # testfile
372406
local testname=`basename $1`
373407
testcase $1
408+
prlog -n "[$CASENO]$INSTANCE$CASENAME"
374409
if [ ! -z "$LOG_FILE" ] ; then
375410
local testlog=`mktemp $LOG_DIR/${CASENO}-${testname}-log.XXXXXX`
376411
else
@@ -405,6 +440,17 @@ run_test() { # testfile
405440
# load in the helper functions
406441
. $TEST_DIR/functions
407442

443+
if [ "$KTAP" = "1" ]; then
444+
echo "TAP version 13"
445+
446+
casecount=`echo $TEST_CASES | wc -w`
447+
for t in $TEST_CASES; do
448+
test_on_instance $t || continue
449+
casecount=$((casecount+1))
450+
done
451+
echo "1..${casecount}"
452+
fi
453+
408454
# Main loop
409455
for t in $TEST_CASES; do
410456
run_test $t
@@ -439,6 +485,17 @@ prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w`
439485
prlog "# of xfailed: " `echo $XFAILED_CASES | wc -w`
440486
prlog "# of undefined(test bug): " `echo $UNDEFINED_CASES | wc -w`
441487

488+
if [ "$KTAP" = "1" ]; then
489+
echo -n "# Totals:"
490+
echo -n " pass:"`echo $PASSED_CASES | wc -w`
491+
echo -n " faii:"`echo $FAILED_CASES | wc -w`
492+
echo -n " xfail:"`echo $XFAILED_CASES | wc -w`
493+
echo -n " xpass:0"
494+
echo -n " skip:"`echo $UNTESTED_CASES $UNSUPPORTED_CASES | wc -w`
495+
echo -n " error:"`echo $UNRESOLVED_CASES $UNDEFINED_CASES | wc -w`
496+
echo
497+
fi
498+
442499
cleanup
443500

444501
# if no error, return 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh -e
2+
# SPDX-License-Identifier: GPL-2.0-only
3+
#
4+
# ftracetest-ktap: Wrapper to integrate ftracetest with the kselftest runner
5+
#
6+
# Copyright (C) Arm Ltd., 2023
7+
8+
./ftracetest -K

tools/testing/selftests/sgx/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \
1717
-fno-stack-protector -mrdrnd $(INCLUDES)
1818

1919
TEST_CUSTOM_PROGS := $(OUTPUT)/test_sgx
20+
TEST_FILES := $(OUTPUT)/test_encl.elf
2021

2122
ifeq ($(CAN_BUILD_X86_64), 1)
2223
all: $(TEST_CUSTOM_PROGS) $(OUTPUT)/test_encl.elf

0 commit comments

Comments
 (0)