History

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

Linus Torvalds committed 11 years ago

Commit 30ec5682 parents 009884f ae785819 files · +52 −34Browse files

Unified · Split

9 files
  1. tools/testing/selftests/Makefile +1 −1
  2. tools/testing/selftests/exec/Makefile +1 −3
  3. tools/testing/selftests/ftrace/Makefile +1 −1
  4. tools/testing/selftests/lib.mk +4 −7
  5. tools/testing/selftests/mqueue/Makefile +4 −6
  6. tools/testing/selftests/seccomp/seccomp_bpf.c +36 −1
  7. tools/testing/selftests/seccomp/test_harness.h +2 −5
  8. tools/testing/selftests/zram/zram.sh +1 −9
  9. tools/testing/selftests/zram/zram_lib.sh +2 −1
tools/testing/selftests/Makefile+1−1
@@ -16,12 +16,12 @@ TARGETS += powerpc · 15 unmodified lines
16TARGETS += ptrace16TARGETS += ptrace
17TARGETS += seccomp17TARGETS += seccomp
18TARGETS += size18TARGETS += size
19TARGETS += static_keys
19TARGETS += sysctl20TARGETS += sysctl
20ifneq (1, $(quicktest))21ifneq (1, $(quicktest))
21TARGETS += timers22TARGETS += timers
22endif23endif
23TARGETS += user24TARGETS += user
24TARGETS += jumplabel
25TARGETS += vm25TARGETS += vm
26TARGETS += x8626TARGETS += x86
27TARGETS += zram27TARGETS += zram
tools/testing/selftests/exec/Makefile+1−3
@@ -1,6 +1,6 @@
1CFLAGS = -Wall1CFLAGS = -Wall
2BINARIES = execveat2BINARIES = execveat
3DEPS = execveat.symlink execveat.denatured script3DEPS = execveat.symlink execveat.denatured script subdir
4all: $(BINARIES) $(DEPS)4all: $(BINARIES) $(DEPS)
5 5
6subdir:6subdir:
@@ -22,7 +22,5 @@ TEST_FILES := $(DEPS) · 15 unmodified lines
22 22
23include ../lib.mk23include ../lib.mk
24 24
25override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
26
27clean:25clean:
28 rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*26 rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
tools/testing/selftests/ftrace/Makefile+1−1
@@ -1,7 +1,7 @@
1all:1all:
2 2
3TEST_PROGS := ftracetest3TEST_PROGS := ftracetest
4TEST_DIRS := test.d/4TEST_DIRS := test.d
5 5
6include ../lib.mk6include ../lib.mk
7 7
tools/testing/selftests/lib.mk+4−7
@@ -12,13 +12,10 @@ run_tests: all · 11 unmodified lines
12 $(RUN_TESTS)12 $(RUN_TESTS)
13 13
14define INSTALL_RULE14define 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 fi19 fi
23endef20endef
24 21
tools/testing/selftests/mqueue/Makefile+4−6
@@ -1,8 +1,8 @@
1CFLAGS = -O21CFLAGS += -O2
2LDLIBS = -lrt -lpthread -lpopt
3TEST_PROGS := mq_open_tests mq_perf_tests
2 4
3all:5all: $(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
7include ../lib.mk7include ../lib.mk
8 8
@@ -11,8 +11,6 @@ override define RUN_TESTS · 2 unmodified lines
11 @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"11 @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
12endef12endef
13 13
14TEST_PROGS := mq_open_tests mq_perf_tests
15
16override define EMIT_TESTS14override 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]\""
tools/testing/selftests/seccomp/seccomp_bpf.c+36−1
@@ -1210,6 +1210,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) · 1209 unmodified lines
1210# define ARCH_REGS struct pt_regs1210# 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#else1217#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#endif1219#endif
@@ -1243,7 +1247,8 @@ void change_syscall(struct __test_metadata *_metadata, · 27 unmodified lines
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, · 31 unmodified lines
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) · 111 unmodified lines
1409# define __NR_seccomp 2771418# define __NR_seccomp 277
1410# elif defined(__powerpc__)1419# elif defined(__powerpc__)
1411# define __NR_seccomp 3581420# define __NR_seccomp 358
1421# elif defined(__s390__)
1422# define __NR_seccomp 348
1412# else1423# else
1413# warning "seccomp syscall number unknown for this architecture"1424# warning "seccomp syscall number unknown for this architecture"
1414# define __NR_seccomp 0xffff1425# define __NR_seccomp 0xffff
@@ -1453,6 +1464,9 @@ TEST(seccomp_syscall) · 38 unmodified lines
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) · 42 unmodified lines
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) · 28 unmodified lines
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) · 153 unmodified lines
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) · 31 unmodified lines
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) · 68 unmodified lines
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) · 22 unmodified lines
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) · 51 unmodified lines
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 }
tools/testing/selftests/seccomp/test_harness.h+2−5
@@ -370,11 +370,8 @@ · 369 unmodified lines
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); \
tools/testing/selftests/zram/zram.sh+1−9
@@ -1,15 +1,7 @@
1#!/bin/bash1#!/bin/bash
2TCID="zram.sh"2TCID="zram.sh"
3 3
4check_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
14run_zram () {6run_zram () {
15echo "--------------------"7echo "--------------------"
tools/testing/selftests/zram/zram_lib.sh+2−1
@@ -23,8 +23,9 @@ trap INT · 22 unmodified lines
23check_prereqs()23check_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 ]; then28 if [ $uid -ne 0 ]; then
28 echo $msg must be run as root >&229 echo $msg must be run as root >&2
29 exit 030 exit 0
30 fi31 fi

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t