Skip to content
This repository was archived by the owner on Oct 5, 2018. It is now read-only.

Commit 30ec568

Browse files
committed
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
2 parents 009884f + ae78581 commit 30ec568

File tree

9 files changed

+52
-34
lines changed

9 files changed

+52
-34
lines changed

tools/testing/selftests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ TARGETS += powerpc
1616
TARGETS += ptrace
1717
TARGETS += seccomp
1818
TARGETS += size
19+
TARGETS += static_keys
1920
TARGETS += sysctl
2021
ifneq (1, $(quicktest))
2122
TARGETS += timers
2223
endif
2324
TARGETS += user
24-
TARGETS += jumplabel
2525
TARGETS += vm
2626
TARGETS += x86
2727
TARGETS += zram

tools/testing/selftests/exec/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CFLAGS = -Wall
22
BINARIES = execveat
3-
DEPS = execveat.symlink execveat.denatured script
3+
DEPS = execveat.symlink execveat.denatured script subdir
44
all: $(BINARIES) $(DEPS)
55

66
subdir:
@@ -22,7 +22,5 @@ TEST_FILES := $(DEPS)
2222

2323
include ../lib.mk
2424

25-
override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
26-
2725
clean:
2826
rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*

tools/testing/selftests/ftrace/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
all:
22

33
TEST_PROGS := ftracetest
4-
TEST_DIRS := test.d/
4+
TEST_DIRS := test.d
55

66
include ../lib.mk
77

tools/testing/selftests/lib.mk

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ run_tests: all
1212
$(RUN_TESTS)
1313

1414
define INSTALL_RULE
15-
@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
16-
mkdir -p $(INSTALL_PATH); \
17-
for TEST_DIR in $(TEST_DIRS); do \
18-
cp -r $$TEST_DIR $(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); \
15+
@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
16+
mkdir -p ${INSTALL_PATH}; \
17+
echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \
18+
rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \
2219
fi
2320
endef
2421

tools/testing/selftests/mqueue/Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
CFLAGS = -O2
1+
CFLAGS += -O2
2+
LDLIBS = -lrt -lpthread -lpopt
3+
TEST_PROGS := mq_open_tests mq_perf_tests
24

3-
all:
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
5+
all: $(TEST_PROGS)
66

77
include ../lib.mk
88

@@ -11,8 +11,6 @@ override define RUN_TESTS
1111
@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
1212
endef
1313

14-
TEST_PROGS := mq_open_tests mq_perf_tests
15-
1614
override define EMIT_TESTS
1715
echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\""
1816
echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\""

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,10 @@ TEST_F(TRACE_poke, getpid_runs_normally)
12101210
# define ARCH_REGS struct pt_regs
12111211
# define SYSCALL_NUM gpr[0]
12121212
# 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]
12131217
#else
12141218
# error "Do not know how to find your architecture's registers and syscalls"
12151219
#endif
@@ -1243,7 +1247,8 @@ void change_syscall(struct __test_metadata *_metadata,
12431247
ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov);
12441248
EXPECT_EQ(0, ret);
12451249

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__)
12471252
{
12481253
regs.SYSCALL_NUM = syscall;
12491254
}
@@ -1281,17 +1286,21 @@ void tracer_syscall(struct __test_metadata *_metadata, pid_t tracee,
12811286
ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg);
12821287
EXPECT_EQ(0, ret);
12831288

1289+
/* Validate and take action on expected syscalls. */
12841290
switch (msg) {
12851291
case 0x1002:
12861292
/* change getpid to getppid. */
1293+
EXPECT_EQ(__NR_getpid, get_syscall(_metadata, tracee));
12871294
change_syscall(_metadata, tracee, __NR_getppid);
12881295
break;
12891296
case 0x1003:
12901297
/* skip gettid. */
1298+
EXPECT_EQ(__NR_gettid, get_syscall(_metadata, tracee));
12911299
change_syscall(_metadata, tracee, -1);
12921300
break;
12931301
case 0x1004:
12941302
/* do nothing (allow getppid) */
1303+
EXPECT_EQ(__NR_getppid, get_syscall(_metadata, tracee));
12951304
break;
12961305
default:
12971306
EXPECT_EQ(0, msg) {
@@ -1409,6 +1418,8 @@ TEST_F(TRACE_syscall, syscall_dropped)
14091418
# define __NR_seccomp 277
14101419
# elif defined(__powerpc__)
14111420
# define __NR_seccomp 358
1421+
# elif defined(__s390__)
1422+
# define __NR_seccomp 348
14121423
# else
14131424
# warning "seccomp syscall number unknown for this architecture"
14141425
# define __NR_seccomp 0xffff
@@ -1453,6 +1464,9 @@ TEST(seccomp_syscall)
14531464

14541465
/* Reject insane operation. */
14551466
ret = seccomp(-1, 0, &prog);
1467+
ASSERT_NE(ENOSYS, errno) {
1468+
TH_LOG("Kernel does not support seccomp syscall!");
1469+
}
14561470
EXPECT_EQ(EINVAL, errno) {
14571471
TH_LOG("Did not reject crazy op value!");
14581472
}
@@ -1501,6 +1515,9 @@ TEST(seccomp_syscall_mode_lock)
15011515
}
15021516

15031517
ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog);
1518+
ASSERT_NE(ENOSYS, errno) {
1519+
TH_LOG("Kernel does not support seccomp syscall!");
1520+
}
15041521
EXPECT_EQ(0, ret) {
15051522
TH_LOG("Could not install filter!");
15061523
}
@@ -1535,6 +1552,9 @@ TEST(TSYNC_first)
15351552

15361553
ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
15371554
&prog);
1555+
ASSERT_NE(ENOSYS, errno) {
1556+
TH_LOG("Kernel does not support seccomp syscall!");
1557+
}
15381558
EXPECT_EQ(0, ret) {
15391559
TH_LOG("Could not install initial filter with TSYNC!");
15401560
}
@@ -1694,6 +1714,9 @@ TEST_F(TSYNC, siblings_fail_prctl)
16941714

16951715
/* Check prctl failure detection by requesting sib 0 diverge. */
16961716
ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog);
1717+
ASSERT_NE(ENOSYS, errno) {
1718+
TH_LOG("Kernel does not support seccomp syscall!");
1719+
}
16971720
ASSERT_EQ(0, ret) {
16981721
TH_LOG("setting filter failed");
16991722
}
@@ -1731,6 +1754,9 @@ TEST_F(TSYNC, two_siblings_with_ancestor)
17311754
}
17321755

17331756
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+
}
17341760
ASSERT_EQ(0, ret) {
17351761
TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!");
17361762
}
@@ -1805,6 +1831,9 @@ TEST_F(TSYNC, two_siblings_with_no_filter)
18051831

18061832
ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
18071833
&self->apply_prog);
1834+
ASSERT_NE(ENOSYS, errno) {
1835+
TH_LOG("Kernel does not support seccomp syscall!");
1836+
}
18081837
ASSERT_EQ(0, ret) {
18091838
TH_LOG("Could install filter on all threads!");
18101839
}
@@ -1833,6 +1862,9 @@ TEST_F(TSYNC, two_siblings_with_one_divergence)
18331862
}
18341863

18351864
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+
}
18361868
ASSERT_EQ(0, ret) {
18371869
TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!");
18381870
}
@@ -1890,6 +1922,9 @@ TEST_F(TSYNC, two_siblings_not_under_filter)
18901922
}
18911923

18921924
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+
}
18931928
ASSERT_EQ(0, ret) {
18941929
TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!");
18951930
}

tools/testing/selftests/seccomp/test_harness.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,8 @@
370370
__typeof__(_expected) __exp = (_expected); \
371371
__typeof__(_seen) __seen = (_seen); \
372372
if (!(__exp _t __seen)) { \
373-
unsigned long long __exp_print = 0; \
374-
unsigned long long __seen_print = 0; \
375-
/* Avoid casting complaints the scariest way we can. */ \
376-
memcpy(&__exp_print, &__exp, sizeof(__exp)); \
377-
memcpy(&__seen_print, &__seen, sizeof(__seen)); \
373+
unsigned long long __exp_print = (unsigned long long)__exp; \
374+
unsigned long long __seen_print = (unsigned long long)__seen; \
378375
__TH_LOG("Expected %s (%llu) %s %s (%llu)", \
379376
#_expected, __exp_print, #_t, \
380377
#_seen, __seen_print); \

tools/testing/selftests/zram/zram.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
#!/bin/bash
22
TCID="zram.sh"
33

4-
check_prereqs()
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-
}
4+
. ./zram_lib.sh
135

146
run_zram () {
157
echo "--------------------"

tools/testing/selftests/zram/zram_lib.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ trap INT
2323
check_prereqs()
2424
{
2525
local msg="skip all tests:"
26+
local uid=$(id -u)
2627

27-
if [ $UID != 0 ]; then
28+
if [ $uid -ne 0 ]; then
2829
echo $msg must be run as root >&2
2930
exit 0
3031
fi

0 commit comments

Comments
 (0)