Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux-kselftest-fixes-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull more kselftest fixes from Shuah Khan
"Fixes to user_events test and ftrace test.

The user_events test was enabled by default in Linux 6.6-rc1. The
following fixes are for bugs found since then:

- add checks for dependencies and skip the test if they aren't met.

The user_events test requires root access, and tracefs and
user_events enabled. It leaves tracefs mounted and a fix is in
progress for that missing piece.

- create user_events test-specific Kconfig fragments

ftrace test fixes:

- unmount tracefs for recovering environment. Fix identified during
the above mentioned user_events dependencies fix.

- adds softlink to latest log directory improving usage"

* tag 'linux-kselftest-fixes-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests: tracing: Fix to unmount tracefs for recovering environment
selftests: user_events: create test-specific Kconfig fragments
ftrace/selftests: Add softlink to latest log directory
selftests/user_events: Fix failures when user_events is not installed

+129 -1
+17 -1
tools/testing/selftests/ftrace/ftracetest
··· 31 31 # kselftest skip code is 4 32 32 err_skip=4 33 33 34 + # umount required 35 + UMOUNT_DIR="" 36 + 34 37 # cgroup RT scheduling prevents chrt commands from succeeding, which 35 38 # induces failures in test wakeup tests. Disable for the duration of 36 39 # the tests. ··· 48 45 49 46 cleanup() { 50 47 echo $sched_rt_runtime_orig > $sched_rt_runtime 48 + if [ -n "${UMOUNT_DIR}" ]; then 49 + umount ${UMOUNT_DIR} ||: 50 + fi 51 51 } 52 52 53 53 errexit() { # message ··· 130 124 ;; 131 125 --logdir|-l) 132 126 LOG_DIR=$2 127 + LINK_PTR= 133 128 shift 2 134 129 ;; 135 130 *.tc) ··· 167 160 mount -t tracefs nodev /sys/kernel/tracing || 168 161 errexit "Failed to mount /sys/kernel/tracing" 169 162 TRACING_DIR="/sys/kernel/tracing" 163 + UMOUNT_DIR=${TRACING_DIR} 170 164 # If debugfs exists, then so does /sys/kernel/debug 171 165 elif [ -d "/sys/kernel/debug" ]; then 172 166 mount -t debugfs nodev /sys/kernel/debug || 173 167 errexit "Failed to mount /sys/kernel/debug" 174 168 TRACING_DIR="/sys/kernel/debug/tracing" 169 + UMOUNT_DIR=${TRACING_DIR} 175 170 else 176 171 err_ret=$err_skip 177 172 errexit "debugfs and tracefs are not configured in this kernel" ··· 190 181 TOP_DIR=`absdir $0` 191 182 TEST_DIR=$TOP_DIR/test.d 192 183 TEST_CASES=`find_testcases $TEST_DIR` 193 - LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ 184 + LOG_TOP_DIR=$TOP_DIR/logs 185 + LOG_DATE=`date +%Y%m%d-%H%M%S` 186 + LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/ 187 + LINK_PTR=$LOG_TOP_DIR/latest 194 188 KEEP_LOG=0 195 189 KTAP=0 196 190 DEBUG=0 ··· 219 207 LOG_FILE=$LOG_DIR/ftracetest.log 220 208 mkdir -p $LOG_DIR || errexit "Failed to make a log directory: $LOG_DIR" 221 209 date > $LOG_FILE 210 + if [ "x-$LINK_PTR" != "x-" ]; then 211 + unlink $LINK_PTR 212 + ln -fs $LOG_DATE $LINK_PTR 213 + fi 222 214 fi 223 215 224 216 # Define text colors
+3
tools/testing/selftests/user_events/abi_test.c
··· 19 19 #include <asm/unistd.h> 20 20 21 21 #include "../kselftest_harness.h" 22 + #include "user_events_selftests.h" 22 23 23 24 const char *data_file = "/sys/kernel/tracing/user_events_data"; 24 25 const char *enable_file = "/sys/kernel/tracing/events/user_events/__abi_event/enable"; ··· 94 93 }; 95 94 96 95 FIXTURE_SETUP(user) { 96 + USER_EVENT_FIXTURE_SETUP(return); 97 + 97 98 change_event(false); 98 99 self->check = 0; 99 100 }
+1
tools/testing/selftests/user_events/config
··· 1 + CONFIG_USER_EVENTS=y
+2
tools/testing/selftests/user_events/dyn_test.c
··· 15 15 #include <unistd.h> 16 16 17 17 #include "../kselftest_harness.h" 18 + #include "user_events_selftests.h" 18 19 19 20 const char *abi_file = "/sys/kernel/tracing/user_events_data"; 20 21 const char *enable_file = "/sys/kernel/tracing/events/user_events/__test_event/enable"; ··· 147 146 }; 148 147 149 148 FIXTURE_SETUP(user) { 149 + USER_EVENT_FIXTURE_SETUP(return); 150 150 } 151 151 152 152 FIXTURE_TEARDOWN(user) {
+3
tools/testing/selftests/user_events/ftrace_test.c
··· 16 16 #include <unistd.h> 17 17 18 18 #include "../kselftest_harness.h" 19 + #include "user_events_selftests.h" 19 20 20 21 const char *data_file = "/sys/kernel/tracing/user_events_data"; 21 22 const char *status_file = "/sys/kernel/tracing/user_events_status"; ··· 207 206 }; 208 207 209 208 FIXTURE_SETUP(user) { 209 + USER_EVENT_FIXTURE_SETUP(return); 210 + 210 211 self->status_fd = open(status_file, O_RDONLY); 211 212 ASSERT_NE(-1, self->status_fd); 212 213
+3
tools/testing/selftests/user_events/perf_test.c
··· 17 17 #include <asm/unistd.h> 18 18 19 19 #include "../kselftest_harness.h" 20 + #include "user_events_selftests.h" 20 21 21 22 const char *data_file = "/sys/kernel/tracing/user_events_data"; 22 23 const char *id_file = "/sys/kernel/tracing/events/user_events/__test_event/id"; ··· 114 113 }; 115 114 116 115 FIXTURE_SETUP(user) { 116 + USER_EVENT_FIXTURE_SETUP(return); 117 + 117 118 self->data_fd = open(data_file, O_RDWR); 118 119 ASSERT_NE(-1, self->data_fd); 119 120 }
+100
tools/testing/selftests/user_events/user_events_selftests.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef _USER_EVENTS_SELFTESTS_H 4 + #define _USER_EVENTS_SELFTESTS_H 5 + 6 + #include <sys/stat.h> 7 + #include <sys/types.h> 8 + #include <sys/mount.h> 9 + #include <unistd.h> 10 + #include <errno.h> 11 + 12 + #include "../kselftest.h" 13 + 14 + static inline bool tracefs_enabled(char **message, bool *fail) 15 + { 16 + struct stat buf; 17 + int ret; 18 + 19 + *message = ""; 20 + *fail = false; 21 + 22 + /* Ensure tracefs is installed */ 23 + ret = stat("/sys/kernel/tracing", &buf); 24 + 25 + if (ret == -1) { 26 + *message = "Tracefs is not installed"; 27 + return false; 28 + } 29 + 30 + /* Ensure mounted tracefs */ 31 + ret = stat("/sys/kernel/tracing/README", &buf); 32 + 33 + if (ret == -1 && errno == ENOENT) { 34 + if (mount(NULL, "/sys/kernel/tracing", "tracefs", 0, NULL) != 0) { 35 + *message = "Cannot mount tracefs"; 36 + *fail = true; 37 + return false; 38 + } 39 + 40 + ret = stat("/sys/kernel/tracing/README", &buf); 41 + } 42 + 43 + if (ret == -1) { 44 + *message = "Cannot access tracefs"; 45 + *fail = true; 46 + return false; 47 + } 48 + 49 + return true; 50 + } 51 + 52 + static inline bool user_events_enabled(char **message, bool *fail) 53 + { 54 + struct stat buf; 55 + int ret; 56 + 57 + *message = ""; 58 + *fail = false; 59 + 60 + if (getuid() != 0) { 61 + *message = "Must be run as root"; 62 + *fail = true; 63 + return false; 64 + } 65 + 66 + if (!tracefs_enabled(message, fail)) 67 + return false; 68 + 69 + /* Ensure user_events is installed */ 70 + ret = stat("/sys/kernel/tracing/user_events_data", &buf); 71 + 72 + if (ret == -1) { 73 + switch (errno) { 74 + case ENOENT: 75 + *message = "user_events is not installed"; 76 + return false; 77 + 78 + default: 79 + *message = "Cannot access user_events_data"; 80 + *fail = true; 81 + return false; 82 + } 83 + } 84 + 85 + return true; 86 + } 87 + 88 + #define USER_EVENT_FIXTURE_SETUP(statement) do { \ 89 + char *message; \ 90 + bool fail; \ 91 + if (!user_events_enabled(&message, &fail)) { \ 92 + if (fail) { \ 93 + TH_LOG("Setup failed due to: %s", message); \ 94 + ASSERT_FALSE(fail); \ 95 + } \ 96 + SKIP(statement, "Skipping due to: %s", message); \ 97 + } \ 98 + } while (0) 99 + 100 + #endif /* _USER_EVENTS_SELFTESTS_H */