Commit 4d6d4c7f authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux-kselftest-fixes-6.4-rc3' of...

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
parents 1b66c114 dbcf7639
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
all: all:
TEST_PROGS := ftracetest TEST_PROGS_EXTENDED := ftracetest
TEST_PROGS := ftracetest-ktap
TEST_FILES := test.d settings TEST_FILES := test.d settings
EXTRA_CLEAN := $(OUTPUT)/logs/* EXTRA_CLEAN := $(OUTPUT)/logs/*
......
...@@ -13,6 +13,7 @@ echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]" ...@@ -13,6 +13,7 @@ echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
echo " Options:" echo " Options:"
echo " -h|--help Show help message" echo " -h|--help Show help message"
echo " -k|--keep Keep passed test logs" echo " -k|--keep Keep passed test logs"
echo " -K|--ktap Output in KTAP format"
echo " -v|--verbose Increase verbosity of test messages" echo " -v|--verbose Increase verbosity of test messages"
echo " -vv Alias of -v -v (Show all results in stdout)" echo " -vv Alias of -v -v (Show all results in stdout)"
echo " -vvv Alias of -v -v -v (Show all commands immediately)" echo " -vvv Alias of -v -v -v (Show all commands immediately)"
...@@ -85,6 +86,10 @@ parse_opts() { # opts ...@@ -85,6 +86,10 @@ parse_opts() { # opts
KEEP_LOG=1 KEEP_LOG=1
shift 1 shift 1
;; ;;
--ktap|-K)
KTAP=1
shift 1
;;
--verbose|-v|-vv|-vvv) --verbose|-v|-vv|-vvv)
if [ $VERBOSE -eq -1 ]; then if [ $VERBOSE -eq -1 ]; then
usage "--console can not use with --verbose" usage "--console can not use with --verbose"
...@@ -178,6 +183,7 @@ TEST_DIR=$TOP_DIR/test.d ...@@ -178,6 +183,7 @@ TEST_DIR=$TOP_DIR/test.d
TEST_CASES=`find_testcases $TEST_DIR` TEST_CASES=`find_testcases $TEST_DIR`
LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
KEEP_LOG=0 KEEP_LOG=0
KTAP=0
DEBUG=0 DEBUG=0
VERBOSE=0 VERBOSE=0
UNSUPPORTED_RESULT=0 UNSUPPORTED_RESULT=0
...@@ -229,7 +235,7 @@ prlog() { # messages ...@@ -229,7 +235,7 @@ prlog() { # messages
newline= newline=
shift shift
fi fi
printf "$*$newline" [ "$KTAP" != "1" ] && printf "$*$newline"
[ "$LOG_FILE" ] && printf "$*$newline" | strip_esc >> $LOG_FILE [ "$LOG_FILE" ] && printf "$*$newline" | strip_esc >> $LOG_FILE
} }
catlog() { #file catlog() { #file
...@@ -260,11 +266,11 @@ TOTAL_RESULT=0 ...@@ -260,11 +266,11 @@ TOTAL_RESULT=0
INSTANCE= INSTANCE=
CASENO=0 CASENO=0
CASENAME=
testcase() { # testfile testcase() { # testfile
CASENO=$((CASENO+1)) CASENO=$((CASENO+1))
desc=`grep "^#[ \t]*description:" $1 | cut -f2- -d:` CASENAME=`grep "^#[ \t]*description:" $1 | cut -f2- -d:`
prlog -n "[$CASENO]$INSTANCE$desc"
} }
checkreq() { # testfile checkreq() { # testfile
...@@ -277,40 +283,68 @@ test_on_instance() { # testfile ...@@ -277,40 +283,68 @@ test_on_instance() { # testfile
grep -q "^#[ \t]*flags:.*instance" $1 grep -q "^#[ \t]*flags:.*instance" $1
} }
ktaptest() { # result comment
if [ "$KTAP" != "1" ]; then
return
fi
local result=
if [ "$1" = "1" ]; then
result="ok"
else
result="not ok"
fi
shift
local comment=$*
if [ "$comment" != "" ]; then
comment="# $comment"
fi
echo $CASENO $result $INSTANCE$CASENAME $comment
}
eval_result() { # sigval eval_result() { # sigval
case $1 in case $1 in
$PASS) $PASS)
prlog " [${color_green}PASS${color_reset}]" prlog " [${color_green}PASS${color_reset}]"
ktaptest 1
PASSED_CASES="$PASSED_CASES $CASENO" PASSED_CASES="$PASSED_CASES $CASENO"
return 0 return 0
;; ;;
$FAIL) $FAIL)
prlog " [${color_red}FAIL${color_reset}]" prlog " [${color_red}FAIL${color_reset}]"
ktaptest 0
FAILED_CASES="$FAILED_CASES $CASENO" FAILED_CASES="$FAILED_CASES $CASENO"
return 1 # this is a bug. return 1 # this is a bug.
;; ;;
$UNRESOLVED) $UNRESOLVED)
prlog " [${color_blue}UNRESOLVED${color_reset}]" prlog " [${color_blue}UNRESOLVED${color_reset}]"
ktaptest 0 UNRESOLVED
UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO" UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO"
return $UNRESOLVED_RESULT # depends on use case return $UNRESOLVED_RESULT # depends on use case
;; ;;
$UNTESTED) $UNTESTED)
prlog " [${color_blue}UNTESTED${color_reset}]" prlog " [${color_blue}UNTESTED${color_reset}]"
ktaptest 1 SKIP
UNTESTED_CASES="$UNTESTED_CASES $CASENO" UNTESTED_CASES="$UNTESTED_CASES $CASENO"
return 0 return 0
;; ;;
$UNSUPPORTED) $UNSUPPORTED)
prlog " [${color_blue}UNSUPPORTED${color_reset}]" prlog " [${color_blue}UNSUPPORTED${color_reset}]"
ktaptest 1 SKIP
UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO" UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO"
return $UNSUPPORTED_RESULT # depends on use case return $UNSUPPORTED_RESULT # depends on use case
;; ;;
$XFAIL) $XFAIL)
prlog " [${color_green}XFAIL${color_reset}]" prlog " [${color_green}XFAIL${color_reset}]"
ktaptest 1 XFAIL
XFAILED_CASES="$XFAILED_CASES $CASENO" XFAILED_CASES="$XFAILED_CASES $CASENO"
return 0 return 0
;; ;;
*) *)
prlog " [${color_blue}UNDEFINED${color_reset}]" prlog " [${color_blue}UNDEFINED${color_reset}]"
ktaptest 0 error
UNDEFINED_CASES="$UNDEFINED_CASES $CASENO" UNDEFINED_CASES="$UNDEFINED_CASES $CASENO"
return 1 # this must be a test bug return 1 # this must be a test bug
;; ;;
...@@ -371,6 +405,7 @@ __run_test() { # testfile ...@@ -371,6 +405,7 @@ __run_test() { # testfile
run_test() { # testfile run_test() { # testfile
local testname=`basename $1` local testname=`basename $1`
testcase $1 testcase $1
prlog -n "[$CASENO]$INSTANCE$CASENAME"
if [ ! -z "$LOG_FILE" ] ; then if [ ! -z "$LOG_FILE" ] ; then
local testlog=`mktemp $LOG_DIR/${CASENO}-${testname}-log.XXXXXX` local testlog=`mktemp $LOG_DIR/${CASENO}-${testname}-log.XXXXXX`
else else
...@@ -405,6 +440,17 @@ run_test() { # testfile ...@@ -405,6 +440,17 @@ run_test() { # testfile
# load in the helper functions # load in the helper functions
. $TEST_DIR/functions . $TEST_DIR/functions
if [ "$KTAP" = "1" ]; then
echo "TAP version 13"
casecount=`echo $TEST_CASES | wc -w`
for t in $TEST_CASES; do
test_on_instance $t || continue
casecount=$((casecount+1))
done
echo "1..${casecount}"
fi
# Main loop # Main loop
for t in $TEST_CASES; do for t in $TEST_CASES; do
run_test $t run_test $t
...@@ -439,6 +485,17 @@ prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w` ...@@ -439,6 +485,17 @@ prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w`
prlog "# of xfailed: " `echo $XFAILED_CASES | wc -w` prlog "# of xfailed: " `echo $XFAILED_CASES | wc -w`
prlog "# of undefined(test bug): " `echo $UNDEFINED_CASES | wc -w` prlog "# of undefined(test bug): " `echo $UNDEFINED_CASES | wc -w`
if [ "$KTAP" = "1" ]; then
echo -n "# Totals:"
echo -n " pass:"`echo $PASSED_CASES | wc -w`
echo -n " faii:"`echo $FAILED_CASES | wc -w`
echo -n " xfail:"`echo $XFAILED_CASES | wc -w`
echo -n " xpass:0"
echo -n " skip:"`echo $UNTESTED_CASES $UNSUPPORTED_CASES | wc -w`
echo -n " error:"`echo $UNRESOLVED_CASES $UNDEFINED_CASES | wc -w`
echo
fi
cleanup cleanup
# if no error, return 0 # if no error, return 0
......
#!/bin/sh -e
# SPDX-License-Identifier: GPL-2.0-only
#
# ftracetest-ktap: Wrapper to integrate ftracetest with the kselftest runner
#
# Copyright (C) Arm Ltd., 2023
./ftracetest -K
...@@ -17,6 +17,7 @@ ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \ ...@@ -17,6 +17,7 @@ ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \
-fno-stack-protector -mrdrnd $(INCLUDES) -fno-stack-protector -mrdrnd $(INCLUDES)
TEST_CUSTOM_PROGS := $(OUTPUT)/test_sgx TEST_CUSTOM_PROGS := $(OUTPUT)/test_sgx
TEST_FILES := $(OUTPUT)/test_encl.elf
ifeq ($(CAN_BUILD_X86_64), 1) ifeq ($(CAN_BUILD_X86_64), 1)
all: $(TEST_CUSTOM_PROGS) $(OUTPUT)/test_encl.elf all: $(TEST_CUSTOM_PROGS) $(OUTPUT)/test_encl.elf
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment