lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  2 Jul 2019 14:23:58 +0800
From:   Po-Hsu Lin <po-hsu.lin@...onical.com>
To:     rostedt@...dmis.org, mingo@...hat.com, shuah@...nel.org,
        linux-kselftest@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH] selftests/ftrace: skip ftrace test if FTRACE was not enabled

The ftrace test will need to have CONFIG_FTRACE enabled to make the
ftrace directory available.

Add an additional check to skip this test if the CONFIG_FTRACE was not
enabled.

This will be helpful to avoid a false-positive test result when testing
it directly with the following commad against a kernel that does not
have CONFIG_FTRACE enabled:
    make -C tools/testing/selftests TARGETS=ftrace run_tests

The test result on an Ubuntu KVM kernel will be changed from:
    selftests: ftrace: ftracetest
    ========================================
    Error: No ftrace directory found
    not ok 1..1 selftests: ftrace: ftracetest [FAIL]
To:
    selftests: ftrace: ftracetest
    ========================================
    CONFIG_FTRACE was not enabled, test skipped.
    not ok 1..1 selftests: ftrace: ftracetest [SKIP]

Signed-off-by: Po-Hsu Lin <po-hsu.lin@...onical.com>
---
 tools/testing/selftests/ftrace/ftracetest | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 6d5e9e8..6c8322e 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -7,6 +7,9 @@
 #  Written by Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
 #
 
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
 usage() { # errno [message]
 [ ! -z "$2" ] && echo $2
 echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
@@ -139,7 +142,13 @@ parse_opts $*
 
 # Verify parameters
 if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then
-  errexit "No ftrace directory found"
+  ftrace_enabled=`grep "^CONFIG_FTRACE=y" /lib/modules/$(uname -r)/build/.config`
+  if [ -z "$ftrace_enabled" ]; then
+    echo "CONFIG_FTRACE was not enabled, test skipped."
+    exit $ksft_skip
+  else
+    errexit "No ftrace directory found"
+  fi
 fi
 
 # Preparing logs
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ