diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-10 23:46:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-10 23:46:45 -0500 |
commit | 6a177af775d92cff7ef36a681c304dc750dbe121 (patch) | |
tree | bddde274e76b662d646ece545f6057c3211e4103 | |
parent | ae36ce07abbdde3521dc0ef7e32143b88718cd21 (diff) | |
parent | 3b5bab390181968e403886a45c70f9c13b5b6d29 (diff) |
Merge tag 'linux-kselftest-4.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest updates from Shuah Khan:
"This 12 patch update for 4.4-rc1 consists of a new pstore test and
fixes to existing tests"
* tag 'linux-kselftest-4.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests: breakpoint: Actually build it
selftests: vm: Try harder to allocate huge pages
selftests: Make scripts executable
selftests: kprobe: Choose an always-defined function to probe
selftests: memfd: Stop unnecessary rebuilds
selftests: Add missing #include directives
selftests/seccomp: Be more precise with syscall arguments.
selftests/seccomp: build and pass on arm64
selftests: memfd_test: Revised STACK_SIZE to make it 16-byte aligned
selftests/pstore: add pstore test scripts going with reboot
selftests/pstore: add pstore test script for pre-reboot
selftests: add .gitignore for efivarfs
22 files changed, 362 insertions, 53 deletions
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 4b4957b8df4e..c8edff6803d1 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -14,6 +14,7 @@ TARGETS += mount | |||
14 | TARGETS += mqueue | 14 | TARGETS += mqueue |
15 | TARGETS += net | 15 | TARGETS += net |
16 | TARGETS += powerpc | 16 | TARGETS += powerpc |
17 | TARGETS += pstore | ||
17 | TARGETS += ptrace | 18 | TARGETS += ptrace |
18 | TARGETS += seccomp | 19 | TARGETS += seccomp |
19 | TARGETS += size | 20 | TARGETS += size |
@@ -66,6 +67,9 @@ clean_hotplug: | |||
66 | make -C $$TARGET clean; \ | 67 | make -C $$TARGET clean; \ |
67 | done; | 68 | done; |
68 | 69 | ||
70 | run_pstore_crash: | ||
71 | make -C pstore run_crash | ||
72 | |||
69 | INSTALL_PATH ?= install | 73 | INSTALL_PATH ?= install |
70 | INSTALL_PATH := $(abspath $(INSTALL_PATH)) | 74 | INSTALL_PATH := $(abspath $(INSTALL_PATH)) |
71 | ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh | 75 | ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh |
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile index d27108b4f208..c0d957015f52 100644 --- a/tools/testing/selftests/breakpoints/Makefile +++ b/tools/testing/selftests/breakpoints/Makefile | |||
@@ -6,7 +6,7 @@ ifeq ($(ARCH),x86) | |||
6 | TEST_PROGS := breakpoint_test | 6 | TEST_PROGS := breakpoint_test |
7 | endif | 7 | endif |
8 | 8 | ||
9 | all: | 9 | all: $(TEST_PROGS) |
10 | 10 | ||
11 | include ../lib.mk | 11 | include ../lib.mk |
12 | 12 | ||
diff --git a/tools/testing/selftests/efivarfs/.gitignore b/tools/testing/selftests/efivarfs/.gitignore new file mode 100644 index 000000000000..33618493562b --- /dev/null +++ b/tools/testing/selftests/efivarfs/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | create-read | ||
2 | open-unlink | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc b/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc index a5a426211129..c3843ed49bf6 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | echo 0 > events/enable | 6 | echo 0 > events/enable |
7 | echo > kprobe_events | 7 | echo > kprobe_events |
8 | echo p:myevent do_fork > kprobe_events | 8 | echo p:myevent _do_fork > kprobe_events |
9 | grep myevent kprobe_events | 9 | grep myevent kprobe_events |
10 | test -d events/kprobes/myevent | 10 | test -d events/kprobes/myevent |
11 | echo > kprobe_events | 11 | echo > kprobe_events |
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc b/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc index d8c7bb6581fe..74507db8bbc8 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | echo 0 > events/enable | 6 | echo 0 > events/enable |
7 | echo > kprobe_events | 7 | echo > kprobe_events |
8 | echo p:myevent do_fork > kprobe_events | 8 | echo p:myevent _do_fork > kprobe_events |
9 | test -d events/kprobes/myevent | 9 | test -d events/kprobes/myevent |
10 | echo 1 > events/kprobes/myevent/enable | 10 | echo 1 > events/kprobes/myevent/enable |
11 | echo > kprobe_events && exit 1 # this must fail | 11 | echo > kprobe_events && exit 1 # this must fail |
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc index c45ee2761354..64949d4eda69 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | echo 0 > events/enable | 6 | echo 0 > events/enable |
7 | echo > kprobe_events | 7 | echo > kprobe_events |
8 | echo 'p:testprobe do_fork $stack $stack0 +0($stack)' > kprobe_events | 8 | echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events |
9 | grep testprobe kprobe_events | 9 | grep testprobe kprobe_events |
10 | test -d events/kprobes/testprobe | 10 | test -d events/kprobes/testprobe |
11 | echo 1 > events/kprobes/testprobe/enable | 11 | echo 1 > events/kprobes/testprobe/enable |
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc index ab41d2b29841..d6f2f4965697 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc | |||
@@ -6,31 +6,31 @@ grep function available_tracers || exit_unsupported # this is configurable | |||
6 | 6 | ||
7 | # prepare | 7 | # prepare |
8 | echo nop > current_tracer | 8 | echo nop > current_tracer |
9 | echo do_fork > set_ftrace_filter | 9 | echo _do_fork > set_ftrace_filter |
10 | echo 0 > events/enable | 10 | echo 0 > events/enable |
11 | echo > kprobe_events | 11 | echo > kprobe_events |
12 | echo 'p:testprobe do_fork' > kprobe_events | 12 | echo 'p:testprobe _do_fork' > kprobe_events |
13 | 13 | ||
14 | # kprobe on / ftrace off | 14 | # kprobe on / ftrace off |
15 | echo 1 > events/kprobes/testprobe/enable | 15 | echo 1 > events/kprobes/testprobe/enable |
16 | echo > trace | 16 | echo > trace |
17 | ( echo "forked") | 17 | ( echo "forked") |
18 | grep testprobe trace | 18 | grep testprobe trace |
19 | ! grep 'do_fork <-' trace | 19 | ! grep '_do_fork <-' trace |
20 | 20 | ||
21 | # kprobe on / ftrace on | 21 | # kprobe on / ftrace on |
22 | echo function > current_tracer | 22 | echo function > current_tracer |
23 | echo > trace | 23 | echo > trace |
24 | ( echo "forked") | 24 | ( echo "forked") |
25 | grep testprobe trace | 25 | grep testprobe trace |
26 | grep 'do_fork <-' trace | 26 | grep '_do_fork <-' trace |
27 | 27 | ||
28 | # kprobe off / ftrace on | 28 | # kprobe off / ftrace on |
29 | echo 0 > events/kprobes/testprobe/enable | 29 | echo 0 > events/kprobes/testprobe/enable |
30 | echo > trace | 30 | echo > trace |
31 | ( echo "forked") | 31 | ( echo "forked") |
32 | ! grep testprobe trace | 32 | ! grep testprobe trace |
33 | grep 'do_fork <-' trace | 33 | grep '_do_fork <-' trace |
34 | 34 | ||
35 | # kprobe on / ftrace on | 35 | # kprobe on / ftrace on |
36 | echo 1 > events/kprobes/testprobe/enable | 36 | echo 1 > events/kprobes/testprobe/enable |
@@ -38,14 +38,14 @@ echo function > current_tracer | |||
38 | echo > trace | 38 | echo > trace |
39 | ( echo "forked") | 39 | ( echo "forked") |
40 | grep testprobe trace | 40 | grep testprobe trace |
41 | grep 'do_fork <-' trace | 41 | grep '_do_fork <-' trace |
42 | 42 | ||
43 | # kprobe on / ftrace off | 43 | # kprobe on / ftrace off |
44 | echo nop > current_tracer | 44 | echo nop > current_tracer |
45 | echo > trace | 45 | echo > trace |
46 | ( echo "forked") | 46 | ( echo "forked") |
47 | grep testprobe trace | 47 | grep testprobe trace |
48 | ! grep 'do_fork <-' trace | 48 | ! grep '_do_fork <-' trace |
49 | 49 | ||
50 | # cleanup | 50 | # cleanup |
51 | echo nop > current_tracer | 51 | echo nop > current_tracer |
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc index 31717985acc7..0d09546258fd 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | echo 0 > events/enable | 6 | echo 0 > events/enable |
7 | echo > kprobe_events | 7 | echo > kprobe_events |
8 | echo 'r:testprobe2 do_fork $retval' > kprobe_events | 8 | echo 'r:testprobe2 _do_fork $retval' > kprobe_events |
9 | grep testprobe2 kprobe_events | 9 | grep testprobe2 kprobe_events |
10 | test -d events/kprobes/testprobe2 | 10 | test -d events/kprobes/testprobe2 |
11 | echo 1 > events/kprobes/testprobe2/enable | 11 | echo 1 > events/kprobes/testprobe2/enable |
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile index 3e7eb7972511..fd396ac811b6 100644 --- a/tools/testing/selftests/memfd/Makefile +++ b/tools/testing/selftests/memfd/Makefile | |||
@@ -4,16 +4,16 @@ CFLAGS += -I../../../../include/uapi/ | |||
4 | CFLAGS += -I../../../../include/ | 4 | CFLAGS += -I../../../../include/ |
5 | CFLAGS += -I../../../../usr/include/ | 5 | CFLAGS += -I../../../../usr/include/ |
6 | 6 | ||
7 | all: | ||
8 | $(CC) $(CFLAGS) memfd_test.c -o memfd_test | ||
9 | |||
10 | TEST_PROGS := memfd_test | 7 | TEST_PROGS := memfd_test |
11 | 8 | ||
9 | all: $(TEST_PROGS) | ||
10 | |||
12 | include ../lib.mk | 11 | include ../lib.mk |
13 | 12 | ||
14 | build_fuse: | 13 | build_fuse: fuse_mnt fuse_test |
15 | $(CC) $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt | 14 | |
16 | $(CC) $(CFLAGS) fuse_test.c -o fuse_test | 15 | fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags) |
16 | fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs) | ||
17 | 17 | ||
18 | run_fuse: build_fuse | 18 | run_fuse: build_fuse |
19 | @./run_fuse_test.sh || echo "fuse_test: [FAIL]" | 19 | @./run_fuse_test.sh || echo "fuse_test: [FAIL]" |
diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index 0b9eafb7ab7b..26546892cd54 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c | |||
@@ -15,10 +15,11 @@ | |||
15 | #include <sys/mman.h> | 15 | #include <sys/mman.h> |
16 | #include <sys/stat.h> | 16 | #include <sys/stat.h> |
17 | #include <sys/syscall.h> | 17 | #include <sys/syscall.h> |
18 | #include <sys/wait.h> | ||
18 | #include <unistd.h> | 19 | #include <unistd.h> |
19 | 20 | ||
20 | #define MFD_DEF_SIZE 8192 | 21 | #define MFD_DEF_SIZE 8192 |
21 | #define STACK_SIZE 65535 | 22 | #define STACK_SIZE 65536 |
22 | 23 | ||
23 | static int sys_memfd_create(const char *name, | 24 | static int sys_memfd_create(const char *name, |
24 | unsigned int flags) | 25 | unsigned int flags) |
diff --git a/tools/testing/selftests/memfd/run_fuse_test.sh b/tools/testing/selftests/memfd/run_fuse_test.sh index 69b930e1e041..69b930e1e041 100644..100755 --- a/tools/testing/selftests/memfd/run_fuse_test.sh +++ b/tools/testing/selftests/memfd/run_fuse_test.sh | |||
diff --git a/tools/testing/selftests/mqueue/mq_open_tests.c b/tools/testing/selftests/mqueue/mq_open_tests.c index 9c1a5d359055..e0a74bd207a5 100644 --- a/tools/testing/selftests/mqueue/mq_open_tests.c +++ b/tools/testing/selftests/mqueue/mq_open_tests.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <sys/resource.h> | 31 | #include <sys/resource.h> |
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <mqueue.h> | 33 | #include <mqueue.h> |
34 | #include <error.h> | ||
34 | 35 | ||
35 | static char *usage = | 36 | static char *usage = |
36 | "Usage:\n" | 37 | "Usage:\n" |
diff --git a/tools/testing/selftests/mqueue/mq_perf_tests.c b/tools/testing/selftests/mqueue/mq_perf_tests.c index 8519e9ee97e3..8188f72de93c 100644 --- a/tools/testing/selftests/mqueue/mq_perf_tests.c +++ b/tools/testing/selftests/mqueue/mq_perf_tests.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
38 | #include <mqueue.h> | 38 | #include <mqueue.h> |
39 | #include <popt.h> | 39 | #include <popt.h> |
40 | #include <error.h> | ||
40 | 41 | ||
41 | static char *usage = | 42 | static char *usage = |
42 | "Usage:\n" | 43 | "Usage:\n" |
diff --git a/tools/testing/selftests/pstore/Makefile b/tools/testing/selftests/pstore/Makefile new file mode 100644 index 000000000000..bd7abe24ea08 --- /dev/null +++ b/tools/testing/selftests/pstore/Makefile | |||
@@ -0,0 +1,15 @@ | |||
1 | # Makefile for pstore selftests. | ||
2 | # Expects pstore backend is registered. | ||
3 | |||
4 | all: | ||
5 | |||
6 | TEST_PROGS := pstore_tests pstore_post_reboot_tests | ||
7 | TEST_FILES := common_tests pstore_crash_test | ||
8 | |||
9 | include ../lib.mk | ||
10 | |||
11 | run_crash: | ||
12 | @sh pstore_crash_test || { echo "pstore_crash_test: [FAIL]"; exit 1; } | ||
13 | |||
14 | clean: | ||
15 | rm -rf logs/* *uuid | ||
diff --git a/tools/testing/selftests/pstore/common_tests b/tools/testing/selftests/pstore/common_tests new file mode 100755 index 000000000000..3ea64d7cf1cd --- /dev/null +++ b/tools/testing/selftests/pstore/common_tests | |||
@@ -0,0 +1,83 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # common_tests - Shell script commonly used by pstore test scripts | ||
4 | # | ||
5 | # Copyright (C) Hitachi Ltd., 2015 | ||
6 | # Written by Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com> | ||
7 | # | ||
8 | # Released under the terms of the GPL v2. | ||
9 | |||
10 | # Utilities | ||
11 | errexit() { # message | ||
12 | echo "Error: $1" 1>&2 | ||
13 | exit 1 | ||
14 | } | ||
15 | |||
16 | absdir() { # file_path | ||
17 | (cd `dirname $1`; pwd) | ||
18 | } | ||
19 | |||
20 | show_result() { # result_value | ||
21 | if [ $1 -eq 0 ]; then | ||
22 | prlog "ok" | ||
23 | else | ||
24 | prlog "FAIL" | ||
25 | rc=1 | ||
26 | fi | ||
27 | } | ||
28 | |||
29 | check_files_exist() { # type of pstorefs file | ||
30 | if [ -e ${1}-${backend}-0 ]; then | ||
31 | prlog "ok" | ||
32 | for f in `ls ${1}-${backend}-*`; do | ||
33 | prlog -e "\t${f}" | ||
34 | done | ||
35 | else | ||
36 | prlog "FAIL" | ||
37 | rc=1 | ||
38 | fi | ||
39 | } | ||
40 | |||
41 | operate_files() { # tested value, files, operation | ||
42 | if [ $1 -eq 0 ]; then | ||
43 | prlog | ||
44 | for f in $2; do | ||
45 | prlog -ne "\t${f} ... " | ||
46 | # execute operation | ||
47 | $3 $f | ||
48 | show_result $? | ||
49 | done | ||
50 | else | ||
51 | prlog " ... FAIL" | ||
52 | rc=1 | ||
53 | fi | ||
54 | } | ||
55 | |||
56 | # Parameters | ||
57 | TEST_STRING_PATTERN="Testing pstore: uuid=" | ||
58 | UUID=`cat /proc/sys/kernel/random/uuid` | ||
59 | TOP_DIR=`absdir $0` | ||
60 | LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`_${UUID}/ | ||
61 | REBOOT_FLAG=$TOP_DIR/reboot_flag | ||
62 | |||
63 | # Preparing logs | ||
64 | LOG_FILE=$LOG_DIR/`basename $0`.log | ||
65 | mkdir -p $LOG_DIR || errexit "Failed to make a log directory: $LOG_DIR" | ||
66 | date > $LOG_FILE | ||
67 | prlog() { # messages | ||
68 | /bin/echo "$@" | tee -a $LOG_FILE | ||
69 | } | ||
70 | |||
71 | # Starting tests | ||
72 | rc=0 | ||
73 | prlog "=== Pstore unit tests (`basename $0`) ===" | ||
74 | prlog "UUID="$UUID | ||
75 | |||
76 | prlog -n "Checking pstore backend is registered ... " | ||
77 | backend=`cat /sys/module/pstore/parameters/backend` | ||
78 | show_result $? | ||
79 | prlog -e "\tbackend=${backend}" | ||
80 | prlog -e "\tcmdline=`cat /proc/cmdline`" | ||
81 | if [ $rc -ne 0 ]; then | ||
82 | exit 1 | ||
83 | fi | ||
diff --git a/tools/testing/selftests/pstore/pstore_crash_test b/tools/testing/selftests/pstore/pstore_crash_test new file mode 100755 index 000000000000..1a4afe5c12b6 --- /dev/null +++ b/tools/testing/selftests/pstore/pstore_crash_test | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # pstore_crash_test - Pstore test shell script which causes crash and reboot | ||
4 | # | ||
5 | # Copyright (C) Hitachi Ltd., 2015 | ||
6 | # Written by Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com> | ||
7 | # | ||
8 | # Released under the terms of the GPL v2. | ||
9 | |||
10 | # exit if pstore backend is not registered | ||
11 | . ./common_tests | ||
12 | |||
13 | prlog "Causing kernel crash ..." | ||
14 | |||
15 | # enable all functions triggered by sysrq | ||
16 | echo 1 > /proc/sys/kernel/sysrq | ||
17 | # setting to reboot in 3 seconds after panic | ||
18 | echo 3 > /proc/sys/kernel/panic | ||
19 | |||
20 | # save uuid file by different name because next test execution will replace it. | ||
21 | mv $TOP_DIR/uuid $TOP_DIR/prev_uuid | ||
22 | |||
23 | # create a file as reboot flag | ||
24 | touch $REBOOT_FLAG | ||
25 | sync | ||
26 | |||
27 | # cause crash | ||
28 | # Note: If you use kdump and want to see kmesg-* files after reboot, you should | ||
29 | # specify 'crash_kexec_post_notifiers' in 1st kernel's cmdline. | ||
30 | echo c > /proc/sysrq-trigger | ||
diff --git a/tools/testing/selftests/pstore/pstore_post_reboot_tests b/tools/testing/selftests/pstore/pstore_post_reboot_tests new file mode 100755 index 000000000000..6ccb154cb4aa --- /dev/null +++ b/tools/testing/selftests/pstore/pstore_post_reboot_tests | |||
@@ -0,0 +1,77 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # pstore_post_reboot_tests - Check pstore's behavior after crash/reboot | ||
4 | # | ||
5 | # Copyright (C) Hitachi Ltd., 2015 | ||
6 | # Written by Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com> | ||
7 | # | ||
8 | # Released under the terms of the GPL v2. | ||
9 | |||
10 | . ./common_tests | ||
11 | |||
12 | if [ -e $REBOOT_FLAG ]; then | ||
13 | rm $REBOOT_FLAG | ||
14 | else | ||
15 | prlog "pstore_crash_test has not been executed yet. we skip further tests." | ||
16 | exit 0 | ||
17 | fi | ||
18 | |||
19 | prlog -n "Mounting pstore filesystem ... " | ||
20 | mount_info=`grep pstore /proc/mounts` | ||
21 | if [ $? -eq 0 ]; then | ||
22 | mount_point=`echo ${mount_info} | cut -d' ' -f2 | head -n1` | ||
23 | prlog "ok" | ||
24 | else | ||
25 | mount none /sys/fs/pstore -t pstore | ||
26 | if [ $? -eq 0 ]; then | ||
27 | mount_point=`grep pstore /proc/mounts | cut -d' ' -f2 | head -n1` | ||
28 | prlog "ok" | ||
29 | else | ||
30 | prlog "FAIL" | ||
31 | exit 1 | ||
32 | fi | ||
33 | fi | ||
34 | |||
35 | cd ${mount_point} | ||
36 | |||
37 | prlog -n "Checking dmesg files exist in pstore filesystem ... " | ||
38 | check_files_exist dmesg | ||
39 | |||
40 | prlog -n "Checking console files exist in pstore filesystem ... " | ||
41 | check_files_exist console | ||
42 | |||
43 | prlog -n "Checking pmsg files exist in pstore filesystem ... " | ||
44 | check_files_exist pmsg | ||
45 | |||
46 | prlog -n "Checking dmesg files contain oops end marker" | ||
47 | grep_end_trace() { | ||
48 | grep -q "\---\[ end trace" $1 | ||
49 | } | ||
50 | files=`ls dmesg-${backend}-*` | ||
51 | operate_files $? "$files" grep_end_trace | ||
52 | |||
53 | prlog -n "Checking console file contains oops end marker ... " | ||
54 | grep -q "\---\[ end trace" console-${backend}-0 | ||
55 | show_result $? | ||
56 | |||
57 | prlog -n "Checking pmsg file properly keeps the content written before crash ... " | ||
58 | prev_uuid=`cat $TOP_DIR/prev_uuid` | ||
59 | if [ $? -eq 0 ]; then | ||
60 | nr_matched=`grep -c "$TEST_STRING_PATTERN" pmsg-${backend}-0` | ||
61 | if [ $nr_matched -eq 1 ]; then | ||
62 | grep -q "$TEST_STRING_PATTERN"$prev_uuid pmsg-${backend}-0 | ||
63 | show_result $? | ||
64 | else | ||
65 | prlog "FAIL" | ||
66 | rc=1 | ||
67 | fi | ||
68 | else | ||
69 | prlog "FAIL" | ||
70 | rc=1 | ||
71 | fi | ||
72 | |||
73 | prlog -n "Removing all files in pstore filesystem " | ||
74 | files=`ls *-${backend}-*` | ||
75 | operate_files $? "$files" rm | ||
76 | |||
77 | exit $rc | ||
diff --git a/tools/testing/selftests/pstore/pstore_tests b/tools/testing/selftests/pstore/pstore_tests new file mode 100755 index 000000000000..f25d2a349a60 --- /dev/null +++ b/tools/testing/selftests/pstore/pstore_tests | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # pstore_tests - Check pstore's behavior before crash/reboot | ||
4 | # | ||
5 | # Copyright (C) Hitachi Ltd., 2015 | ||
6 | # Written by Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com> | ||
7 | # | ||
8 | # Released under the terms of the GPL v2. | ||
9 | |||
10 | . ./common_tests | ||
11 | |||
12 | prlog -n "Checking pstore console is registered ... " | ||
13 | dmesg | grep -q "console \[pstore" | ||
14 | show_result $? | ||
15 | |||
16 | prlog -n "Checking /dev/pmsg0 exists ... " | ||
17 | test -e /dev/pmsg0 | ||
18 | show_result $? | ||
19 | |||
20 | prlog -n "Writing unique string to /dev/pmsg0 ... " | ||
21 | if [ -e "/dev/pmsg0" ]; then | ||
22 | echo "${TEST_STRING_PATTERN}""$UUID" > /dev/pmsg0 | ||
23 | show_result $? | ||
24 | echo "$UUID" > $TOP_DIR/uuid | ||
25 | else | ||
26 | prlog "FAIL" | ||
27 | rc=1 | ||
28 | fi | ||
29 | |||
30 | exit $rc | ||
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 770f47adf295..e38cc54942db 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c | |||
@@ -19,15 +19,19 @@ | |||
19 | #include <linux/prctl.h> | 19 | #include <linux/prctl.h> |
20 | #include <linux/ptrace.h> | 20 | #include <linux/ptrace.h> |
21 | #include <linux/seccomp.h> | 21 | #include <linux/seccomp.h> |
22 | #include <poll.h> | ||
23 | #include <pthread.h> | 22 | #include <pthread.h> |
24 | #include <semaphore.h> | 23 | #include <semaphore.h> |
25 | #include <signal.h> | 24 | #include <signal.h> |
26 | #include <stddef.h> | 25 | #include <stddef.h> |
27 | #include <stdbool.h> | 26 | #include <stdbool.h> |
28 | #include <string.h> | 27 | #include <string.h> |
28 | #include <time.h> | ||
29 | #include <linux/elf.h> | 29 | #include <linux/elf.h> |
30 | #include <sys/uio.h> | 30 | #include <sys/uio.h> |
31 | #include <sys/utsname.h> | ||
32 | #include <sys/fcntl.h> | ||
33 | #include <sys/mman.h> | ||
34 | #include <sys/times.h> | ||
31 | 35 | ||
32 | #define _GNU_SOURCE | 36 | #define _GNU_SOURCE |
33 | #include <unistd.h> | 37 | #include <unistd.h> |
@@ -428,14 +432,16 @@ TEST_SIGNAL(KILL_one, SIGSYS) | |||
428 | 432 | ||
429 | TEST_SIGNAL(KILL_one_arg_one, SIGSYS) | 433 | TEST_SIGNAL(KILL_one_arg_one, SIGSYS) |
430 | { | 434 | { |
435 | void *fatal_address; | ||
431 | struct sock_filter filter[] = { | 436 | struct sock_filter filter[] = { |
432 | BPF_STMT(BPF_LD|BPF_W|BPF_ABS, | 437 | BPF_STMT(BPF_LD|BPF_W|BPF_ABS, |
433 | offsetof(struct seccomp_data, nr)), | 438 | offsetof(struct seccomp_data, nr)), |
434 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 1, 0), | 439 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_times, 1, 0), |
435 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), | 440 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), |
436 | /* Only both with lower 32-bit for now. */ | 441 | /* Only both with lower 32-bit for now. */ |
437 | BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(0)), | 442 | BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(0)), |
438 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 0x0C0FFEE, 0, 1), | 443 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, |
444 | (unsigned long)&fatal_address, 0, 1), | ||
439 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL), | 445 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL), |
440 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), | 446 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), |
441 | }; | 447 | }; |
@@ -445,7 +451,8 @@ TEST_SIGNAL(KILL_one_arg_one, SIGSYS) | |||
445 | }; | 451 | }; |
446 | long ret; | 452 | long ret; |
447 | pid_t parent = getppid(); | 453 | pid_t parent = getppid(); |
448 | pid_t pid = getpid(); | 454 | struct tms timebuf; |
455 | clock_t clock = times(&timebuf); | ||
449 | 456 | ||
450 | ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); | 457 | ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); |
451 | ASSERT_EQ(0, ret); | 458 | ASSERT_EQ(0, ret); |
@@ -454,17 +461,22 @@ TEST_SIGNAL(KILL_one_arg_one, SIGSYS) | |||
454 | ASSERT_EQ(0, ret); | 461 | ASSERT_EQ(0, ret); |
455 | 462 | ||
456 | EXPECT_EQ(parent, syscall(__NR_getppid)); | 463 | EXPECT_EQ(parent, syscall(__NR_getppid)); |
457 | EXPECT_EQ(pid, syscall(__NR_getpid)); | 464 | EXPECT_LE(clock, syscall(__NR_times, &timebuf)); |
458 | /* getpid() should never return. */ | 465 | /* times() should never return. */ |
459 | EXPECT_EQ(0, syscall(__NR_getpid, 0x0C0FFEE)); | 466 | EXPECT_EQ(0, syscall(__NR_times, &fatal_address)); |
460 | } | 467 | } |
461 | 468 | ||
462 | TEST_SIGNAL(KILL_one_arg_six, SIGSYS) | 469 | TEST_SIGNAL(KILL_one_arg_six, SIGSYS) |
463 | { | 470 | { |
471 | #ifndef __NR_mmap2 | ||
472 | int sysno = __NR_mmap; | ||
473 | #else | ||
474 | int sysno = __NR_mmap2; | ||
475 | #endif | ||
464 | struct sock_filter filter[] = { | 476 | struct sock_filter filter[] = { |
465 | BPF_STMT(BPF_LD|BPF_W|BPF_ABS, | 477 | BPF_STMT(BPF_LD|BPF_W|BPF_ABS, |
466 | offsetof(struct seccomp_data, nr)), | 478 | offsetof(struct seccomp_data, nr)), |
467 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 1, 0), | 479 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, sysno, 1, 0), |
468 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), | 480 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), |
469 | /* Only both with lower 32-bit for now. */ | 481 | /* Only both with lower 32-bit for now. */ |
470 | BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(5)), | 482 | BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(5)), |
@@ -478,7 +490,8 @@ TEST_SIGNAL(KILL_one_arg_six, SIGSYS) | |||
478 | }; | 490 | }; |
479 | long ret; | 491 | long ret; |
480 | pid_t parent = getppid(); | 492 | pid_t parent = getppid(); |
481 | pid_t pid = getpid(); | 493 | int fd; |
494 | void *map1, *map2; | ||
482 | 495 | ||
483 | ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); | 496 | ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); |
484 | ASSERT_EQ(0, ret); | 497 | ASSERT_EQ(0, ret); |
@@ -486,10 +499,22 @@ TEST_SIGNAL(KILL_one_arg_six, SIGSYS) | |||
486 | ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog); | 499 | ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog); |
487 | ASSERT_EQ(0, ret); | 500 | ASSERT_EQ(0, ret); |
488 | 501 | ||
502 | fd = open("/dev/zero", O_RDONLY); | ||
503 | ASSERT_NE(-1, fd); | ||
504 | |||
489 | EXPECT_EQ(parent, syscall(__NR_getppid)); | 505 | EXPECT_EQ(parent, syscall(__NR_getppid)); |
490 | EXPECT_EQ(pid, syscall(__NR_getpid)); | 506 | map1 = (void *)syscall(sysno, |
491 | /* getpid() should never return. */ | 507 | NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, PAGE_SIZE); |
492 | EXPECT_EQ(0, syscall(__NR_getpid, 1, 2, 3, 4, 5, 0x0C0FFEE)); | 508 | EXPECT_NE(MAP_FAILED, map1); |
509 | /* mmap2() should never return. */ | ||
510 | map2 = (void *)syscall(sysno, | ||
511 | NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE); | ||
512 | EXPECT_EQ(MAP_FAILED, map2); | ||
513 | |||
514 | /* The test failed, so clean up the resources. */ | ||
515 | munmap(map1, PAGE_SIZE); | ||
516 | munmap(map2, PAGE_SIZE); | ||
517 | close(fd); | ||
493 | } | 518 | } |
494 | 519 | ||
495 | /* TODO(wad) add 64-bit versus 32-bit arg tests. */ | 520 | /* TODO(wad) add 64-bit versus 32-bit arg tests. */ |
@@ -1247,8 +1272,8 @@ void change_syscall(struct __test_metadata *_metadata, | |||
1247 | ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); | 1272 | ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); |
1248 | EXPECT_EQ(0, ret); | 1273 | EXPECT_EQ(0, ret); |
1249 | 1274 | ||
1250 | #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \ | 1275 | #if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \ |
1251 | defined(__powerpc__) || defined(__s390__) | 1276 | defined(__s390__) |
1252 | { | 1277 | { |
1253 | regs.SYSCALL_NUM = syscall; | 1278 | regs.SYSCALL_NUM = syscall; |
1254 | } | 1279 | } |
@@ -1262,6 +1287,18 @@ void change_syscall(struct __test_metadata *_metadata, | |||
1262 | EXPECT_EQ(0, ret); | 1287 | EXPECT_EQ(0, ret); |
1263 | } | 1288 | } |
1264 | 1289 | ||
1290 | #elif defined(__aarch64__) | ||
1291 | # ifndef NT_ARM_SYSTEM_CALL | ||
1292 | # define NT_ARM_SYSTEM_CALL 0x404 | ||
1293 | # endif | ||
1294 | { | ||
1295 | iov.iov_base = &syscall; | ||
1296 | iov.iov_len = sizeof(syscall); | ||
1297 | ret = ptrace(PTRACE_SETREGSET, tracee, NT_ARM_SYSTEM_CALL, | ||
1298 | &iov); | ||
1299 | EXPECT_EQ(0, ret); | ||
1300 | } | ||
1301 | |||
1265 | #else | 1302 | #else |
1266 | ASSERT_EQ(1, 0) { | 1303 | ASSERT_EQ(1, 0) { |
1267 | TH_LOG("How is the syscall changed on this architecture?"); | 1304 | TH_LOG("How is the syscall changed on this architecture?"); |
@@ -1272,6 +1309,8 @@ void change_syscall(struct __test_metadata *_metadata, | |||
1272 | if (syscall == -1) | 1309 | if (syscall == -1) |
1273 | regs.SYSCALL_RET = 1; | 1310 | regs.SYSCALL_RET = 1; |
1274 | 1311 | ||
1312 | iov.iov_base = ®s; | ||
1313 | iov.iov_len = sizeof(regs); | ||
1275 | ret = ptrace(PTRACE_SETREGSET, tracee, NT_PRSTATUS, &iov); | 1314 | ret = ptrace(PTRACE_SETREGSET, tracee, NT_PRSTATUS, &iov); |
1276 | EXPECT_EQ(0, ret); | 1315 | EXPECT_EQ(0, ret); |
1277 | } | 1316 | } |
@@ -2005,20 +2044,25 @@ TEST(syscall_restart) | |||
2005 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_read, 5, 0), | 2044 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_read, 5, 0), |
2006 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_exit, 4, 0), | 2045 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_exit, 4, 0), |
2007 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_rt_sigreturn, 3, 0), | 2046 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_rt_sigreturn, 3, 0), |
2008 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_poll, 4, 0), | 2047 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_nanosleep, 4, 0), |
2009 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_restart_syscall, 4, 0), | 2048 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_restart_syscall, 4, 0), |
2010 | 2049 | ||
2011 | /* Allow __NR_write for easy logging. */ | 2050 | /* Allow __NR_write for easy logging. */ |
2012 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_write, 0, 1), | 2051 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_write, 0, 1), |
2013 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), | 2052 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), |
2014 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL), | 2053 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL), |
2015 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x100), /* poll */ | 2054 | /* The nanosleep jump target. */ |
2016 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x200), /* restart */ | 2055 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x100), |
2056 | /* The restart_syscall jump target. */ | ||
2057 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x200), | ||
2017 | }; | 2058 | }; |
2018 | struct sock_fprog prog = { | 2059 | struct sock_fprog prog = { |
2019 | .len = (unsigned short)ARRAY_SIZE(filter), | 2060 | .len = (unsigned short)ARRAY_SIZE(filter), |
2020 | .filter = filter, | 2061 | .filter = filter, |
2021 | }; | 2062 | }; |
2063 | #if defined(__arm__) | ||
2064 | struct utsname utsbuf; | ||
2065 | #endif | ||
2022 | 2066 | ||
2023 | ASSERT_EQ(0, pipe(pipefd)); | 2067 | ASSERT_EQ(0, pipe(pipefd)); |
2024 | 2068 | ||
@@ -2027,10 +2071,7 @@ TEST(syscall_restart) | |||
2027 | if (child_pid == 0) { | 2071 | if (child_pid == 0) { |
2028 | /* Child uses EXPECT not ASSERT to deliver status correctly. */ | 2072 | /* Child uses EXPECT not ASSERT to deliver status correctly. */ |
2029 | char buf = ' '; | 2073 | char buf = ' '; |
2030 | struct pollfd fds = { | 2074 | struct timespec timeout = { }; |
2031 | .fd = pipefd[0], | ||
2032 | .events = POLLIN, | ||
2033 | }; | ||
2034 | 2075 | ||
2035 | /* Attach parent as tracer and stop. */ | 2076 | /* Attach parent as tracer and stop. */ |
2036 | EXPECT_EQ(0, ptrace(PTRACE_TRACEME)); | 2077 | EXPECT_EQ(0, ptrace(PTRACE_TRACEME)); |
@@ -2054,10 +2095,11 @@ TEST(syscall_restart) | |||
2054 | TH_LOG("Failed to get sync data from read()"); | 2095 | TH_LOG("Failed to get sync data from read()"); |
2055 | } | 2096 | } |
2056 | 2097 | ||
2057 | /* Start poll to be interrupted. */ | 2098 | /* Start nanosleep to be interrupted. */ |
2099 | timeout.tv_sec = 1; | ||
2058 | errno = 0; | 2100 | errno = 0; |
2059 | EXPECT_EQ(1, poll(&fds, 1, -1)) { | 2101 | EXPECT_EQ(0, nanosleep(&timeout, NULL)) { |
2060 | TH_LOG("Call to poll() failed (errno %d)", errno); | 2102 | TH_LOG("Call to nanosleep() failed (errno %d)", errno); |
2061 | } | 2103 | } |
2062 | 2104 | ||
2063 | /* Read final sync from parent. */ | 2105 | /* Read final sync from parent. */ |
@@ -2082,14 +2124,14 @@ TEST(syscall_restart) | |||
2082 | ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0)); | 2124 | ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0)); |
2083 | ASSERT_EQ(1, write(pipefd[1], ".", 1)); | 2125 | ASSERT_EQ(1, write(pipefd[1], ".", 1)); |
2084 | 2126 | ||
2085 | /* Wait for poll() to start. */ | 2127 | /* Wait for nanosleep() to start. */ |
2086 | ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0)); | 2128 | ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0)); |
2087 | ASSERT_EQ(true, WIFSTOPPED(status)); | 2129 | ASSERT_EQ(true, WIFSTOPPED(status)); |
2088 | ASSERT_EQ(SIGTRAP, WSTOPSIG(status)); | 2130 | ASSERT_EQ(SIGTRAP, WSTOPSIG(status)); |
2089 | ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16)); | 2131 | ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16)); |
2090 | ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg)); | 2132 | ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg)); |
2091 | ASSERT_EQ(0x100, msg); | 2133 | ASSERT_EQ(0x100, msg); |
2092 | EXPECT_EQ(__NR_poll, get_syscall(_metadata, child_pid)); | 2134 | EXPECT_EQ(__NR_nanosleep, get_syscall(_metadata, child_pid)); |
2093 | 2135 | ||
2094 | /* Might as well check siginfo for sanity while we're here. */ | 2136 | /* Might as well check siginfo for sanity while we're here. */ |
2095 | ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info)); | 2137 | ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info)); |
@@ -2100,7 +2142,7 @@ TEST(syscall_restart) | |||
2100 | /* Verify signal delivery came from child (seccomp-triggered). */ | 2142 | /* Verify signal delivery came from child (seccomp-triggered). */ |
2101 | EXPECT_EQ(child_pid, info.si_pid); | 2143 | EXPECT_EQ(child_pid, info.si_pid); |
2102 | 2144 | ||
2103 | /* Interrupt poll with SIGSTOP (which we'll need to handle). */ | 2145 | /* Interrupt nanosleep with SIGSTOP (which we'll need to handle). */ |
2104 | ASSERT_EQ(0, kill(child_pid, SIGSTOP)); | 2146 | ASSERT_EQ(0, kill(child_pid, SIGSTOP)); |
2105 | ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0)); | 2147 | ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0)); |
2106 | ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0)); | 2148 | ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0)); |
@@ -2110,7 +2152,7 @@ TEST(syscall_restart) | |||
2110 | ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info)); | 2152 | ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info)); |
2111 | EXPECT_EQ(getpid(), info.si_pid); | 2153 | EXPECT_EQ(getpid(), info.si_pid); |
2112 | 2154 | ||
2113 | /* Restart poll with SIGCONT, which triggers restart_syscall. */ | 2155 | /* Restart nanosleep with SIGCONT, which triggers restart_syscall. */ |
2114 | ASSERT_EQ(0, kill(child_pid, SIGCONT)); | 2156 | ASSERT_EQ(0, kill(child_pid, SIGCONT)); |
2115 | ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0)); | 2157 | ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0)); |
2116 | ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0)); | 2158 | ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0)); |
@@ -2124,16 +2166,25 @@ TEST(syscall_restart) | |||
2124 | ASSERT_EQ(SIGTRAP, WSTOPSIG(status)); | 2166 | ASSERT_EQ(SIGTRAP, WSTOPSIG(status)); |
2125 | ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16)); | 2167 | ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16)); |
2126 | ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg)); | 2168 | ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg)); |
2169 | |||
2127 | ASSERT_EQ(0x200, msg); | 2170 | ASSERT_EQ(0x200, msg); |
2128 | ret = get_syscall(_metadata, child_pid); | 2171 | ret = get_syscall(_metadata, child_pid); |
2129 | #if defined(__arm__) | 2172 | #if defined(__arm__) |
2130 | /* FIXME: ARM does not expose true syscall in registers. */ | 2173 | /* |
2131 | EXPECT_EQ(__NR_poll, ret); | 2174 | * FIXME: |
2132 | #else | 2175 | * - native ARM registers do NOT expose true syscall. |
2133 | EXPECT_EQ(__NR_restart_syscall, ret); | 2176 | * - compat ARM registers on ARM64 DO expose true syscall. |
2177 | */ | ||
2178 | ASSERT_EQ(0, uname(&utsbuf)); | ||
2179 | if (strncmp(utsbuf.machine, "arm", 3) == 0) { | ||
2180 | EXPECT_EQ(__NR_nanosleep, ret); | ||
2181 | } else | ||
2134 | #endif | 2182 | #endif |
2183 | { | ||
2184 | EXPECT_EQ(__NR_restart_syscall, ret); | ||
2185 | } | ||
2135 | 2186 | ||
2136 | /* Write again to end poll. */ | 2187 | /* Write again to end test. */ |
2137 | ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0)); | 2188 | ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0)); |
2138 | ASSERT_EQ(1, write(pipefd[1], "!", 1)); | 2189 | ASSERT_EQ(1, write(pipefd[1], "!", 1)); |
2139 | EXPECT_EQ(0, close(pipefd[1])); | 2190 | EXPECT_EQ(0, close(pipefd[1])); |
diff --git a/tools/testing/selftests/static_keys/test_static_keys.sh b/tools/testing/selftests/static_keys/test_static_keys.sh index 1261e3fa1e3a..1261e3fa1e3a 100644..100755 --- a/tools/testing/selftests/static_keys/test_static_keys.sh +++ b/tools/testing/selftests/static_keys/test_static_keys.sh | |||
diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/selftests/timers/nanosleep.c index 8a3c29de7d49..ff942ff7c9b3 100644 --- a/tools/testing/selftests/timers/nanosleep.c +++ b/tools/testing/selftests/timers/nanosleep.c | |||
@@ -19,6 +19,7 @@ | |||
19 | * GNU General Public License for more details. | 19 | * GNU General Public License for more details. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <errno.h> | ||
22 | #include <stdio.h> | 23 | #include <stdio.h> |
23 | #include <stdlib.h> | 24 | #include <stdlib.h> |
24 | #include <time.h> | 25 | #include <time.h> |
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index 2df21b3bb26d..e11968b3677e 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests | |||
@@ -20,13 +20,26 @@ done < /proc/meminfo | |||
20 | if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then | 20 | if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then |
21 | nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` | 21 | nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` |
22 | needpgs=`expr $needmem / $pgsize` | 22 | needpgs=`expr $needmem / $pgsize` |
23 | if [ $freepgs -lt $needpgs ]; then | 23 | tries=2 |
24 | while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do | ||
24 | lackpgs=$(( $needpgs - $freepgs )) | 25 | lackpgs=$(( $needpgs - $freepgs )) |
26 | echo 3 > /proc/sys/vm/drop_caches | ||
25 | echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages | 27 | echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages |
26 | if [ $? -ne 0 ]; then | 28 | if [ $? -ne 0 ]; then |
27 | echo "Please run this test as root" | 29 | echo "Please run this test as root" |
28 | exit 1 | 30 | exit 1 |
29 | fi | 31 | fi |
32 | while read name size unit; do | ||
33 | if [ "$name" = "HugePages_Free:" ]; then | ||
34 | freepgs=$size | ||
35 | fi | ||
36 | done < /proc/meminfo | ||
37 | tries=$((tries - 1)) | ||
38 | done | ||
39 | if [ $freepgs -lt $needpgs ]; then | ||
40 | printf "Not enough huge pages available (%d < %d)\n" \ | ||
41 | $freepgs $needpgs | ||
42 | exit 1 | ||
30 | fi | 43 | fi |
31 | else | 44 | else |
32 | echo "no hugetlbfs support in kernel?" | 45 | echo "no hugetlbfs support in kernel?" |