diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-19 23:57:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-19 23:57:45 -0400 |
commit | 30ec56824897fc70f668dcb302f08cc9080eadfa (patch) | |
tree | 5aff0c6722bb448287223e9aea9f4787c156b647 /tools | |
parent | 009884f384dcc71909f2b861c317da7242979f31 (diff) | |
parent | ae7858180510d6fd0dfaf66d209bc6103db1678f (diff) |
Merge tag 'linux-kselftest-4.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest fixes from Shuah Khan:
"This update contains 7 fixes for problems ranging from build failurs
to incorrect error reporting"
* tag 'linux-kselftest-4.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests: exec: revert to default emit rule
selftests: change install command to rsync
selftests: mqueue: simplify the Makefile
selftests: mqueue: allow extra cflags
selftests: rename jump label to static_keys
selftests/seccomp: add support for s390
seltests/zram: fix syntax error
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/Makefile | 2 | ||||
-rw-r--r-- | tools/testing/selftests/exec/Makefile | 4 | ||||
-rw-r--r-- | tools/testing/selftests/ftrace/Makefile | 2 | ||||
-rw-r--r-- | tools/testing/selftests/lib.mk | 11 | ||||
-rw-r--r-- | tools/testing/selftests/mqueue/Makefile | 10 | ||||
-rw-r--r-- | tools/testing/selftests/seccomp/seccomp_bpf.c | 37 | ||||
-rw-r--r-- | tools/testing/selftests/seccomp/test_harness.h | 7 | ||||
-rwxr-xr-x | tools/testing/selftests/zram/zram.sh | 10 | ||||
-rwxr-xr-x | tools/testing/selftests/zram/zram_lib.sh | 3 |
9 files changed, 52 insertions, 34 deletions
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 89b05e2222c9..cfe121353eec 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -16,12 +16,12 @@ TARGETS += powerpc | |||
16 | TARGETS += ptrace | 16 | TARGETS += ptrace |
17 | TARGETS += seccomp | 17 | TARGETS += seccomp |
18 | TARGETS += size | 18 | TARGETS += size |
19 | TARGETS += static_keys | ||
19 | TARGETS += sysctl | 20 | TARGETS += sysctl |
20 | ifneq (1, $(quicktest)) | 21 | ifneq (1, $(quicktest)) |
21 | TARGETS += timers | 22 | TARGETS += timers |
22 | endif | 23 | endif |
23 | TARGETS += user | 24 | TARGETS += user |
24 | TARGETS += jumplabel | ||
25 | TARGETS += vm | 25 | TARGETS += vm |
26 | TARGETS += x86 | 26 | TARGETS += x86 |
27 | TARGETS += zram | 27 | TARGETS += zram |
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile index 6b76bfdc847e..4e400eb83657 100644 --- a/tools/testing/selftests/exec/Makefile +++ b/tools/testing/selftests/exec/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | CFLAGS = -Wall | 1 | CFLAGS = -Wall |
2 | BINARIES = execveat | 2 | BINARIES = execveat |
3 | DEPS = execveat.symlink execveat.denatured script | 3 | DEPS = execveat.symlink execveat.denatured script subdir |
4 | all: $(BINARIES) $(DEPS) | 4 | all: $(BINARIES) $(DEPS) |
5 | 5 | ||
6 | subdir: | 6 | subdir: |
@@ -22,7 +22,5 @@ TEST_FILES := $(DEPS) | |||
22 | 22 | ||
23 | include ../lib.mk | 23 | include ../lib.mk |
24 | 24 | ||
25 | override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\"" | ||
26 | |||
27 | clean: | 25 | clean: |
28 | rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* | 26 | rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* |
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile index 0acbeca47225..4e6ed13e7f66 100644 --- a/tools/testing/selftests/ftrace/Makefile +++ b/tools/testing/selftests/ftrace/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | all: | 1 | all: |
2 | 2 | ||
3 | TEST_PROGS := ftracetest | 3 | TEST_PROGS := ftracetest |
4 | TEST_DIRS := test.d/ | 4 | TEST_DIRS := test.d |
5 | 5 | ||
6 | include ../lib.mk | 6 | include ../lib.mk |
7 | 7 | ||
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 97f1c6742066..50a93f5f13d6 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk | |||
@@ -12,13 +12,10 @@ run_tests: all | |||
12 | $(RUN_TESTS) | 12 | $(RUN_TESTS) |
13 | 13 | ||
14 | define INSTALL_RULE | 14 | define INSTALL_RULE |
15 | @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ | 15 | @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ |
16 | mkdir -p $(INSTALL_PATH); \ | 16 | mkdir -p ${INSTALL_PATH}; \ |
17 | for TEST_DIR in $(TEST_DIRS); do \ | 17 | echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \ |
18 | cp -r $$TEST_DIR $(INSTALL_PATH); \ | 18 | rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \ |
19 | done; \ | ||
20 | echo "install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)"; \ | ||
21 | install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES); \ | ||
22 | fi | 19 | fi |
23 | endef | 20 | endef |
24 | 21 | ||
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile index 0e3b41eb85cd..eebac29acbd9 100644 --- a/tools/testing/selftests/mqueue/Makefile +++ b/tools/testing/selftests/mqueue/Makefile | |||
@@ -1,8 +1,8 @@ | |||
1 | CFLAGS = -O2 | 1 | CFLAGS += -O2 |
2 | LDLIBS = -lrt -lpthread -lpopt | ||
3 | TEST_PROGS := mq_open_tests mq_perf_tests | ||
2 | 4 | ||
3 | all: | 5 | all: $(TEST_PROGS) |
4 | $(CC) $(CFLAGS) mq_open_tests.c -o mq_open_tests -lrt | ||
5 | $(CC) $(CFLAGS) -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt | ||
6 | 6 | ||
7 | include ../lib.mk | 7 | include ../lib.mk |
8 | 8 | ||
@@ -11,8 +11,6 @@ override define RUN_TESTS | |||
11 | @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" | 11 | @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" |
12 | endef | 12 | endef |
13 | 13 | ||
14 | TEST_PROGS := mq_open_tests mq_perf_tests | ||
15 | |||
16 | override define EMIT_TESTS | 14 | override define EMIT_TESTS |
17 | echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\"" | 15 | echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\"" |
18 | echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\"" | 16 | echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\"" |
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index a004b4cce99e..770f47adf295 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c | |||
@@ -1210,6 +1210,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) | |||
1210 | # define ARCH_REGS struct pt_regs | 1210 | # define ARCH_REGS struct pt_regs |
1211 | # define SYSCALL_NUM gpr[0] | 1211 | # define SYSCALL_NUM gpr[0] |
1212 | # define SYSCALL_RET gpr[3] | 1212 | # define SYSCALL_RET gpr[3] |
1213 | #elif defined(__s390__) | ||
1214 | # define ARCH_REGS s390_regs | ||
1215 | # define SYSCALL_NUM gprs[2] | ||
1216 | # define SYSCALL_RET gprs[2] | ||
1213 | #else | 1217 | #else |
1214 | # error "Do not know how to find your architecture's registers and syscalls" | 1218 | # error "Do not know how to find your architecture's registers and syscalls" |
1215 | #endif | 1219 | #endif |
@@ -1243,7 +1247,8 @@ void change_syscall(struct __test_metadata *_metadata, | |||
1243 | ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); | 1247 | ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); |
1244 | EXPECT_EQ(0, ret); | 1248 | EXPECT_EQ(0, ret); |
1245 | 1249 | ||
1246 | #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__) | 1250 | #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \ |
1251 | defined(__powerpc__) || defined(__s390__) | ||
1247 | { | 1252 | { |
1248 | regs.SYSCALL_NUM = syscall; | 1253 | regs.SYSCALL_NUM = syscall; |
1249 | } | 1254 | } |
@@ -1281,17 +1286,21 @@ void tracer_syscall(struct __test_metadata *_metadata, pid_t tracee, | |||
1281 | ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg); | 1286 | ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg); |
1282 | EXPECT_EQ(0, ret); | 1287 | EXPECT_EQ(0, ret); |
1283 | 1288 | ||
1289 | /* Validate and take action on expected syscalls. */ | ||
1284 | switch (msg) { | 1290 | switch (msg) { |
1285 | case 0x1002: | 1291 | case 0x1002: |
1286 | /* change getpid to getppid. */ | 1292 | /* change getpid to getppid. */ |
1293 | EXPECT_EQ(__NR_getpid, get_syscall(_metadata, tracee)); | ||
1287 | change_syscall(_metadata, tracee, __NR_getppid); | 1294 | change_syscall(_metadata, tracee, __NR_getppid); |
1288 | break; | 1295 | break; |
1289 | case 0x1003: | 1296 | case 0x1003: |
1290 | /* skip gettid. */ | 1297 | /* skip gettid. */ |
1298 | EXPECT_EQ(__NR_gettid, get_syscall(_metadata, tracee)); | ||
1291 | change_syscall(_metadata, tracee, -1); | 1299 | change_syscall(_metadata, tracee, -1); |
1292 | break; | 1300 | break; |
1293 | case 0x1004: | 1301 | case 0x1004: |
1294 | /* do nothing (allow getppid) */ | 1302 | /* do nothing (allow getppid) */ |
1303 | EXPECT_EQ(__NR_getppid, get_syscall(_metadata, tracee)); | ||
1295 | break; | 1304 | break; |
1296 | default: | 1305 | default: |
1297 | EXPECT_EQ(0, msg) { | 1306 | EXPECT_EQ(0, msg) { |
@@ -1409,6 +1418,8 @@ TEST_F(TRACE_syscall, syscall_dropped) | |||
1409 | # define __NR_seccomp 277 | 1418 | # define __NR_seccomp 277 |
1410 | # elif defined(__powerpc__) | 1419 | # elif defined(__powerpc__) |
1411 | # define __NR_seccomp 358 | 1420 | # define __NR_seccomp 358 |
1421 | # elif defined(__s390__) | ||
1422 | # define __NR_seccomp 348 | ||
1412 | # else | 1423 | # else |
1413 | # warning "seccomp syscall number unknown for this architecture" | 1424 | # warning "seccomp syscall number unknown for this architecture" |
1414 | # define __NR_seccomp 0xffff | 1425 | # define __NR_seccomp 0xffff |
@@ -1453,6 +1464,9 @@ TEST(seccomp_syscall) | |||
1453 | 1464 | ||
1454 | /* Reject insane operation. */ | 1465 | /* Reject insane operation. */ |
1455 | ret = seccomp(-1, 0, &prog); | 1466 | ret = seccomp(-1, 0, &prog); |
1467 | ASSERT_NE(ENOSYS, errno) { | ||
1468 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1469 | } | ||
1456 | EXPECT_EQ(EINVAL, errno) { | 1470 | EXPECT_EQ(EINVAL, errno) { |
1457 | TH_LOG("Did not reject crazy op value!"); | 1471 | TH_LOG("Did not reject crazy op value!"); |
1458 | } | 1472 | } |
@@ -1501,6 +1515,9 @@ TEST(seccomp_syscall_mode_lock) | |||
1501 | } | 1515 | } |
1502 | 1516 | ||
1503 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); | 1517 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); |
1518 | ASSERT_NE(ENOSYS, errno) { | ||
1519 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1520 | } | ||
1504 | EXPECT_EQ(0, ret) { | 1521 | EXPECT_EQ(0, ret) { |
1505 | TH_LOG("Could not install filter!"); | 1522 | TH_LOG("Could not install filter!"); |
1506 | } | 1523 | } |
@@ -1535,6 +1552,9 @@ TEST(TSYNC_first) | |||
1535 | 1552 | ||
1536 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, | 1553 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, |
1537 | &prog); | 1554 | &prog); |
1555 | ASSERT_NE(ENOSYS, errno) { | ||
1556 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1557 | } | ||
1538 | EXPECT_EQ(0, ret) { | 1558 | EXPECT_EQ(0, ret) { |
1539 | TH_LOG("Could not install initial filter with TSYNC!"); | 1559 | TH_LOG("Could not install initial filter with TSYNC!"); |
1540 | } | 1560 | } |
@@ -1694,6 +1714,9 @@ TEST_F(TSYNC, siblings_fail_prctl) | |||
1694 | 1714 | ||
1695 | /* Check prctl failure detection by requesting sib 0 diverge. */ | 1715 | /* Check prctl failure detection by requesting sib 0 diverge. */ |
1696 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); | 1716 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); |
1717 | ASSERT_NE(ENOSYS, errno) { | ||
1718 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1719 | } | ||
1697 | ASSERT_EQ(0, ret) { | 1720 | ASSERT_EQ(0, ret) { |
1698 | TH_LOG("setting filter failed"); | 1721 | TH_LOG("setting filter failed"); |
1699 | } | 1722 | } |
@@ -1731,6 +1754,9 @@ TEST_F(TSYNC, two_siblings_with_ancestor) | |||
1731 | } | 1754 | } |
1732 | 1755 | ||
1733 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); | 1756 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
1757 | ASSERT_NE(ENOSYS, errno) { | ||
1758 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1759 | } | ||
1734 | ASSERT_EQ(0, ret) { | 1760 | ASSERT_EQ(0, ret) { |
1735 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); | 1761 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
1736 | } | 1762 | } |
@@ -1805,6 +1831,9 @@ TEST_F(TSYNC, two_siblings_with_no_filter) | |||
1805 | 1831 | ||
1806 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, | 1832 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, |
1807 | &self->apply_prog); | 1833 | &self->apply_prog); |
1834 | ASSERT_NE(ENOSYS, errno) { | ||
1835 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1836 | } | ||
1808 | ASSERT_EQ(0, ret) { | 1837 | ASSERT_EQ(0, ret) { |
1809 | TH_LOG("Could install filter on all threads!"); | 1838 | TH_LOG("Could install filter on all threads!"); |
1810 | } | 1839 | } |
@@ -1833,6 +1862,9 @@ TEST_F(TSYNC, two_siblings_with_one_divergence) | |||
1833 | } | 1862 | } |
1834 | 1863 | ||
1835 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); | 1864 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
1865 | ASSERT_NE(ENOSYS, errno) { | ||
1866 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1867 | } | ||
1836 | ASSERT_EQ(0, ret) { | 1868 | ASSERT_EQ(0, ret) { |
1837 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); | 1869 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
1838 | } | 1870 | } |
@@ -1890,6 +1922,9 @@ TEST_F(TSYNC, two_siblings_not_under_filter) | |||
1890 | } | 1922 | } |
1891 | 1923 | ||
1892 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); | 1924 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
1925 | ASSERT_NE(ENOSYS, errno) { | ||
1926 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1927 | } | ||
1893 | ASSERT_EQ(0, ret) { | 1928 | ASSERT_EQ(0, ret) { |
1894 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); | 1929 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
1895 | } | 1930 | } |
diff --git a/tools/testing/selftests/seccomp/test_harness.h b/tools/testing/selftests/seccomp/test_harness.h index 977a6afc4489..fb2841601f2f 100644 --- a/tools/testing/selftests/seccomp/test_harness.h +++ b/tools/testing/selftests/seccomp/test_harness.h | |||
@@ -370,11 +370,8 @@ | |||
370 | __typeof__(_expected) __exp = (_expected); \ | 370 | __typeof__(_expected) __exp = (_expected); \ |
371 | __typeof__(_seen) __seen = (_seen); \ | 371 | __typeof__(_seen) __seen = (_seen); \ |
372 | if (!(__exp _t __seen)) { \ | 372 | if (!(__exp _t __seen)) { \ |
373 | unsigned long long __exp_print = 0; \ | 373 | unsigned long long __exp_print = (unsigned long long)__exp; \ |
374 | unsigned long long __seen_print = 0; \ | 374 | unsigned long long __seen_print = (unsigned long long)__seen; \ |
375 | /* Avoid casting complaints the scariest way we can. */ \ | ||
376 | memcpy(&__exp_print, &__exp, sizeof(__exp)); \ | ||
377 | memcpy(&__seen_print, &__seen, sizeof(__seen)); \ | ||
378 | __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ | 375 | __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ |
379 | #_expected, __exp_print, #_t, \ | 376 | #_expected, __exp_print, #_t, \ |
380 | #_seen, __seen_print); \ | 377 | #_seen, __seen_print); \ |
diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh index 20de9a761269..683a292e3290 100755 --- a/tools/testing/selftests/zram/zram.sh +++ b/tools/testing/selftests/zram/zram.sh | |||
@@ -1,15 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | TCID="zram.sh" | 2 | TCID="zram.sh" |
3 | 3 | ||
4 | check_prereqs() | 4 | . ./zram_lib.sh |
5 | { | ||
6 | local msg="skip all tests:" | ||
7 | |||
8 | if [ $UID != 0 ]; then | ||
9 | echo $msg must be run as root >&2 | ||
10 | exit 0 | ||
11 | fi | ||
12 | } | ||
13 | 5 | ||
14 | run_zram () { | 6 | run_zram () { |
15 | echo "--------------------" | 7 | echo "--------------------" |
diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh index 424e68ed1487..f6a9c73e7a44 100755 --- a/tools/testing/selftests/zram/zram_lib.sh +++ b/tools/testing/selftests/zram/zram_lib.sh | |||
@@ -23,8 +23,9 @@ trap INT | |||
23 | check_prereqs() | 23 | check_prereqs() |
24 | { | 24 | { |
25 | local msg="skip all tests:" | 25 | local msg="skip all tests:" |
26 | local uid=$(id -u) | ||
26 | 27 | ||
27 | if [ $UID != 0 ]; then | 28 | if [ $uid -ne 0 ]; then |
28 | echo $msg must be run as root >&2 | 29 | echo $msg must be run as root >&2 |
29 | exit 0 | 30 | exit 0 |
30 | fi | 31 | fi |