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-next-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest updates from Shuah Khan:

- Fixes:
- false failure of subsystem event test
- glob filter test to use mutex_unlock() instead of mutex_trylock()
- several spelling errors in tests
- test_kexec_jump build errors
- pidfd test duplicate-symbol warnings for SCHED_ CPP symbols

- Add a reliable check for suspend to breakpoints suspend test

- Improvements to ipc test

* tag 'linux_kselftest-next-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols
selftests/tracing: Fix false failure of subsystem event test
selftests/kexec: fix test_kexec_jump build
selftests: breakpoints: use suspend_stats to reliably check suspend success
selftests: tracing: Use mutex_unlock for testing glob filter
selftests: print installation complete message
selftests/ptrace: Fix spelling mistake "multible" -> "multiple"
selftests: ipc: Replace fail print statements with ksft_test_result_fail
selftests: Add version file to kselftest installation dir
selftests/cpu-hotplug: fix typo in hotplaggable_offline_cpus function name

+102 -41
+8
tools/testing/selftests/Makefile
··· 293 293 $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ 294 294 -C $$TARGET emit_tests >> $(TEST_LIST); \ 295 295 done; 296 + @VERSION=$$(git describe HEAD 2>/dev/null); \ 297 + if [ -n "$$VERSION" ]; then \ 298 + echo "$$VERSION" > $(INSTALL_PATH)/VERSION; \ 299 + printf "Version saved to $(INSTALL_PATH)/VERSION\n"; \ 300 + else \ 301 + printf "Unable to get version from git describe\n"; \ 302 + fi 303 + @echo "**Kselftest Installation is complete: $(INSTALL_PATH)**" 296 304 else 297 305 $(error Error: set INSTALL_PATH to use install) 298 306 endif
+31 -10
tools/testing/selftests/breakpoints/step_after_suspend_test.c
··· 127 127 return KSFT_PASS; 128 128 } 129 129 130 + /* 131 + * Reads the suspend success count from sysfs. 132 + * Returns the count on success or exits on failure. 133 + */ 134 + static int get_suspend_success_count_or_fail(void) 135 + { 136 + FILE *fp; 137 + int val; 138 + 139 + fp = fopen("/sys/power/suspend_stats/success", "r"); 140 + if (!fp) 141 + ksft_exit_fail_msg( 142 + "Failed to open suspend_stats/success: %s\n", 143 + strerror(errno)); 144 + 145 + if (fscanf(fp, "%d", &val) != 1) { 146 + fclose(fp); 147 + ksft_exit_fail_msg( 148 + "Failed to read suspend success count\n"); 149 + } 150 + 151 + fclose(fp); 152 + return val; 153 + } 154 + 130 155 void suspend(void) 131 156 { 132 - int power_state_fd; 133 157 int timerfd; 134 158 int err; 159 + int count_before; 160 + int count_after; 135 161 struct itimerspec spec = {}; 136 162 137 163 if (getuid() != 0) 138 164 ksft_exit_skip("Please run the test as root - Exiting.\n"); 139 - 140 - power_state_fd = open("/sys/power/state", O_RDWR); 141 - if (power_state_fd < 0) 142 - ksft_exit_fail_msg( 143 - "open(\"/sys/power/state\") failed %s)\n", 144 - strerror(errno)); 145 165 146 166 timerfd = timerfd_create(CLOCK_BOOTTIME_ALARM, 0); 147 167 if (timerfd < 0) ··· 172 152 if (err < 0) 173 153 ksft_exit_fail_msg("timerfd_settime() failed\n"); 174 154 155 + count_before = get_suspend_success_count_or_fail(); 156 + 175 157 system("(echo mem > /sys/power/state) 2> /dev/null"); 176 158 177 - timerfd_gettime(timerfd, &spec); 178 - if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0) 159 + count_after = get_suspend_success_count_or_fail(); 160 + if (count_after <= count_before) 179 161 ksft_exit_fail_msg("Failed to enter Suspend state\n"); 180 162 181 163 close(timerfd); 182 - close(power_state_fd); 183 164 } 184 165 185 166 int main(int argc, char **argv)
+2 -2
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
··· 67 67 done 68 68 } 69 69 70 - hotplaggable_offline_cpus() 70 + hotpluggable_offline_cpus() 71 71 { 72 72 hotpluggable_cpus 0 73 73 } ··· 151 151 152 152 online_all_hot_pluggable_cpus() 153 153 { 154 - for cpu in `hotplaggable_offline_cpus`; do 154 + for cpu in `hotpluggable_offline_cpus`; do 155 155 online_cpu_expect_success $cpu 156 156 done 157 157 }
+26 -2
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
··· 14 14 exit_fail 15 15 } 16 16 17 + # As reading trace can last forever, simply look for 3 different 18 + # events then exit out of reading the file. If there's not 3 different 19 + # events, then the test has failed. 20 + check_unique() { 21 + cat trace | grep -v '^#' | awk ' 22 + BEGIN { cnt = 0; } 23 + { 24 + for (i = 0; i < cnt; i++) { 25 + if (event[i] == $5) { 26 + break; 27 + } 28 + } 29 + if (i == cnt) { 30 + event[cnt++] = $5; 31 + if (cnt > 2) { 32 + exit; 33 + } 34 + } 35 + } 36 + END { 37 + printf "%d", cnt; 38 + }' 39 + } 40 + 17 41 echo 'sched:*' > set_event 18 42 19 43 yield 20 44 21 - count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` 45 + count=`check_unique` 22 46 if [ $count -lt 3 ]; then 23 47 fail "at least fork, exec and exit events should be recorded" 24 48 fi ··· 53 29 54 30 yield 55 31 56 - count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` 32 + count=`check_unique` 57 33 if [ $count -lt 3 ]; then 58 34 fail "at least fork, exec and exit events should be recorded" 59 35 fi
+1 -1
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
··· 29 29 ftrace_filter_check '*pin*lock' '.*pin.*lock$' 30 30 31 31 # filter by start*mid* 32 - ftrace_filter_check 'mutex*try*' '^mutex.*try.*' 32 + ftrace_filter_check 'mutex*unl*' '^mutex.*unl.*' 33 33 34 34 # Advanced full-glob matching feature is recently supported. 35 35 # Skip the tests if we are sure the kernel does not support it.
+23 -24
tools/testing/selftests/ipc/msgque.c
··· 39 39 40 40 fd = open("/proc/sys/kernel/msg_next_id", O_WRONLY); 41 41 if (fd == -1) { 42 - printf("Failed to open /proc/sys/kernel/msg_next_id\n"); 42 + ksft_test_result_fail("Failed to open /proc/sys/kernel/msg_next_id\n"); 43 43 return -errno; 44 44 } 45 45 sprintf(buf, "%d", msgque->msq_id); 46 46 47 47 ret = write(fd, buf, strlen(buf)); 48 48 if (ret != strlen(buf)) { 49 - printf("Failed to write to /proc/sys/kernel/msg_next_id\n"); 49 + ksft_test_result_fail("Failed to write to /proc/sys/kernel/msg_next_id\n"); 50 50 return -errno; 51 51 } 52 52 53 53 id = msgget(msgque->key, msgque->mode | IPC_CREAT | IPC_EXCL); 54 54 if (id == -1) { 55 - printf("Failed to create queue\n"); 55 + ksft_test_result_fail("Failed to create queue\n"); 56 56 return -errno; 57 57 } 58 58 59 59 if (id != msgque->msq_id) { 60 - printf("Restored queue has wrong id (%d instead of %d)\n", 61 - id, msgque->msq_id); 60 + ksft_test_result_fail("Restored queue has wrong id (%d instead of %d)\n" 61 + , id, msgque->msq_id); 62 62 ret = -EFAULT; 63 63 goto destroy; 64 64 } ··· 66 66 for (i = 0; i < msgque->qnum; i++) { 67 67 if (msgsnd(msgque->msq_id, &msgque->messages[i].mtype, 68 68 msgque->messages[i].msize, IPC_NOWAIT) != 0) { 69 - printf("msgsnd failed (%m)\n"); 69 + ksft_test_result_fail("msgsnd failed (%m)\n"); 70 70 ret = -errno; 71 71 goto destroy; 72 72 } ··· 90 90 if (ret < 0) { 91 91 if (errno == ENOMSG) 92 92 break; 93 - printf("Failed to read IPC message: %m\n"); 93 + ksft_test_result_fail("Failed to read IPC message: %m\n"); 94 94 ret = -errno; 95 95 goto err; 96 96 } 97 97 if (ret != msgque->messages[cnt].msize) { 98 - printf("Wrong message size: %d (expected %d)\n", ret, 99 - msgque->messages[cnt].msize); 98 + ksft_test_result_fail("Wrong message size: %d (expected %d)\n", ret, msgque->messages[cnt].msize); 100 99 ret = -EINVAL; 101 100 goto err; 102 101 } 103 102 if (message.mtype != msgque->messages[cnt].mtype) { 104 - printf("Wrong message type\n"); 103 + ksft_test_result_fail("Wrong message type\n"); 105 104 ret = -EINVAL; 106 105 goto err; 107 106 } 108 107 if (memcmp(message.mtext, msgque->messages[cnt].mtext, ret)) { 109 - printf("Wrong message content\n"); 108 + ksft_test_result_fail("Wrong message content\n"); 110 109 ret = -EINVAL; 111 110 goto err; 112 111 } ··· 113 114 } 114 115 115 116 if (cnt != msgque->qnum) { 116 - printf("Wrong message number\n"); 117 + ksft_test_result_fail("Wrong message number\n"); 117 118 ret = -EINVAL; 118 119 goto err; 119 120 } ··· 138 139 if (ret < 0) { 139 140 if (errno == EINVAL) 140 141 continue; 141 - printf("Failed to get stats for IPC queue with id %d\n", 142 + ksft_test_result_fail("Failed to get stats for IPC queue with id %d\n", 142 143 kern_id); 143 144 return -errno; 144 145 } ··· 149 150 150 151 msgque->messages = malloc(sizeof(struct msg1) * ds.msg_qnum); 151 152 if (msgque->messages == NULL) { 152 - printf("Failed to get stats for IPC queue\n"); 153 + ksft_test_result_fail("Failed to get stats for IPC queue\n"); 153 154 return -ENOMEM; 154 155 } 155 156 ··· 161 162 ret = msgrcv(msgque->msq_id, &msgque->messages[i].mtype, 162 163 MAX_MSG_SIZE, i, IPC_NOWAIT | MSG_COPY); 163 164 if (ret < 0) { 164 - printf("Failed to copy IPC message: %m (%d)\n", errno); 165 + ksft_test_result_fail("Failed to copy IPC message: %m (%d)\n", errno); 165 166 return -errno; 166 167 } 167 168 msgque->messages[i].msize = ret; ··· 177 178 memcpy(msgbuf.mtext, TEST_STRING, sizeof(TEST_STRING)); 178 179 if (msgsnd(msgque->msq_id, &msgbuf.mtype, sizeof(TEST_STRING), 179 180 IPC_NOWAIT) != 0) { 180 - printf("First message send failed (%m)\n"); 181 + ksft_test_result_fail("First message send failed (%m)\n"); 181 182 return -errno; 182 183 } 183 184 ··· 185 186 memcpy(msgbuf.mtext, ANOTHER_TEST_STRING, sizeof(ANOTHER_TEST_STRING)); 186 187 if (msgsnd(msgque->msq_id, &msgbuf.mtype, sizeof(ANOTHER_TEST_STRING), 187 188 IPC_NOWAIT) != 0) { 188 - printf("Second message send failed (%m)\n"); 189 + ksft_test_result_fail("Second message send failed (%m)\n"); 189 190 return -errno; 190 191 } 191 192 return 0; ··· 201 202 202 203 msgque.key = ftok(argv[0], 822155650); 203 204 if (msgque.key == -1) { 204 - printf("Can't make key: %d\n", -errno); 205 + ksft_test_result_fail("Can't make key: %d\n", -errno); 205 206 ksft_exit_fail(); 206 207 } 207 208 208 209 msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666); 209 210 if (msgque.msq_id == -1) { 210 211 err = -errno; 211 - printf("Can't create queue: %d\n", err); 212 + ksft_test_result_fail("Can't create queue: %d\n", err); 212 213 goto err_out; 213 214 } 214 215 215 216 err = fill_msgque(&msgque); 216 217 if (err) { 217 - printf("Failed to fill queue: %d\n", err); 218 + ksft_test_result_fail("Failed to fill queue: %d\n", err); 218 219 goto err_destroy; 219 220 } 220 221 221 222 err = dump_queue(&msgque); 222 223 if (err) { 223 - printf("Failed to dump queue: %d\n", err); 224 + ksft_test_result_fail("Failed to dump queue: %d\n", err); 224 225 goto err_destroy; 225 226 } 226 227 227 228 err = check_and_destroy_queue(&msgque); 228 229 if (err) { 229 - printf("Failed to check and destroy queue: %d\n", err); 230 + ksft_test_result_fail("Failed to check and destroy queue: %d\n", err); 230 231 goto err_out; 231 232 } 232 233 233 234 err = restore_queue(&msgque); 234 235 if (err) { 235 - printf("Failed to restore queue: %d\n", err); 236 + ksft_test_result_fail("Failed to restore queue: %d\n", err); 236 237 goto err_destroy; 237 238 } 238 239 239 240 err = check_and_destroy_queue(&msgque); 240 241 if (err) { 241 - printf("Failed to test queue: %d\n", err); 242 + ksft_test_result_fail("Failed to test queue: %d\n", err); 242 243 goto err_out; 243 244 } 244 245 ksft_exit_pass();
+1 -1
tools/testing/selftests/kexec/Makefile
··· 12 12 13 13 ifeq ($(IS_64_BIT)$(ARCH_PROCESSED),1x86) 14 14 TEST_PROGS += test_kexec_jump.sh 15 - test_kexec_jump.sh: $(OUTPUT)/test_kexec_jump 15 + TEST_GEN_PROGS := test_kexec_jump 16 16 endif 17 17 18 18 include ../lib.mk
+9
tools/testing/selftests/pidfd/pidfd.h
··· 16 16 #include <sys/types.h> 17 17 #include <sys/wait.h> 18 18 19 + /* 20 + * Remove the userspace definitions of the following preprocessor symbols 21 + * to avoid duplicate-definition warnings from the subsequent in-kernel 22 + * definitions. 23 + */ 24 + #undef SCHED_NORMAL 25 + #undef SCHED_FLAG_KEEP_ALL 26 + #undef SCHED_FLAG_UTIL_CLAMP 27 + 19 28 #include "../kselftest.h" 20 29 #include "../clone3/clone3_selftests.h" 21 30
+1 -1
tools/testing/selftests/ptrace/peeksiginfo.c
··· 199 199 200 200 /* 201 201 * Dump signal from the process-wide queue. 202 - * The number of signals is not multible to the buffer size 202 + * The number of signals is not multiple to the buffer size 203 203 */ 204 204 if (check_direct_path(child, 1, 3)) 205 205 goto out;