diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-17 22:37:08 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-17 22:37:08 -0400 |
| commit | 3d15cfdb1b77536c205d8e49c0312219ddf162ec (patch) | |
| tree | 8615e83fc3765920be21e5bc2e157862b42d8d29 | |
| parent | 5cd0911a9e0e408f28079a5e36a981217bf47520 (diff) | |
| parent | 6accd8e9bf22749f621fb7fb57995fa65f4cd873 (diff) | |
Merge tag 'linux-kselftest-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull Kselftest updates from Shuah Khan:
"This update for Kselftest adds:
- A new feature to create test-specific kconfig fragments. This
feature helps configure Kselftests to test specific Kernel
Configuration options as opposed to defconfig.
- A new test for Media Controller API
- A few fixes"
* tag 'linux-kselftest-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests: media_dcevice_test fix usage information
selftests: media_dcevice_test fix to handle ioctl failure case
selftests: add missing .gitignore file or entry
Makefile: add kselftest-merge
selftests: create test-specific kconfig fragments
selftests: breakpoint: add step_after_suspend_test
selftests: add a new test for Media Controller API
21 files changed, 362 insertions, 1 deletions
| @@ -1087,6 +1087,14 @@ kselftest: | |||
| 1087 | kselftest-clean: | 1087 | kselftest-clean: |
| 1088 | $(Q)$(MAKE) -C tools/testing/selftests clean | 1088 | $(Q)$(MAKE) -C tools/testing/selftests clean |
| 1089 | 1089 | ||
| 1090 | PHONY += kselftest-merge | ||
| 1091 | kselftest-merge: | ||
| 1092 | $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!)) | ||
| 1093 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ | ||
| 1094 | -m $(objtree)/.config \ | ||
| 1095 | $(srctree)/tools/testing/selftests/*/config | ||
| 1096 | +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig | ||
| 1097 | |||
| 1090 | # --------------------------------------------------------------------------- | 1098 | # --------------------------------------------------------------------------- |
| 1091 | # Modules | 1099 | # Modules |
| 1092 | 1100 | ||
| @@ -1295,6 +1303,8 @@ help: | |||
| 1295 | @echo ' Build, install, and boot kernel before' | 1303 | @echo ' Build, install, and boot kernel before' |
| 1296 | @echo ' running kselftest on it' | 1304 | @echo ' running kselftest on it' |
| 1297 | @echo ' kselftest-clean - Remove all generated kselftest files' | 1305 | @echo ' kselftest-clean - Remove all generated kselftest files' |
| 1306 | @echo ' kselftest-merge - Merge all the config dependencies of kselftest to existed' | ||
| 1307 | @echo ' .config.' | ||
| 1298 | @echo '' | 1308 | @echo '' |
| 1299 | @echo 'Kernel packaging:' | 1309 | @echo 'Kernel packaging:' |
| 1300 | @$(MAKE) $(build)=$(package-dir) help | 1310 | @$(MAKE) $(build)=$(package-dir) help |
diff --git a/tools/testing/selftests/breakpoints/.gitignore b/tools/testing/selftests/breakpoints/.gitignore index 9b3193d06608..a23bb4a6f06c 100644 --- a/tools/testing/selftests/breakpoints/.gitignore +++ b/tools/testing/selftests/breakpoints/.gitignore | |||
| @@ -1 +1,2 @@ | |||
| 1 | breakpoint_test | 1 | breakpoint_test |
| 2 | step_after_suspend_test | ||
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile index c0d957015f52..74e533fd4bc5 100644 --- a/tools/testing/selftests/breakpoints/Makefile +++ b/tools/testing/selftests/breakpoints/Makefile | |||
| @@ -6,9 +6,11 @@ ifeq ($(ARCH),x86) | |||
| 6 | TEST_PROGS := breakpoint_test | 6 | TEST_PROGS := breakpoint_test |
| 7 | endif | 7 | endif |
| 8 | 8 | ||
| 9 | TEST_PROGS += step_after_suspend_test | ||
| 10 | |||
| 9 | all: $(TEST_PROGS) | 11 | all: $(TEST_PROGS) |
| 10 | 12 | ||
| 11 | include ../lib.mk | 13 | include ../lib.mk |
| 12 | 14 | ||
| 13 | clean: | 15 | clean: |
| 14 | rm -fr breakpoint_test | 16 | rm -fr breakpoint_test step_after_suspend_test |
diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c b/tools/testing/selftests/breakpoints/step_after_suspend_test.c new file mode 100644 index 000000000000..60b8a95dac26 --- /dev/null +++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c | |||
| @@ -0,0 +1,218 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2016 Google, Inc. | ||
| 3 | * | ||
| 4 | * This software is licensed under the terms of the GNU General Public | ||
| 5 | * License version 2, as published by the Free Software Foundation, and | ||
| 6 | * may be copied, distributed, and modified under those terms. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | */ | ||
| 14 | |||
| 15 | #define _GNU_SOURCE | ||
| 16 | |||
| 17 | #include <errno.h> | ||
| 18 | #include <fcntl.h> | ||
| 19 | #include <sched.h> | ||
| 20 | #include <signal.h> | ||
| 21 | #include <stdbool.h> | ||
| 22 | #include <stdio.h> | ||
| 23 | #include <string.h> | ||
| 24 | #include <unistd.h> | ||
| 25 | #include <sys/ptrace.h> | ||
| 26 | #include <sys/stat.h> | ||
| 27 | #include <sys/timerfd.h> | ||
| 28 | #include <sys/types.h> | ||
| 29 | #include <sys/wait.h> | ||
| 30 | |||
| 31 | #include "../kselftest.h" | ||
| 32 | |||
| 33 | void child(int cpu) | ||
| 34 | { | ||
| 35 | cpu_set_t set; | ||
| 36 | |||
| 37 | CPU_ZERO(&set); | ||
| 38 | CPU_SET(cpu, &set); | ||
| 39 | if (sched_setaffinity(0, sizeof(set), &set) != 0) { | ||
| 40 | perror("sched_setaffinity() failed"); | ||
| 41 | _exit(1); | ||
| 42 | } | ||
| 43 | |||
| 44 | if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) { | ||
| 45 | perror("ptrace(PTRACE_TRACEME) failed"); | ||
| 46 | _exit(1); | ||
| 47 | } | ||
| 48 | |||
| 49 | if (raise(SIGSTOP) != 0) { | ||
| 50 | perror("raise(SIGSTOP) failed"); | ||
| 51 | _exit(1); | ||
| 52 | } | ||
| 53 | |||
| 54 | _exit(0); | ||
| 55 | } | ||
| 56 | |||
| 57 | bool run_test(int cpu) | ||
| 58 | { | ||
| 59 | int status; | ||
| 60 | pid_t pid = fork(); | ||
| 61 | pid_t wpid; | ||
| 62 | |||
| 63 | if (pid < 0) { | ||
| 64 | perror("fork() failed"); | ||
| 65 | return false; | ||
| 66 | } | ||
| 67 | if (pid == 0) | ||
| 68 | child(cpu); | ||
| 69 | |||
| 70 | wpid = waitpid(pid, &status, __WALL); | ||
| 71 | if (wpid != pid) { | ||
| 72 | perror("waitpid() failed"); | ||
| 73 | return false; | ||
| 74 | } | ||
| 75 | if (!WIFSTOPPED(status)) { | ||
| 76 | printf("child did not stop\n"); | ||
| 77 | return false; | ||
| 78 | } | ||
| 79 | if (WSTOPSIG(status) != SIGSTOP) { | ||
| 80 | printf("child did not stop with SIGSTOP\n"); | ||
| 81 | return false; | ||
| 82 | } | ||
| 83 | |||
| 84 | if (ptrace(PTRACE_SINGLESTEP, pid, NULL, NULL) < 0) { | ||
| 85 | if (errno == EIO) { | ||
| 86 | printf("ptrace(PTRACE_SINGLESTEP) not supported on this architecture\n"); | ||
| 87 | ksft_exit_skip(); | ||
| 88 | } | ||
| 89 | perror("ptrace(PTRACE_SINGLESTEP) failed"); | ||
| 90 | return false; | ||
| 91 | } | ||
| 92 | |||
| 93 | wpid = waitpid(pid, &status, __WALL); | ||
| 94 | if (wpid != pid) { | ||
| 95 | perror("waitpid() failed"); | ||
| 96 | return false; | ||
| 97 | } | ||
| 98 | if (WIFEXITED(status)) { | ||
| 99 | printf("child did not single-step\n"); | ||
| 100 | return false; | ||
| 101 | } | ||
| 102 | if (!WIFSTOPPED(status)) { | ||
| 103 | printf("child did not stop\n"); | ||
| 104 | return false; | ||
| 105 | } | ||
| 106 | if (WSTOPSIG(status) != SIGTRAP) { | ||
| 107 | printf("child did not stop with SIGTRAP\n"); | ||
| 108 | |||
