selftests: android: ion: return Kselftest Skip code for skipped tests
Subsystems (12)
Shuah Khan (Samsung OSG)
maintainerPATCH 1/24 selftests: android: ion: return Kselftest Skip code for skipped tests
When ion test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/android/ion/ion_test.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/android/ion/ion_test.sh +5 -2
@@ -4,6 +4,9 @@ heapsize=4096 TCID="ion_test.sh" errcode=0 +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + run_test() { heaptype=$1
@@ -25,7 +28,7 @@ check_root() uid=$(id -u) if [ $uid -ne 0 ]; then echo $TCID: must be run as root >&2 - exit 0 + exit $ksft_skip fi }
@@ -35,7 +38,7 @@ check_device() if [ ! -e $DEVICE ]; then echo $TCID: No $DEVICE device found >&2 echo $TCID: May be CONFIG_ION is not set >&2 - exit 0 + exit $ksft_skip fi }
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 2/24 selftests: breakpoints: return Kselftest Skip code for skipped tests
When step_after_suspend_test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use ksft_exit_skip() when a non-root user runs the test and add an explicit check for root and a clear message, instead of failing the test when /sys/power/state file open fails.
--- tools/testing/selftests/breakpoints/step_after_suspend_test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/testing/selftests/breakpoints/step_after_suspend_test.c +5 -1
@@ -143,10 +143,14 @@ void suspend(void)int err;struct itimerspec spec = {}; +if (getuid () !=0 ) +ksft_exit_skip ("Please run the test as root - Exiting.\n" ); + power_state_fd =open ("/sys/power/state" ,O_RDWR );if (power_state_fd <0 )ksft_exit_fail_msg ( -"open(\"/sys/power/state\") failed (is this test running as root?)\n" ); +"open(\"/sys/power/state\") failed %s)\n" , +strerror (errno)); timerfd =timerfd_create (CLOCK_BOOTTIME_ALARM ,0 );if (timerfd <0 )
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 3/24 selftests: cpu-hotplug: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When cpu-on-off-test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh +8 -6
@@ -2,6 +2,8 @@ # SPDX-License-Identifier: GPL-2.0 SYSFS= +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 prerequisite() {
@@ -9,7 +11,7 @@ prerequisite() if [ $UID != 0 ]; then echo $msg must be run as root >&2 - exit 0 + exit $ksft_skip fi taskset -p 01 $$
@@ -18,12 +20,12 @@ prerequisite() if [ ! -d "$SYSFS" ]; then echo $msg sysfs is not mounted >&2 - exit 0 + exit $ksft_skip fi if ! ls $SYSFS/devices/system/cpu/cpu* > /dev/null 2>&1; then echo $msg cpu hotplug is not supported >&2 - exit 0 + exit $ksft_skip fi echo "CPU online/offline summary:"
@@ -32,7 +34,7 @@ prerequisite() if [[ "$online_cpus" = "$online_max" ]]; then echo "$msg: since there is only one cpu: $online_cpus" - exit 0 + exit $ksft_skip fi echo -e "\t Cpus in online state: $online_cpus"
@@ -237,12 +239,12 @@ prerequisite_extra() if [ ! -d "$DEBUGFS" ]; then echo $msg debugfs is not mounted >&2 - exit 0 + exit $ksft_skip fi if [ ! -d $NOTIFIER_ERR_INJECT_DIR ]; then echo $msg cpu-notifier-error-inject module is not available >&2 - exit 0 + exit $ksft_skip fi }
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 4/24 selftests: cpufreq: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When cpufreq test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/cpufreq/main.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/cpufreq/main.sh +4 -1
@@ -13,6 +13,9 @@ SYSFS= CPUROOT= CPUFREQROOT= +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + helpme() { printf "Usage: $0 [-h] [-todg args]
@@ -38,7 +41,7 @@ prerequisite() if [ $UID != 0 ]; then echo $msg must be run as root >&2 - exit 2 + exit $ksft_skip fi taskset -p 01 $$
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 5/24 selftests: efivarfs: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When efivarfs test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/efivarfs/efivarfs.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/efivarfs/efivarfs.sh +5 -2
@@ -4,18 +4,21 @@ efivarfs_mount=/sys/firmware/efi/efivars test_guid=210be57c-9849-4fc7-a635-e6382d1aec27 +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + check_prereqs() { local msg="skip all tests:" if [ $UID != 0 ]; then echo $msg must be run as root >&2 - exit 0 + exit $ksft_skip fi if ! grep -q "^\S\+ $efivarfs_mount efivarfs" /proc/mounts; then echo $msg efivarfs is not mounted on $efivarfs_mount >&2 - exit 0 + exit $ksft_skip fi }
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 6/24 selftests: exec: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When execveat test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use ksft_exit_skip() when kernel doesn't support execveat.
--- tools/testing/selftests/exec/execveat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/exec/execveat.c +4 -2
@@ -20,6 +20,8 @@#include <string.h> #include <unistd.h> +#include "../kselftest.h" +static char longpath[2 *PATH_MAX ] ="" ;static char *envp[] = {"IN_TEST=yes" ,NULL ,NULL };static char *argv[] = {"execveat" ,"99" ,NULL };
@@ -249,8 +251,8 @@ static int run_tests(void) errno =0 ;execveat_ (-1 ,NULL ,NULL ,NULL ,0 );if (errno ==ENOSYS ) { -printf ("[FAIL] ENOSYS calling execveat - no kernel support?\n" ); -return 1 ; +ksft_exit_skip ( +"ENOSYS calling execveat - no kernel support?\n" ); }/* Change file position to confirm it doesn't affect anything */
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 7/24 selftests: filesystems: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When devpts_pts test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
In another case, it returns pass for a skipped test reporting a false postive.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use ksft_exit_skip() when test is skipped.
--- tools/testing/selftests/filesystems/devpts_pts.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/filesystems/devpts_pts.c +7 -4
@@ -11,6 +11,7 @@#include <sys/ioctl.h> #include <sys/mount.h> #include <sys/wait.h> +#include "../kselftest.h" static bool terminal_dup2 (int duplicate,int original) {
@@ -125,10 +126,12 @@ static int do_tiocgptpeer(char *ptmx, char *expected_procfd_contents)if (errno ==EINVAL ) {fprintf (stderr,"TIOCGPTPEER is not supported. " "Skipping test.\n" ); - fret =EXIT_SUCCESS ; + fret =KSFT_SKIP ; + }else { +fprintf (stderr, +"Failed to perform TIOCGPTPEER ioctl\n" ); + fret =EXIT_FAILURE ; } - -fprintf (stderr,"Failed to perform TIOCGPTPEER ioctl\n" ); goto do_cleanup; }
@@ -281,7 +284,7 @@ int main(int argc, char *argv[])if (!isatty (STDIN_FILENO )) {fprintf (stderr,"Standard input file desciptor is not attached " "to a terminal. Skipping test\n" ); -exit (EXIT_FAILURE ); +exit (KSFT_SKIP ); } ret =unshare (CLONE_NEWNS );
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 8/24 selftests: firmware: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When firmware test(s) get skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/firmware/fw_fallback.sh | 4 ++-- tools/testing/selftests/firmware/fw_filesystem.sh | 4 +++- tools/testing/selftests/firmware/fw_lib.sh | 7 +++++-- 3 files changed, 10 insertions(+), 5 deletions(-)
tools/testing/selftests/firmware/fw_fallback.sh +2 -2
@@ -74,7 +74,7 @@ load_fw_custom() { if [ ! -e "$DIR"/trigger_custom_fallback ]; then echo "$0: custom fallback trigger not present, ignoring test" >&2 - return 1 + exit $ksft_skip fi local name="$1"
@@ -107,7 +107,7 @@ load_fw_custom_cancel() { if [ ! -e "$DIR"/trigger_custom_fallback ]; then echo "$0: canceling custom fallback trigger not present, ignoring test" >&2 - return 1 + exit $ksft_skip fi local name="$1"
tools/testing/selftests/firmware/fw_filesystem.sh +3 -1
@@ -30,6 +30,7 @@ fi if [ ! -e "$DIR"/trigger_async_request ]; then echo "$0: empty filename: async trigger not present, ignoring test" >&2 + exit $ksft_skip else if printf '\000' >"$DIR"/trigger_async_request 2> /dev/null; then echo "$0: empty filename should not succeed (async)" >&2
@@ -69,6 +70,7 @@ fi # Try the asynchronous version too if [ ! -e "$DIR"/trigger_async_request ]; then echo "$0: firmware loading: async trigger not present, ignoring test" >&2 + exit $ksft_skip else if ! echo -n "$NAME" >"$DIR"/trigger_async_request ; then echo "$0: could not trigger async request" >&2
@@ -89,7 +91,7 @@ test_config_present() { if [ ! -f $DIR/reset ]; then echo "Configuration triggers not present, ignoring test" - exit 0 + exit $ksft_skip fi }
tools/testing/selftests/firmware/fw_lib.sh +5 -2
@@ -9,11 +9,14 @@ DIR=/sys/devices/virtual/misc/test_firmware PROC_CONFIG="/proc/config.gz" TEST_DIR=$(dirname $0) +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + print_reqs_exit() { echo "You must have the following enabled in your kernel:" >&2 cat $TEST_DIR/config >&2 - exit 1 + exit $ksft_skip } test_modprobe()
@@ -88,7 +91,7 @@ verify_reqs() if [ "$TEST_REQS_FW_SYSFS_FALLBACK" = "yes" ]; then if [ ! "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then echo "usermode helper disabled so ignoring test" - exit 0 + exit $ksft_skip fi fi }
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 9/24 selftests: ftrace: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When ftrace test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/ftrace/ftracetest | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +6 -2
@@ -23,6 +23,9 @@ echo " If <dir> is -, all logs output in console only" exit $1 } +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + errexit() { # message echo "Error: $1" 1>&2 exit 1
@@ -30,7 +33,8 @@ errexit() { # message # Ensuring user privilege if [ `id -u` -ne 0 ]; then - errexit "this must be run by root user" + echo "Skipping: test must be run by root user" + exit $ksft_skip fi # Utilities
@@ -249,7 +253,7 @@ trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED SIG_UNSUPPORTED=$((SIG_BASE + UNSUPPORTED)) exit_unsupported () { kill -s $SIG_UNSUPPORTED $SIG_PID - exit 0 + exit $ksft_skip } trap 'SIG_RESULT=$UNSUPPORTED' $SIG_UNSUPPORTED
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 10/24 selftests: gpio: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When gpio test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/gpio/gpio-mockup.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
tools/testing/selftests/gpio/gpio-mockup.sh +8 -4
@@ -2,10 +2,11 @@ # SPDX-License-Identifier: GPL-2.0 #exit status -#1: run as non-root user +#1: Internal error #2: sysfs/debugfs not mount #3: insert module fail when gpio-mockup is a module. -#4: other reason. +#4: Skip test including run as non-root user. +#5: other reason. SYSFS= GPIO_SYSFS=
@@ -15,6 +16,9 @@ GPIO_DEBUGFS= dev_type= module= +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + usage() { echo "Usage:"
@@ -34,7 +38,7 @@ prerequisite() msg="skip all tests:" if [ $UID != 0 ]; then echo $msg must be run as root >&2 - exit 1 + exit $ksft_skip fi SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` if [ ! -d "$SYSFS" ]; then
@@ -73,7 +77,7 @@ remove_module() die() { remove_module - exit 4 + exit 5 } test_chips()
Signature · 1 line
2.14.1
Shuah Khan (Samsung OSG)
maintainerPATCH 11/24 selftests: intel_pstate: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When intel_pstate test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/intel_pstate/run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/intel_pstate/run.sh +4 -1
@@ -30,9 +30,12 @@ EVALUATE_ONLY=0 +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + if ! uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ | grep -q x86; then echo "$0 # Skipped: Test can only run on x86 architectures." - exit 0 + exit $ksft_skip fi max_cpus=$(($(nproc)-1))
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 12/24 selftests: ipc: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When ipc test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use ksft_exit_skip() when the test is skipped.
--- tools/testing/selftests/ipc/msgque.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/testing/selftests/ipc/msgque.c +3 -4
@@ -196,10 +196,9 @@ int main(int argc, char **argv)int msg, pid, err;struct msgque_data msgque; -if (getuid () !=0 ) { -printf ("Please run the test as root - Exiting.\n" ); -return ksft_exit_fail (); - } +if (getuid () !=0 ) +return ksft_exit_skip ( +"Please run the test as root - Exiting.\n" ); msgque.key =ftok (argv[0 ],822155650 );if (msgque.key ==-1 ) {
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 13/24 selftests: kmod: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When kmod test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run. It returns fail in some cases when test is skipped. Either way, it is incorrect and incosnistent reporting.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/kmod/kmod.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
tools/testing/selftests/kmod/kmod.sh +8 -5
@@ -62,13 +62,16 @@ ALL_TESTS="$ALL_TESTS 0007:5:1" ALL_TESTS="$ALL_TESTS 0008:150:1" ALL_TESTS="$ALL_TESTS 0009:150:1" +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + test_modprobe() { if [ ! -d $DIR ]; then echo "$0: $DIR not present" >&2 echo "You must have the following enabled in your kernel:" >&2 cat $TEST_DIR/config >&2 - exit 1 + exit $ksft_skip fi }
@@ -105,12 +108,12 @@ test_reqs() { if ! which modprobe 2> /dev/null > /dev/null; then echo "$0: You need modprobe installed" >&2 - exit 1 + exit $ksft_skip fi if ! which kmod 2> /dev/null > /dev/null; then echo "$0: You need kmod installed" >&2 - exit 1 + exit $ksft_skip fi # kmod 19 has a bad bug where it returns 0 when modprobe
@@ -124,13 +127,13 @@ test_reqs() echo "$0: You need at least kmod 20" >&2 echo "kmod <= 19 is buggy, for details see:" >&2 echo "http://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/libkmod/libkmod-module.c?id=fd44a98ae2eb5eb32161088954ab21e58e19dfc4" >&2 - exit 1 + exit $ksft_skip fi uid=$(id -u) if [ $uid -ne 0 ]; then echo $msg must be run as root >&2 - exit 0 + exit $ksft_skip fi }
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 14/24 selftests: kvm: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When kvm test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use ksft_exit_skip() when the test is skipped. In addition, refine test_assert() message to include strerror() string and add explicit check for root user to clearly identofy non-root user skip case.
--- tools/testing/selftests/kvm/lib/assert.c | 10 ++++++++-- tools/testing/selftests/kvm/vmx_tsc_adjust_test.c | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-)
tools/testing/selftests/kvm/lib/assert.c +8 -2
@@ -13,6 +13,8 @@#include <execinfo.h> #include <sys/syscall.h> +#include "../../kselftest.h" +/* Dumps the current stack trace to stderr. */ static void __attribute__((noinline))test_dump_stack (void );static void test_dump_stack (void )
@@ -65,13 +67,17 @@ test_assert(bool exp, const char *exp_str, {va_list ap; +if (getuid () !=0 ) +ksft_exit_skip ("Please run the test as root - Exiting.\n" ); +if (!(exp)) {va_start (ap, fmt);fprintf (stderr,"==== Test Assertion Failure ====\n" " %s:%u: %s\n" -" pid=%d tid=%d\n" , - file, line, exp_str,getpid (),gettid ()); +" pid=%d tid=%d - %s\n" , + file, line, exp_str,getpid (),gettid (), +strerror (errno));test_dump_stack ();if (fmt) {fputs (" " , stderr);
tools/testing/selftests/kvm/vmx_tsc_adjust_test.c +3 -1
@@ -28,6 +28,8 @@#include <string.h> #include <sys/ioctl.h> +#include "../kselftest.h" +#ifndef MSR_IA32_TSC_ADJUST #define MSR_IA32_TSC_ADJUST 0x3b#endif
@@ -190,7 +192,7 @@ int main(int argc, char *argv[])if (!(entry->ecx &CPUID_VMX )) {printf ("nested VMX not enabled, skipping test" ); -return 0 ; +return KSFT_SKIP ; } vm =vm_create_default_vmx (VCPU_ID , (void *) l1_guest_code);
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 15/24 selftests: lib: add prime_numbers.sh test to Makefile
In reply to Shuah Khan (Samsung OSG)prime_numbers.sh is not included in TEST_PROGS. Add it.
--- tools/testing/selftests/lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/lib/Makefile +1 -1
@@ -3,6 +3,6 @@ # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" all: -TEST_PROGS := printf.sh bitmap.sh +TEST_PROGS := printf.sh bitmap.sh prime_numbers.sh include ../lib.mk
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 16/24 selftests: lib: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When lib test(s) is skipped because of unmet dependencies and/or unsupported configuration, it returns non-zero value hich is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/lib/bitmap.sh | 8 ++++++-- tools/testing/selftests/lib/prime_numbers.sh | 7 +++++-- tools/testing/selftests/lib/printf.sh | 8 ++++++-- 3 files changed, 17 insertions(+), 6 deletions(-)
tools/testing/selftests/lib/bitmap.sh +6 -2
@@ -1,9 +1,13 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + # Runs bitmap infrastructure tests using test_bitmap kernel module if ! /sbin/modprobe -q -n test_bitmap; then - echo "bitmap: [SKIP]" - exit 77 + echo "bitmap: module test_bitmap is not found [SKIP]" + exit $ksft_skip fi if /sbin/modprobe -q test_bitmap; then
tools/testing/selftests/lib/prime_numbers.sh +5 -2
@@ -2,9 +2,12 @@ # SPDX-License-Identifier: GPL-2.0 # Checks fast/slow prime_number generation for inconsistencies +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + if ! /sbin/modprobe -q -r prime_numbers; then - echo "prime_numbers: [SKIP]" - exit 77 + echo "prime_numbers: module prime_numbers is not found [SKIP]" + exit $ksft_skip fi if /sbin/modprobe -q prime_numbers selftest=65536; then
tools/testing/selftests/lib/printf.sh +6 -2
@@ -1,9 +1,13 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # Runs printf infrastructure using test_printf kernel module + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + if ! /sbin/modprobe -q -n test_printf; then - echo "printf: [SKIP]" - exit 77 + echo "printf: module test_printf is not found [SKIP]" + exit $ksft_skip fi if /sbin/modprobe -q test_printf; then
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 17/24 selftests: locking: add Makefile for locking test
In reply to Shuah Khan (Samsung OSG)Add Makefile for locking test.
--- tools/testing/selftests/locking/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tools/testing/selftests/locking/Makefile
tools/testing/selftests/locking/Makefile new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for locking/ww_mutx selftests + +# No binaries, but make sure arg-less "make" doesn't trigger "run_tests" +all: + +TEST_PROGS := ww_mutex.sh + +include ../lib.mk
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 18/24 selftests: locking: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When locking test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Added an explicit search for ww_mutex module and return skip code if it isn't found to differentiate between the failure to load the module condition and module not found condition.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/locking/ww_mutex.sh | 8 ++++++++ 1 file changed, 8 insertions(+) mode change 100644 => 100755 tools/testing/selftests/locking/ww_mutex.sh
tools/testing/selftests/locking/ww_mutex.sh +8 -0
@@ -1,6 +1,14 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + # Runs API tests for struct ww_mutex (Wait/Wound mutexes) +if ! /sbin/modprobe -q -n test-ww_mutex; then + echo "ww_mutex: module test-ww_mutex is not found [SKIP]" + exit $ksft_skip +fi if /sbin/modprobe -q test-ww_mutex; then /sbin/modprobe -q -r test-ww_mutex
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 19/24 selftests: media_tests: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When media_tests test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use ksft_exit_skip() when the test is skipped.
--- tools/testing/selftests/media_tests/Makefile | 3 ++- tools/testing/selftests/media_tests/media_device_open.c | 8 ++++---- tools/testing/selftests/media_tests/media_device_test.c | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-)
tools/testing/selftests/media_tests/Makefile +2 -1
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 +# +CFLAGS += -I../ -I../../../../usr/include/ TEST_GEN_PROGS := media_device_test media_device_open video_device_test -all: $(TEST_GEN_PROGS) include ../lib.mk
tools/testing/selftests/media_tests/media_device_open.c +4 -4
@@ -34,6 +34,8 @@#include <sys/stat.h> #include <linux/media.h> +#include "../kselftest.h" +int main (int argc,char **argv) {int opt;
@@ -61,10 +63,8 @@ int main(int argc, char **argv) } } -if (getuid () !=0 ) { -printf ("Please run the test as root - Exiting.\n" ); -exit (-1 ); - } +if (getuid () !=0 ) +ksft_exit_skip ("Please run the test as root - Exiting.\n" );/* Open Media device and keep it open */ fd =open (media_device,O_RDWR );
tools/testing/selftests/media_tests/media_device_test.c +4 -4
@@ -39,6 +39,8 @@#include <time.h> #include <linux/media.h> +#include "../kselftest.h" +int main (int argc,char **argv) {int opt;
@@ -66,10 +68,8 @@ int main(int argc, char **argv) } } -if (getuid () !=0 ) { -printf ("Please run the test as root - Exiting.\n" ); -exit (-1 ); - } +if (getuid () !=0 ) +ksft_exit_skip ("Please run the test as root - Exiting.\n" );/* Generate random number of interations */ srand ((unsigned int )time (NULL ));
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 20/24 selftests: membarrier: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When membarrier test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use ksft_exit_skip() when the test is skipped.
--- tools/testing/selftests/membarrier/membarrier_test.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/testing/selftests/membarrier/membarrier_test.c +3 -4
@@ -293,10 +293,9 @@ static int test_membarrier_query(void) }ksft_exit_fail_msg ("sys_membarrier() failed\n" ); } -if (!(ret &MEMBARRIER_CMD_GLOBAL )) { -ksft_test_result_fail ("sys_membarrier() CMD_GLOBAL query failed\n" ); -ksft_exit_fail_msg ("sys_membarrier is not supported.\n" ); - } +if (!(ret &MEMBARRIER_CMD_GLOBAL )) +ksft_exit_skip ( +"sys_membarrier unsupported: CMD_GLOBAL not found.\n" );ksft_test_result_pass ("sys_membarrier available\n" );return 0 ;
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 21/24 selftests: memfd: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When memfd test is skipped because of unmet dependencies and/or unsupported configuration, it returns non-zero value which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Added an explicit check for root user and return skip code.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/memfd/run_tests.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/memfd/run_tests.sh +9 -1
@@ -1,6 +1,14 @@ #!/bin/bash # please run as root +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +if [ $UID != 0 ]; then + echo "Please run this test as root" + exit $ksft_skip +fi + # # Normal tests requiring no special resources #
@@ -33,7 +41,7 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages if [ $? -ne 0 ]; then echo "Please run this test as root" - exit 1 + exit $ksft_skip fi while read name size unit; do if [ "$name" = "HugePages_Free:" ]; then
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 22/24 selftests: memory-hotplug: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When memory-hotplug test is skipped because of unmet dependencies and/or unsupported configuration, it returns non-zero value hich is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
--- tools/testing/selftests/memory-hotplug/mem-on-off-test.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/memory-hotplug/mem-on-off-test.sh +7 -4
@@ -3,30 +3,33 @@ SYSFS= +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + prerequisite() { msg="skip all tests:" if [ $UID != 0 ]; then echo $msg must be run as root >&2 - exit 0 + exit $ksft_skip fi SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` if [ ! -d "$SYSFS" ]; then echo $msg sysfs is not mounted >&2 - exit 0 + exit $ksft_skip fi if ! ls $SYSFS/devices/system/memory/memory* > /dev/null 2>&1; then echo $msg memory hotplug is not supported >&2 - exit 0 + exit $ksft_skip fi if ! grep -q 1 $SYSFS/devices/system/memory/memory*/removable; then echo $msg no hot-pluggable memory >&2 - exit 0 + exit $ksft_skip fi }
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 23/24 selftests: mqueue: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When mqueue test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use ksft_exit_skip() when the test is skipped.
--- tools/testing/selftests/mqueue/mq_open_tests.c | 8 ++++---- tools/testing/selftests/mqueue/mq_perf_tests.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
tools/testing/selftests/mqueue/mq_open_tests.c +4 -4
@@ -33,6 +33,8 @@#include <mqueue.h> #include <error.h> +#include "../kselftest.h" +static char *usage ="Usage:\n" " %s path\n"
@@ -262,12 +264,10 @@ int main(int argc, char *argv[]) } } -if (getuid () !=0 ) { -fprintf (stderr,"Not running as root, but almost all tests " +if (getuid () !=0 ) +ksft_exit_skip ("Not running as root, but almost all tests " "require root in order to modify\nsystem settings. " "Exiting.\n" ); -exit (1 ); - }/* Find out what files there are for us to make tweaks in */ def_msgs =fopen (DEF_MSGS ,"r+" );
tools/testing/selftests/mqueue/mq_perf_tests.c +4 -4
@@ -39,6 +39,8 @@#include <popt.h> #include <error.h> +#include "../kselftest.h" +static char *usage ="Usage:\n" " %s [-c #[,#..] -f] path\n"
@@ -626,12 +628,10 @@ int main(int argc, char *argv[]) cpus_to_pin[0 ] = cpus_online -1 ; } -if (getuid () !=0 ) { -fprintf (stderr,"Not running as root, but almost all tests " +if (getuid () !=0 ) +ksft_exit_skip ("Not running as root, but almost all tests " "require root in order to modify\nsystem settings. " "Exiting.\n" ); -exit (1 ); - } max_msgs =fopen (MAX_MSGS ,"r+" ); max_msgsize =fopen (MAX_MSGSIZE ,"r+" );
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan (Samsung OSG)
maintainerPATCH 24/24 selftests: net: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)When net test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Change psock_tpacket to use ksft_exit_skip() when a non-root user runs the test and add an explicit check for root and a clear message, instead of failing the test when /sys/power/state file open fails.
--- tools/testing/selftests/net/fib_tests.sh | 8 +++++--- tools/testing/selftests/net/netdevice.sh | 16 +++++++++------ tools/testing/selftests/net/pmtu.sh | 5 ++++- tools/testing/selftests/net/psock_tpacket.c | 4 +++- tools/testing/selftests/net/rtnetlink.sh | 31 ++++++++++++++++------------- 5 files changed, 39 insertions(+), 25 deletions(-)
tools/testing/selftests/net/fib_tests.sh +5 -3
@@ -5,6 +5,8 @@ # different events. ret=0 +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 VERBOSE=${VERBOSE:=0} PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
@@ -579,18 +581,18 @@ fib_test() if [ "$(id -u)" -ne 0 ];then echo "SKIP: Need root privileges" - exit 0 + exit $ksft_skip; fi if [ ! -x "$(command -v ip)" ]; then echo "SKIP: Could not run test without ip tool" - exit 0 + exit $ksft_skip fi ip route help 2>&1 | grep -q fibmatch if [ $? -ne 0 ]; then echo "SKIP: iproute2 too old, missing fibmatch" - exit 0 + exit $ksft_skip fi # start clean
tools/testing/selftests/net/netdevice.sh +10 -6
@@ -8,6 +8,9 @@ # if not they probably have failed earlier in the boot process and their logged error will be catched by another test # +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + # this function will try to up the interface # if already up, nothing done # arg1: network interface name
@@ -18,7 +21,7 @@ kci_net_start() ip link show "$netdev" |grep -q UP if [ $? -eq 0 ];then echo "SKIP: $netdev: interface already up" - return 0 + return $ksft_skip fi ip link set "$netdev" up
@@ -61,12 +64,12 @@ kci_net_setup() ip address show "$netdev" |grep '^[[:space:]]*inet' if [ $? -eq 0 ];then echo "SKIP: $netdev: already have an IP" - return 0 + return $ksft_skip fi # TODO what ipaddr to set ? DHCP ? echo "SKIP: $netdev: set IP address" - return 0 + return $ksft_skip } # test an ethtool command
@@ -84,6 +87,7 @@ kci_netdev_ethtool_test() if [ $ret -ne 0 ];then if [ $ret -eq "$1" ];then echo "SKIP: $netdev: ethtool $2 not supported" + return $ksft_skip else echo "FAIL: $netdev: ethtool $2" return 1
@@ -104,7 +108,7 @@ kci_netdev_ethtool() ethtool --version 2>/dev/null >/dev/null if [ $? -ne 0 ];then echo "SKIP: ethtool not present" - return 1 + return $ksft_skip fi TMP_ETHTOOL_FEATURES="$(mktemp)"
@@ -176,13 +180,13 @@ kci_test_netdev() #check for needed privileges if [ "$(id -u)" -ne 0 ];then echo "SKIP: Need root privileges" - exit 0 + exit $ksft_skip fi ip link show 2>/dev/null >/dev/null if [ $? -ne 0 ];then echo "SKIP: Could not run test without the ip tool" - exit 0 + exit $ksft_skip fi TMP_LIST_NETDEV="$(mktemp)"
tools/testing/selftests/net/pmtu.sh +4 -1
@@ -43,6 +43,9 @@ # that MTU is properly calculated instead when MTU is not configured from # userspace +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + tests=" pmtu_vti6_exception vti6: PMTU exceptions pmtu_vti4_exception vti4: PMTU exceptions
@@ -162,7 +165,7 @@ setup_xfrm6() { } setup() { - [ "$(id -u)" -ne 0 ] && echo " need to run as root" && return 1 + [ "$(id -u)" -ne 0 ] && echo " need to run as root" && return $ksft_skip cleanup_done=0 for arg do
tools/testing/selftests/net/psock_tpacket.c +3 -1
@@ -60,6 +60,8 @@#include "psock_lib.h" +#include "../kselftest.h" +#ifndef bug_on# define bug_on (cond) assert(!(cond))#endif
@@ -825,7 +827,7 @@ static int test_tpacket(int version, int type)fprintf (stderr,"test: skip %s %s since user and kernel " "space have different bit width\n" , tpacket_str[version], type_str[type]); -return 0 ; +return KSFT_SKIP ; } sock =pfsocket (version);
tools/testing/selftests/net/rtnetlink.sh +17 -14
@@ -7,6 +7,9 @@ devdummy="test-dummy0" ret=0 +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + # set global exit status, but never reset nonzero one. check_err() {
@@ -333,7 +336,7 @@ kci_test_vrf() ip link show type vrf 2>/dev/null if [ $? -ne 0 ]; then echo "SKIP: vrf: iproute2 too old" - return 0 + return $ksft_skip fi ip link add "$vrfname" type vrf table 10
@@ -409,7 +412,7 @@ kci_test_encap_fou() ip fou help 2>&1 |grep -q 'Usage: ip fou' if [ $? -ne 0 ];then echo "SKIP: fou: iproute2 too old" - return 1 + return $ksft_skip fi ip netns exec "$testns" ip fou add port 7777 ipproto 47 2>/dev/null
@@ -444,7 +447,7 @@ kci_test_encap() ip netns add "$testns" if [ $? -ne 0 ]; then echo "SKIP encap tests: cannot add net namespace $testns" - return 1 + return $ksft_skip fi ip netns exec "$testns" ip link set lo up
@@ -469,7 +472,7 @@ kci_test_macsec() ip macsec help 2>&1 | grep -q "^Usage: ip macsec" if [ $? -ne 0 ]; then echo "SKIP: macsec: iproute2 too old" - return 0 + return $ksft_skip fi ip link add link "$devdummy" "$msname" type macsec port 42 encrypt on
@@ -511,14 +514,14 @@ kci_test_gretap() ip netns add "$testns" if [ $? -ne 0 ]; then echo "SKIP gretap tests: cannot add net namespace $testns" - return 1 + return $ksft_skip fi ip link help gretap 2>&1 | grep -q "^Usage:" if [ $? -ne 0 ];then echo "SKIP: gretap: iproute2 too old" ip netns del "$testns" - return 1 + return $ksft_skip fi # test native tunnel
@@ -561,14 +564,14 @@ kci_test_ip6gretap() ip netns add "$testns" if [ $? -ne 0 ]; then echo "SKIP ip6gretap tests: cannot add net namespace $testns" - return 1 + return $ksft_skip fi ip link help ip6gretap 2>&1 | grep -q "^Usage:" if [ $? -ne 0 ];then echo "SKIP: ip6gretap: iproute2 too old" ip netns del "$testns" - return 1 + return $ksft_skip fi # test native tunnel
@@ -611,13 +614,13 @@ kci_test_erspan() ip link help erspan 2>&1 | grep -q "^Usage:" if [ $? -ne 0 ];then echo "SKIP: erspan: iproute2 too old" - return 1 + return $ksft_skip fi ip netns add "$testns" if [ $? -ne 0 ]; then echo "SKIP erspan tests: cannot add net namespace $testns" - return 1 + return $ksft_skip fi # test native tunnel erspan v1
@@ -676,13 +679,13 @@ kci_test_ip6erspan() ip link help ip6erspan 2>&1 | grep -q "^Usage:" if [ $? -ne 0 ];then echo "SKIP: ip6erspan: iproute2 too old" - return 1 + return $ksft_skip fi ip netns add "$testns" if [ $? -ne 0 ]; then echo "SKIP ip6erspan tests: cannot add net namespace $testns" - return 1 + return $ksft_skip fi # test native tunnel ip6erspan v1
@@ -762,14 +765,14 @@ kci_test_rtnl() #check for needed privileges if [ "$(id -u)" -ne 0 ];then echo "SKIP: Need root privileges" - exit 0 + exit $ksft_skip fi for x in ip tc;do $x -Version 2>/dev/null >/dev/null if [ $? -ne 0 ];then echo "SKIP: Could not run test without the $x tool" - exit 0 + exit $ksft_skip fi done
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 21/24] selftests: memfd: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 38 lines · Shuah Khan (Samsung OSG)
When memfd test is skipped because of unmet dependencies and/or unsupported configuration, it returns non-zero value which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Added an explicit check for root user and return skip code.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/memfd/run_tests.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)tools/testing/selftests/memfd/run_tests.sh +8
-0@@ -1,6 +1,14 @@ #!/bin/bash # please run as root +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +if [ $UID != 0 ]; then + echo "Please run this test as root" + exit $ksft_skip +fi + # # Normal tests requiring no special resources #
tools/testing/selftests/memfd/run_tests.sh if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then · line 44
Quoted 5 lines
tools/testing/selftests/memfd/run_tests.sh +1
-1@@ -33,7 +41,7 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages if [ $? -ne 0 ]; then echo "Please run this test as root" - exit 1 + exit $ksft_skip
We now KNOW that we are running as root because of the check above. We can delete this test, and rely on the later check to determine if the number of huge pages was actually increased.
How about this instead (untested)?
tools/testing/selftests/memfd/run_tests.sh +9 -5
@@ -1,6 +1,14 @@ #!/bin/bash # please run as root +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +if [ $UID != 0 ]; then + echo "Please run this test as root" + exit $ksft_skip +fi + # # Normal tests requiring no special resources #
@@ -31,10 +39,6 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then echo 3 > /proc/sys/vm/drop_caches echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages - if [ $? -ne 0 ]; then - echo "Please run this test as root" - exit 1 - fi while read name size unit; do if [ "$name" = "HugePages_Free:" ]; then freepgs=$size
@@ -53,7 +57,7 @@ if [ $freepgs -lt $hpages_test ]; then fi printf "Not enough huge pages available (%d < %d)\n" \ $freepgs $needpgs - exit 1 + exit $ksft_skip fi #
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 07/24] selftests: filesystems: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 8 lines · Shuah Khan (Samsung OSG)
When
devpts_ptstest is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.In another case, it returns pass for a skipped test reporting a false postive.
Quoted 6 lines
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use
ksft_exit_skip()when test is skipped.Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>
Thanks, Shuah!
Christian
Quoted 44 lines
--- tools/testing/selftests/filesystems/devpts_pts.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)tools/testing/selftests/filesystems/devpts_pts.c +7
-4@@ -11,6 +11,7 @@#include <sys/ioctl.h> #include <sys/mount.h> #include <sys/wait.h> +#include "../kselftest.h" static bool terminal_dup2 (int duplicate,int original) {@@ -125,10 +126,12 @@ static int do_tiocgptpeer(char *ptmx, char *expected_procfd_contents)if (errno ==EINVAL ) {fprintf (stderr,"TIOCGPTPEER is not supported. " "Skipping test.\n" ); - fret =EXIT_SUCCESS ; + fret =KSFT_SKIP ; + }else { +fprintf (stderr, +"Failed to perform TIOCGPTPEER ioctl\n" ); + fret =EXIT_FAILURE ; } - -fprintf (stderr,"Failed to perform TIOCGPTPEER ioctl\n" ); goto do_cleanup; }@@ -281,7 +284,7 @@ int main(int argc, char *argv[])if (!isatty (STDIN_FILENO )) {fprintf (stderr,"Standard input file desciptor is not attached " "to a terminal. Skipping test\n" ); -exit (EXIT_FAILURE ); +exit (KSFT_SKIP ); } ret =unshare (CLONE_NEWNS );Signature · 1 line
2.14.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 04/24] selftests: cpufreq: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 31 lines · Shuah Khan (Samsung OSG)
When cpufreq test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/cpufreq/main.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/testing/selftests/cpufreq/main.sh +3
-0@@ -13,6 +13,9 @@ SYSFS= CPUROOT= CPUFREQROOT= +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + helpme() { printf "Usage: $0 [-h] [-todg args]
tools/testing/selftests/cpufreq/main.sh prerequisite() · line 47
Quoted 8 lines
tools/testing/selftests/cpufreq/main.sh +1
-1@@ -38,7 +41,7 @@ prerequisite() if [ $UID != 0 ]; then echo $msg must be run as root >&2 - exit 2 + exit $ksft_skip fi taskset -p 01 $$
Signature · 5 lines
viresh -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 40 lines · Shuah Khan (Samsung OSG)
When ion test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/android/ion/ion_test.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/testing/selftests/android/ion/ion_test.sh +4
-1@@ -4,6 +4,9 @@ heapsize=4096 TCID="ion_test.sh" errcode=0 +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + run_test() { heaptype=$1@@ -25,7 +28,7 @@ check_root() uid=$(id -u) if [ $uid -ne 0 ]; then echo $TCID: must be run as root >&2 - exit 0 + exit $ksft_skip fi }
tools/testing/selftests/android/ion/ion_test.sh check_device() · line 44
Quoted 8 lines
tools/testing/selftests/android/ion/ion_test.sh +1
-1@@ -35,7 +38,7 @@ check_device() if [ ! -e $DEVICE ]; then echo $TCID: No $DEVICE device found >&2 echo $TCID: May be CONFIG_ION is not set >&2 - exit 0 + exit $ksft_skip fi }
Ok changes looks good to me.
Quoted 3 lines
--
2.14.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 14/24] selftests: kvm: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 11 lines · Shuah Khan (Samsung OSG)
When kvm test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use
ksft_exit_skip()when the test is skipped. In addition, refinetest_assert()message to includestrerror()string and add explicit check for root user to clearly identofy non-root user skip case.
Root should not be needed.
Otherwise
Paolo
Quoted 20 lines
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/kvm/lib/assert.c | 10 ++++++++-- tools/testing/selftests/kvm/vmx_tsc_adjust_test.c | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-)tools/testing/selftests/kvm/lib/assert.c +2
-0@@ -13,6 +13,8 @@#include <execinfo.h> #include <sys/syscall.h> +#include "../../kselftest.h" +/* Dumps the current stack trace to stderr. */ static void __attribute__((noinline))test_dump_stack (void );static void test_dump_stack (void )
tools/testing/selftests/kvm/lib/assert.c test_assert(bool exp, const char *exp_str, · line 71
Quoted 5 lines
tools/testing/selftests/kvm/lib/assert.c +2
-0@@ -65,13 +67,17 @@ test_assert(bool exp, const char *exp_str, {va_list ap; +if (getuid () !=0 ) +ksft_exit_skip ("Please run the test as root - Exiting.\n" );
This should not be needed. Otherwise
Quoted 28 lines
tools/testing/selftests/kvm/lib/assert.c +3
-2if (!(exp)) {va_start (ap, fmt);fprintf (stderr,"==== Test Assertion Failure ====\n" " %s:%u: %s\n" -" pid=%d tid=%d\n" , - file, line, exp_str,getpid (),gettid ()); +" pid=%d tid=%d - %s\n" , + file, line, exp_str,getpid (),gettid (), +strerror (errno));test_dump_stack ();if (fmt) {fputs (" " , stderr);tools/testing/selftests/kvm/vmx_tsc_adjust_test.c +2
-0@@ -28,6 +28,8 @@#include <string.h> #include <sys/ioctl.h> +#include "../kselftest.h" +#ifndef MSR_IA32_TSC_ADJUST #define MSR_IA32_TSC_ADJUST 0x3b#endif
tools/testing/selftests/kvm/vmx_tsc_adjust_test.c int main(int argc, char *argv[]) · line 198
Quoted 8 lines
tools/testing/selftests/kvm/vmx_tsc_adjust_test.c +1
-1@@ -190,7 +192,7 @@ int main(int argc, char *argv[])if (!(entry->ecx &CPUID_VMX )) {printf ("nested VMX not enabled, skipping test" ); -return 0 ; +return KSFT_SKIP ; } vm =vm_create_default_vmx (VCPU_ID , (void *) l1_guest_code);
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Steven Rostedt
maintainerRe: [PATCH 09/24] selftests: ftrace: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 11 lines · On Fri, 4 May 2018 19:13:13 -0600 "Shuah Khan (Samsung OSG)" <shuah at…
When ftrace test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
I'm fine with this change, but I believe Masami and perhaps others have scripts that expect zero return.
If anything, we probably need to have a way to override the ksft_skip via a command line argument.
Masami?
-- Steve
Quoted 30 lines
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/ftrace/ftracetest | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)tools/testing/selftests/ftrace/ftracetest +5
-1@@ -23,6 +23,9 @@ echo " If <dir> is -, all logs output in console only" exit $1 } +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + errexit() { # message echo "Error: $1" 1>&2 exit 1@@ -30,7 +33,8 @@ errexit() { # message # Ensuring user privilege if [ `id -u` -ne 0 ]; then - errexit "this must be run by root user" + echo "Skipping: test must be run by root user" + exit $ksft_skip fi # Utilities
tools/testing/selftests/ftrace/ftracetest trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED · line 259
Quoted 8 lines
tools/testing/selftests/ftrace/ftracetest +1
-1@@ -249,7 +253,7 @@ trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED SIG_UNSUPPORTED=$((SIG_BASE + UNSUPPORTED)) exit_unsupported () { kill -s $SIG_UNSUPPORTED $SIG_PID - exit 0 + exit $ksft_skip } trap 'SIG_RESULT=$UNSUPPORTED' $SIG_UNSUPPORTED
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan
maintainerRe: [PATCH 21/24] selftests: memfd: return Kselftest Skip code for skipped tests
In reply to Mike KravetzQuoted 40 lines · Mike Kravetz
Quoted 39 lines · Shuah Khan (Samsung OSG)
When memfd test is skipped because of unmet dependencies and/or unsupported configuration, it returns non-zero value which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Added an explicit check for root user and return skip code.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/memfd/run_tests.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)tools/testing/selftests/memfd/run_tests.sh +8
-0@@ -1,6 +1,14 @@ #!/bin/bash # please run as root +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +if [ $UID != 0 ]; then + echo "Please run this test as root" + exit $ksft_skip +fi + # # Normal tests requiring no special resources #@@ -33,7 +41,7 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
Quoted 8 lines
tools/testing/selftests/memfd/run_tests.sh if [ $freepgs -lt $hpages_test ]; then · line 60
Quoted 4 lines
tools/testing/selftests/memfd/run_tests.sh +1
-1if [ $? -ne 0 ]; then echo "Please run this test as root" - exit 1 + exit $ksft_skipWe now KNOW that we are running as root because of the check above. We can delete this test, and rely on the later check to determine if the number of huge pages was actually increased.
Thanks for the review. Yesh this check can go away.
Quoted 35 lines
How about this instead (untested)?
Signed-off-by Mike Kravetz <mike.kravetz at oracle.com>tools/testing/selftests/memfd/run_tests.sh +8
-4@@ -1,6 +1,14 @@ #!/bin/bash # please run as root +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +if [ $UID != 0 ]; then + echo "Please run this test as root" + exit $ksft_skip +fi + # # Normal tests requiring no special resources #@@ -31,10 +39,6 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then echo 3 > /proc/sys/vm/drop_caches echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages - if [ $? -ne 0 ]; then - echo "Please run this test as root" - exit 1 - fi while read name size unit; do if [ "$name" = "HugePages_Free:" ]; then freepgs=$size
tools/testing/selftests/memfd/run_tests.sh if [ $freepgs -lt $hpages_test ]; then · line 61
Quoted 6 lines
tools/testing/selftests/memfd/run_tests.sh +1
-1@@ -53,7 +57,7 @@ if [ $freepgs -lt $hpages_test ]; then fi printf "Not enough huge pages available (%d < %d)\n" \ $freepgs $needpgs - exit 1 + exit $ksft_skip fi
I thought about changing this to skip and wasn't sure since the test did run partially. Good to know this case can be classified as skip. I will make the suggested changes and send v2.
thanks,
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan
maintainerRe: [PATCH 14/24] selftests: kvm: return Kselftest Skip code for skipped tests
In reply to Paolo BonziniQuoted 6 lines · Paolo Bonzini
Quoted 5 lines · Shuah Khan (Samsung OSG)
When kvm test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Quoted 8 lines
Quoted 6 lines
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use
ksft_exit_skip()when the test is skipped. In addition, refinetest_assert()message to includestrerror()string and add explicit check for root user to clearly identofy non-root user skip case.Root should not be needed.
Will remove the root check and send v2.
Quoted 5 lines
Otherwise
Acked-by Paolo Bonzini <pbonzini at redhat.com>
thanks,
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan
maintainerRe: [PATCH 14/24] selftests: kvm: return Kselftest Skip code for skipped tests
Quoted 10 lines · Shuah Khan
Quoted 9 lines · Paolo Bonzini
Quoted 8 lines · Shuah Khan (Samsung OSG)
When kvm test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Change it to use
ksft_exit_skip()when the test is skipped. In addition, refinetest_assert()message to includestrerror()string and add explicit check for root user to clearly identofy non-root user skip case.Root should not be needed.
Will remove the root check and send v2.
Hmm. I am seeing
selftests: kvm: sync_regs_test
========================================
==== Test Assertion Failure ====
lib/kvm_util.c:54: kvm_fd >= 0
pid=2840 tid=2840 - Permission denied
1 0x0000564cd5206163: ?? ??:0
2 0x0000564cd520531b: ?? ??:0
3 0x00007f7ec018f1c0: ?? ??:0
4 0x0000564cd52058f9: ?? ??:0 open /dev/kvm failed, rc: -1 errno: 13
There are a couple of other tests that fail with EACCES It would make sense report these tests as Skipped perhaps.
thanks,
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan
maintainerRe: [PATCH 21/24] selftests: memfd: return Kselftest Skip code for skipped tests
In reply to Shuah KhanQuoted 28 lines · Shuah Khan
Quoted 27 lines · Mike Kravetz
Quoted 26 lines · Shuah Khan (Samsung OSG)
When memfd test is skipped because of unmet dependencies and/or unsupported configuration, it returns non-zero value which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Added an explicit check for root user and return skip code.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/memfd/run_tests.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)tools/testing/selftests/memfd/run_tests.sh +0
-0@@ -1,6 +1,14 @@ #!/bin/bash # please run as root
Quoted 8 lines
Quoted 8 lines
tools/testing/selftests/memfd/run_tests.sh line 11
Quoted 8 lines
tools/testing/selftests/memfd/run_tests.sh +8
-0+# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +if [ $UID != 0 ]; then + echo "Please run this test as root" + exit $ksft_skip +fi +
Moving root check this far up messes the test up and requires root access for run_fuse_test.sh and memfd_test which is incorrect.
I will re-do the patch
thanks,
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 06/24] selftests: exec: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 30 lines · Shuah Khan (Samsung OSG)
When execveat test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Change it to use
ksft_exit_skip()when kernel doesn't support execveat.Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/exec/execveat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/testing/selftests/exec/execveat.c +2
-0@@ -20,6 +20,8 @@#include <string.h> #include <unistd.h> +#include "../kselftest.h" +static char longpath[2 *PATH_MAX ] ="" ;static char *envp[] = {"IN_TEST=yes" ,NULL ,NULL };static char *argv[] = {"execveat" ,"99" ,NULL };
tools/testing/selftests/exec/execveat.c static int run_tests(void) · line 258
Quoted 10 lines
tools/testing/selftests/exec/execveat.c +2
-2@@ -249,8 +251,8 @@ static int run_tests(void) errno =0 ;execveat_ (-1 ,NULL ,NULL ,NULL ,0 );if (errno ==ENOSYS ) { -printf ("[FAIL] ENOSYS calling execveat - no kernel support?\n" ); -return 1 ; +ksft_exit_skip ( +"ENOSYS calling execveat - no kernel support?\n" ); }/* Change file position to confirm it doesn't affect anything */
LGTM.
thanks,
Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Masami Hiramatsu
maintainerRe: [PATCH 09/24] selftests: ftrace: return Kselftest Skip code for skipped tests
In reply to Steven RostedtQuoted 11 lines · On Mon, 7 May 2018 11:17:21 -0400 Steven Rostedt <rostedt at goodmis.org> wrote:
Quoted 8 lines · On Fri, 4 May 2018 19:13:13 -0600 "Shuah Khan (Samsung OSG)" <shuah at…
When ftrace test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Quoted 6 lines
Quoted 3 lines
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
I'm fine with this change, but I believe Masami and perhaps others have scripts that expect zero return.
Oh, I'm happy with updating my script to follow the kselftest framework spec, since that is the standard.
Shuah, is there any document which describe the return code for kselftest framework? (And I think it should report some FAIL/PASS counts to kselftest
However, this patch seems not working as you expected.
If kselftest framework would like to get the SKIP code from ftrace script, you need to update TOTAL_RESULT before leave.
Quoted 4 lines
If anything, we probably need to have a way to override the
ksft_skipvia a command line argument.Masami?
Agreed. Maybe we can pass the option via an environment variable.
Thanks,
Quoted 42 lines
-- Steve
Quoted 38 lines
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/ftrace/ftracetest | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)tools/testing/selftests/ftrace/ftracetest +6
-2@@ -23,6 +23,9 @@ echo " If <dir> is -, all logs output in console only" exit $1 } +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + errexit() { # message echo "Error: $1" 1>&2 exit 1@@ -30,7 +33,8 @@ errexit() { # message # Ensuring user privilege if [ `id -u` -ne 0 ]; then - errexit "this must be run by root user" + echo "Skipping: test must be run by root user" + exit $ksft_skip fi # Utilities@@ -249,7 +253,7 @@ trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED SIG_UNSUPPORTED=$((SIG_BASE + UNSUPPORTED)) exit_unsupported () { kill -s $SIG_UNSUPPORTED $SIG_PID - exit 0 + exit $ksft_skip } trap 'SIG_RESULT=$UNSUPPORTED' $SIG_UNSUPPORTED
Signature · 5 lines
Masami Hiramatsu <mhiramat at kernel.org> -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Masami Hiramatsu
maintainerRe: [PATCH 09/24] selftests: ftrace: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 41 lines · On Fri, 4 May 2018 19:13:13 -0600 "Shuah Khan (Samsung OSG)" <shuah at…
When ftrace test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/ftrace/ftracetest | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)tools/testing/selftests/ftrace/ftracetest +5
-1@@ -23,6 +23,9 @@ echo " If <dir> is -, all logs output in console only" exit $1 } +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + errexit() { # message echo "Error: $1" 1>&2 exit 1@@ -30,7 +33,8 @@ errexit() { # message # Ensuring user privilege if [ `id -u` -ne 0 ]; then - errexit "this must be run by root user" + echo "Skipping: test must be run by root user" + exit $ksft_skip fi # Utilities
tools/testing/selftests/ftrace/ftracetest trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED · line 256
Quoted 5 lines
tools/testing/selftests/ftrace/ftracetest +1
-1@@ -249,7 +253,7 @@ trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED SIG_UNSUPPORTED=$((SIG_BASE + UNSUPPORTED)) exit_unsupported () { kill -s $SIG_UNSUPPORTED $SIG_PID - exit 0 + exit $ksft_skip
This should return 0. If you want to change the result code, you have to change the last part as below.
(Note that we need a switch option of return code, so that
ftracetest user can continue to use same way...)
tools/testing/selftests/ftrace/ftracetest +12 -2
@@ -326,5 +326,15 @@ prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w` prlog "# of xfailed: " `echo $XFAILED_CASES | wc -w` prlog "# of undefined(test bug): " `echo $UNDEFINED_CASES | wc -w` -# if no error, return 0 -exit $TOTAL_RESULT +# following kselftest result code +if [ $UNSUPPORTED_CASES -ne 0 -o \ + $UNTESTED_CASES -ne 0 -o \ + $UNRESOLVED_CASES -ne 0]; then # There are skipped tests + exit 4 +elif [ $XAILED_CASES -ne 0 -o ]; then # XFAILs + exit 2 +elif [ $FAILED_CASES -ne 0 -o ]; then # FAILs + exit 1 +else # PASS + exit 0 +fi
Thanks,
Signature · 5 lines
Masami Hiramatsu <mhiramat at kernel.org> -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 08/24] selftests: firmware: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 5 lines · Shuah Khan (Samsung OSG)
When firmware test(s) get skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Quoted 7 lines
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>
Luis
Quoted 90 lines
--- tools/testing/selftests/firmware/fw_fallback.sh | 4 ++-- tools/testing/selftests/firmware/fw_filesystem.sh | 4 +++- tools/testing/selftests/firmware/fw_lib.sh | 7 +++++-- 3 files changed, 10 insertions(+), 5 deletions(-)tools/testing/selftests/firmware/fw_fallback.sh +2
-2@@ -74,7 +74,7 @@ load_fw_custom() { if [ ! -e "$DIR"/trigger_custom_fallback ]; then echo "$0: custom fallback trigger not present, ignoring test" >&2 - return 1 + exit $ksft_skip fi local name="$1"@@ -107,7 +107,7 @@ load_fw_custom_cancel() { if [ ! -e "$DIR"/trigger_custom_fallback ]; then echo "$0: canceling custom fallback trigger not present, ignoring test" >&2 - return 1 + exit $ksft_skip fi local name="$1"tools/testing/selftests/firmware/fw_filesystem.sh +3
-1@@ -30,6 +30,7 @@ fi if [ ! -e "$DIR"/trigger_async_request ]; then echo "$0: empty filename: async trigger not present, ignoring test" >&2 + exit $ksft_skip else if printf '\000' >"$DIR"/trigger_async_request 2> /dev/null; then echo "$0: empty filename should not succeed (async)" >&2@@ -69,6 +70,7 @@ fi # Try the asynchronous version too if [ ! -e "$DIR"/trigger_async_request ]; then echo "$0: firmware loading: async trigger not present, ignoring test" >&2 + exit $ksft_skip else if ! echo -n "$NAME" >"$DIR"/trigger_async_request ; then echo "$0: could not trigger async request" >&2@@ -89,7 +91,7 @@ test_config_present() { if [ ! -f $DIR/reset ]; then echo "Configuration triggers not present, ignoring test" - exit 0 + exit $ksft_skip fi }tools/testing/selftests/firmware/fw_lib.sh +5
-2@@ -9,11 +9,14 @@ DIR=/sys/devices/virtual/misc/test_firmware PROC_CONFIG="/proc/config.gz" TEST_DIR=$(dirname $0) +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + print_reqs_exit() { echo "You must have the following enabled in your kernel:" >&2 cat $TEST_DIR/config >&2 - exit 1 + exit $ksft_skip } test_modprobe()@@ -88,7 +91,7 @@ verify_reqs() if [ "$TEST_REQS_FW_SYSFS_FALLBACK" = "yes" ]; then if [ ! "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then echo "usermode helper disabled so ignoring test" - exit 0 + exit $ksft_skip fi fi }Signature · 1 line
2.14.1
Signature · 5 lines
Do not panic -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 13/24] selftests: kmod: return Kselftest Skip code for skipped tests
In reply to Shuah Khan (Samsung OSG)Quoted 6 lines · Shuah Khan (Samsung OSG)
When kmod test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run. It returns fail in some cases when test is skipped. Either way, it is incorrect and incosnistent reporting.
Quoted 7 lines
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>
Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Shuah Khan
maintainerRe: [PATCH 09/24] selftests: ftrace: return Kselftest Skip code for skipped tests
In reply to Masami HiramatsuHi Masami,
Quoted 42 lines · Masami Hiramatsu
Quoted 39 lines · On Fri, 4 May 2018 19:13:13 -0600 "Shuah Khan (Samsung OSG)" <shuah at…
When ftrace test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/ftrace/ftracetest | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)tools/testing/selftests/ftrace/ftracetest +5
-1@@ -23,6 +23,9 @@ echo " If <dir> is -, all logs output in console only" exit $1 } +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + errexit() { # message echo "Error: $1" 1>&2 exit 1@@ -30,7 +33,8 @@ errexit() { # message # Ensuring user privilege if [ `id -u` -ne 0 ]; then - errexit "this must be run by root user" + echo "Skipping: test must be run by root user" + exit $ksft_skip fi
Quoted 12 lines
tools/testing/selftests/ftrace/ftracetest trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED · line 256
Quoted 7 lines
tools/testing/selftests/ftrace/ftracetest +1
-1# Utilities@@ -249,7 +253,7 @@ trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED SIG_UNSUPPORTED=$((SIG_BASE + UNSUPPORTED)) exit_unsupported () { kill -s $SIG_UNSUPPORTED $SIG_PID - exit 0 + exit $ksft_skipThis should return 0. If you want to change the result code, you have to change the last part as below.
(Note that we need a switch option of return code, so that
ftracetest user can continue to use same way...)
Doesn't this existing option take care of this:
--fail-unsupported Treat UNSUPPORTED as a failure"
Is there a need for another. This indicates that the default mode is UNSUPPORTED isn't a failure.
Quoted 14 lines
tools/testing/selftests/ftrace/ftracetest +2
-2@@ -326,5 +326,15 @@ prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w` prlog "# of xfailed: " `echo $XFAILED_CASES | wc -w` prlog "# of undefined(test bug): " `echo $UNDEFINED_CASES | wc -w` -# if no error, return 0 -exit $TOTAL_RESULT +# following kselftest result code +if [ $UNSUPPORTED_CASES -ne 0 -o \
tools/testing/selftests/ftrace/ftracetest prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w` · line 340
Quoted 10 lines
tools/testing/selftests/ftrace/ftracetest +10
-0+ $UNTESTED_CASES -ne 0 -o \ + $UNRESOLVED_CASES -ne 0]; then # There are skipped tests + exit 4 +elif [ $XAILED_CASES -ne 0 -o ]; then # XFAILs + exit 2 +elif [ $FAILED_CASES -ne 0 -o ]; then # FAILs + exit 1 +else # PASS + exit 0 +fi
Thanks for pointing out the right change to make.
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Masami Hiramatsu
maintainerRe: [PATCH 09/24] selftests: ftrace: return Kselftest Skip code for skipped tests
Quoted 58 lines · On Thu, 10 May 2018 14:18:16 -0600 Shuah Khan <shuah at kernel.org> wrote:
Hi Masami,
Quoted 42 lines · Masami Hiramatsu
Quoted 39 lines · On Fri, 4 May 2018 19:13:13 -0600 "Shuah Khan (Samsung OSG)" <shuah at…
When ftrace test is skipped because of unmet dependencies and/or unsupported configuration, it returns 0 which is treated as a pass by the Kselftest framework. This leads to false positive result even when the test could not be run.
Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run.
Kselftest framework SKIP code is 4 and the framework prints appropriate messages to indicate that the test is skipped.
Signed-off-by Shuah Khan (Samsung OSG) <shuah at kernel.org>--- tools/testing/selftests/ftrace/ftracetest | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)tools/testing/selftests/ftrace/ftracetest +5
-1@@ -23,6 +23,9 @@ echo " If <dir> is -, all logs output in console only" exit $1 } +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + errexit() { # message echo "Error: $1" 1>&2 exit 1@@ -30,7 +33,8 @@ errexit() { # message # Ensuring user privilege if [ `id -u` -ne 0 ]; then - errexit "this must be run by root user" + echo "Skipping: test must be run by root user" + exit $ksft_skip fiQuoted 12 lines
tools/testing/selftests/ftrace/ftracetest trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED · line 256
Quoted 7 lines
tools/testing/selftests/ftrace/ftracetest +1
-1# Utilities@@ -249,7 +253,7 @@ trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED SIG_UNSUPPORTED=$((SIG_BASE + UNSUPPORTED)) exit_unsupported () { kill -s $SIG_UNSUPPORTED $SIG_PID - exit 0 + exit $ksft_skipThis should return 0. If you want to change the result code, you have to change the last part as below.
(Note that we need a switch option of return code, so that
ftracetest user can continue to use same way...)
Quoted 3 lines
Doesn't this existing option take care of this:
--fail-unsupported Treat UNSUPPORTED as a failure"
No, that is an opposite option... it makes UNSUPPORTED result as a failure. What the option we need is to ignore UNSUPPORTED results because it is expected.
Quoted 2 lines
Is there a need for another. This indicates that the default mode is UNSUPPORTED isn't a failure.
Right, currently UNSUPPORTED/UNRESOLVED/UNTESTED are not failure.
Quoted 10 lines
Quoted 10 lines
tools/testing/selftests/ftrace/ftracetest +0
-0@@ -326,5 +326,15 @@ prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w` prlog "# of xfailed: " `echo $XFAILED_CASES | wc -w` prlog "# of undefined(test bug): " `echo $UNDEFINED_CASES | wc -w`
Quoted 8 lines
tools/testing/selftests/ftrace/ftracetest prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w` · line 334
Quoted 8 lines
tools/testing/selftests/ftrace/ftracetest +6
-2-# if no error, return 0 -exit $TOTAL_RESULT +# following kselftest result code +if [ $UNSUPPORTED_CASES -ne 0 -o \ + $UNTESTED_CASES -ne 0 -o \ + $UNRESOLVED_CASES -ne 0]; then # There are skipped tests + exit 4 +elif [ $XAILED_CASES -ne 0 -o ]; then # XFAILs
Ah, I missed to remove the last "-o"
Quoted 2 lines
tools/testing/selftests/ftrace/ftracetest prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w` · line 336
Quoted 2 lines
tools/testing/selftests/ftrace/ftracetest +2
-0+ exit 2 +elif [ $FAILED_CASES -ne 0 -o ]; then # FAILs
ditto.
Thanks,
Quoted 10 lines
tools/testing/selftests/ftrace/ftracetest prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w` · line 340
Quoted 5 lines
tools/testing/selftests/ftrace/ftracetest +4
-0+ exit 1 +else # PASS + exit 0 +fiThanks for pointing out the right change to make.
-- Shuah
Signature · 5 lines
Masami Hiramatsu <mhiramat at kernel.org> -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html