diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-22 20:02:14 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-22 20:02:14 -0500 |
| commit | 8f45fa2724a67f660a3b089950cb51eb9fef63d1 (patch) | |
| tree | 61724f3728315a433b5272ec878af8572878e65d | |
| parent | 787a3b4322763284a594a5dd3680508c0bfb20b0 (diff) | |
| parent | 3d244c192afeee7dd4f5fb1b916ea4e47420d401 (diff) | |
Merge tag 'linux-kselftest-5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest fixes from Shuah Khan:
"Fixes to rtc, seccomp and other tests"
* tag 'linux-kselftest-5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests/seccomp: Abort without user notification support
selftests: gpio-mockup-chardev: Check asprintf() for error
selftests: seccomp: use LDLIBS instead of LDFLAGS
selftests/vm/gup_benchmark.c: match gup struct to kernel
tools/testing/selftests/x86/unwind_vdso.c: Remove duplicate header
x86/mpx/selftests: fix spelling mistake "succeded" -> "succeeded"
selftests: rtc: rtctest: add alarm test on minute boundary
selftests: rtc: rtctest: fix alarm tests
| -rw-r--r-- | tools/testing/selftests/gpio/gpio-mockup-chardev.c | 9 | ||||
| -rw-r--r-- | tools/testing/selftests/rtc/rtctest.c | 109 | ||||
| -rw-r--r-- | tools/testing/selftests/seccomp/Makefile | 2 | ||||
| -rw-r--r-- | tools/testing/selftests/seccomp/seccomp_bpf.c | 10 | ||||
| -rw-r--r-- | tools/testing/selftests/vm/gup_benchmark.c | 1 | ||||
| -rw-r--r-- | tools/testing/selftests/x86/mpx-mini-test.c | 2 | ||||
| -rw-r--r-- | tools/testing/selftests/x86/unwind_vdso.c | 1 |
7 files changed, 118 insertions, 16 deletions
diff --git a/tools/testing/selftests/gpio/gpio-mockup-chardev.c b/tools/testing/selftests/gpio/gpio-mockup-chardev.c index f8d468f54e98..aaa1e9f083c3 100644 --- a/tools/testing/selftests/gpio/gpio-mockup-chardev.c +++ b/tools/testing/selftests/gpio/gpio-mockup-chardev.c | |||
| @@ -37,7 +37,7 @@ static int get_debugfs(char **path) | |||
| 37 | struct libmnt_table *tb; | 37 | struct libmnt_table *tb; |
| 38 | struct libmnt_iter *itr = NULL; | 38 | struct libmnt_iter *itr = NULL; |
| 39 | struct libmnt_fs *fs; | 39 | struct libmnt_fs *fs; |
| 40 | int found = 0; | 40 | int found = 0, ret; |
| 41 | 41 | ||
| 42 | cxt = mnt_new_context(); | 42 | cxt = mnt_new_context(); |
| 43 | if (!cxt) | 43 | if (!cxt) |
| @@ -58,8 +58,11 @@ static int get_debugfs(char **path) | |||
| 58 | break; | 58 | break; |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | if (found) | 61 | if (found) { |
| 62 | asprintf(path, "%s/gpio", mnt_fs_get_target(fs)); | 62 | ret = asprintf(path, "%s/gpio", mnt_fs_get_target(fs)); |
| 63 | if (ret < 0) | ||
| 64 | err(EXIT_FAILURE, "failed to format string"); | ||
| 65 | } | ||
| 63 | 66 | ||
| 64 | mnt_free_iter(itr); | 67 | mnt_free_iter(itr); |
| 65 | mnt_free_context(cxt); | 68 | mnt_free_context(cxt); |
diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c index e20b017e7073..b2065536d407 100644 --- a/tools/testing/selftests/rtc/rtctest.c +++ b/tools/testing/selftests/rtc/rtctest.c | |||
| @@ -145,15 +145,12 @@ TEST_F(rtc, alarm_alm_set) { | |||
| 145 | 145 | ||
| 146 | rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); | 146 | rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); |
| 147 | ASSERT_NE(-1, rc); | 147 | ASSERT_NE(-1, rc); |
| 148 | EXPECT_NE(0, rc); | 148 | ASSERT_NE(0, rc); |
| 149 | 149 | ||
| 150 | /* Disable alarm interrupts */ | 150 | /* Disable alarm interrupts */ |
| 151 | rc = ioctl(self->fd, RTC_AIE_OFF, 0); | 151 | rc = ioctl(self->fd, RTC_AIE_OFF, 0); |
| 152 | ASSERT_NE(-1, rc); | 152 | ASSERT_NE(-1, rc); |
| 153 | 153 | ||
| 154 | if (rc == 0) | ||
| 155 | return; | ||
| 156 | |||
| 157 | rc = read(self->fd, &data, sizeof(unsigned long)); | 154 | rc = read(self->fd, &data, sizeof(unsigned long)); |
| 158 | ASSERT_NE(-1, rc); | 155 | ASSERT_NE(-1, rc); |
| 159 | TH_LOG("data: %lx", data); | 156 | TH_LOG("data: %lx", data); |
| @@ -202,7 +199,109 @@ TEST_F(rtc, alarm_wkalm_set) { | |||
| 202 | 199 | ||
| 203 | rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); | 200 | rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); |
| 204 | ASSERT_NE(-1, rc); | 201 | ASSERT_NE(-1, rc); |
| 205 | EXPECT_NE(0, rc); | 202 | ASSERT_NE(0, rc); |
| 203 | |||
| 204 | rc = read(self->fd, &data, sizeof(unsigned long)); | ||
| 205 | ASSERT_NE(-1, rc); | ||
| 206 | |||
| 207 | rc = ioctl(self->fd, RTC_RD_TIME, &tm); | ||
| 208 | ASSERT_NE(-1, rc); | ||
| 209 | |||
| 210 | new = timegm((struct tm *)&tm); | ||
| 211 | ASSERT_EQ(new, secs); | ||
| 212 | } | ||
| 213 | |||
| 214 | TEST_F(rtc, alarm_alm_set_minute) { | ||
| 215 | struct timeval tv = { .tv_sec = 62 }; | ||
| 216 | unsigned long data; | ||
| 217 | struct rtc_time tm; | ||
| 218 | fd_set readfds; | ||
| 219 | time_t secs, new; | ||
| 220 | int rc; | ||
| 221 | |||
| 222 | rc = ioctl(self->fd, RTC_RD_TIME, &tm); | ||
| 223 | ASSERT_NE(-1, rc); | ||
| 224 | |||
| 225 | secs = timegm((struct tm *)&tm) + 60 - tm.tm_sec; | ||
| 226 | gmtime_r(&secs, (struct tm *)&tm); | ||
| 227 | |||
| 228 | rc = ioctl(self->fd, RTC_ALM_SET, &tm); | ||
| 229 | if (rc == -1) { | ||
| 230 | ASSERT_EQ(EINVAL, errno); | ||
| 231 | TH_LOG("skip alarms are not supported."); | ||
| 232 | return; | ||
| 233 | } | ||
| 234 | |||
| 235 | rc = ioctl(self->fd, RTC_ALM_READ, &tm); | ||
| 236 | ASSERT_NE(-1, rc); | ||
| 237 | |||
| 238 | TH_LOG("Alarm time now set to %02d:%02d:%02d.", | ||
| 239 | tm.tm_hour, tm.tm_min, tm.tm_sec); | ||
| 240 | |||
| 241 | /* Enable alarm interrupts */ | ||
| 242 | rc = ioctl(self->fd, RTC_AIE_ON, 0); | ||
| 243 | ASSERT_NE(-1, rc); | ||
| 244 | |||
| 245 | FD_ZERO(&readfds); | ||
| 246 | FD_SET(self->fd, &readfds); | ||
| 247 | |||
| 248 | rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); | ||
| 249 | ASSERT_NE(-1, rc); | ||
| 250 | ASSERT_NE(0, rc); | ||
| 251 | |||
| 252 | /* Disable alarm interrupts */ | ||
| 253 | rc = ioctl(self->fd, RTC_AIE_OFF, 0); | ||
| 254 | ASSERT_NE(-1, rc); | ||
| 255 | |||
| 256 | rc = read(self->fd, &data, sizeof(unsigned long)); | ||
| 257 | ASSERT_NE(-1, rc); | ||
| 258 | TH_LOG("data: %lx", data); | ||
| 259 | |||
| 260 | rc = ioctl(self->fd, RTC_RD_TIME, &tm); | ||
| 261 | ASSERT_NE(-1, rc); | ||
| 262 | |||
| 263 | new = timegm((struct tm *)&tm); | ||
| 264 | ASSERT_EQ(new, secs); | ||
| 265 | } | ||
| 266 | |||
| 267 | TEST_F(rtc, alarm_wkalm_set_minute) { | ||
| 268 | struct timeval tv = { .tv_sec = 62 }; | ||
| 269 | struct rtc_wkalrm alarm = { 0 }; | ||
| 270 | struct rtc_time tm; | ||
| 271 | unsigned long data; | ||
| 272 | fd_set readfds; | ||
| 273 | time_t secs, new; | ||
| 274 | int rc; | ||
| 275 | |||
| 276 | rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time); | ||
| 277 | ASSERT_NE(-1, rc); | ||
| 278 | |||
| 279 | secs = timegm((struct tm *)&alarm.time) + 60 - alarm.time.tm_sec; | ||
| 280 | gmtime_r(&secs, (struct tm *)&alarm.time); | ||
| 281 | |||
| 282 | alarm.enabled = 1; | ||
| 283 | |||
| 284 | rc = ioctl(self->fd, RTC_WKALM_SET, &alarm); | ||
| 285 | if (rc == -1) { | ||
| 286 | ASSERT_EQ(EINVAL, errno); | ||
| 287 | TH_LOG("skip alarms are not supported."); | ||
| 288 | return; | ||
| 289 | } | ||
| 290 | |||
| 291 | rc = ioctl(self->fd, RTC_WKALM_RD, &alarm); | ||
| 292 | ASSERT_NE(-1, rc); | ||
| 293 | |||
| 294 | TH_LOG("Alarm time now set to %02d/%02d/%02d %02d:%02d:%02d.", | ||
| 295 | alarm.time.tm_mday, alarm.time.tm_mon + 1, | ||
| 296 | alarm.time.tm_year + 1900, alarm.time.tm_hour, | ||
| 297 | alarm.time.tm_min, alarm.time.tm_sec); | ||
| 298 | |||
| 299 | FD_ZERO(&readfds); | ||
| 300 | FD_SET(self->fd, &readfds); | ||
| 301 | |||
| 302 | rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); | ||
| 303 | ASSERT_NE(-1, rc); | ||
| 304 | ASSERT_NE(0, rc); | ||
| 206 | 305 | ||
| 207 | rc = read(self->fd, &data, sizeof(unsigned long)); | 306 | rc = read(self->fd, &data, sizeof(unsigned long)); |
| 208 | ASSERT_NE(-1, rc); | 307 | ASSERT_NE(-1, rc); |
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index fce7f4ce0692..1760b3e39730 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile | |||
| @@ -9,7 +9,7 @@ BINARIES := seccomp_bpf seccomp_benchmark | |||
| 9 | CFLAGS += -Wl,-no-as-needed -Wall | 9 | CFLAGS += -Wl,-no-as-needed -Wall |
| 10 | 10 | ||
| 11 | seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h | 11 | seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h |
| 12 | $(CC) $(CFLAGS) $(LDFLAGS) -lpthread $< -o $@ | 12 | $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@ |
| 13 | 13 | ||
| 14 | TEST_PROGS += $(BINARIES) | 14 | TEST_PROGS += $(BINARIES) |
| 15 | EXTRA_CLEAN := $(BINARIES) | 15 | EXTRA_CLEAN := $(BINARIES) |
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 067cb4607d6c..496a9a8c773a 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c | |||
| @@ -3044,7 +3044,7 @@ TEST(user_notification_basic) | |||
| 3044 | /* Check that the basic notification machinery works */ | 3044 | /* Check that the basic notification machinery works */ |
| 3045 | listener = user_trap_syscall(__NR_getpid, | 3045 | listener = user_trap_syscall(__NR_getpid, |
| 3046 | SECCOMP_FILTER_FLAG_NEW_LISTENER); | 3046 | SECCOMP_FILTER_FLAG_NEW_LISTENER); |
| 3047 | EXPECT_GE(listener, 0); | 3047 | ASSERT_GE(listener, 0); |
| 3048 | 3048 | ||
| 3049 | /* Installing a second listener in the chain should EBUSY */ | 3049 | /* Installing a second listener in the chain should EBUSY */ |
| 3050 | EXPECT_EQ(user_trap_syscall(__NR_getpid, | 3050 | EXPECT_EQ(user_trap_syscall(__NR_getpid, |
| @@ -3103,7 +3103,7 @@ TEST(user_notification_kill_in_middle) | |||
| 3103 | 3103 | ||
| 3104 | listener = user_trap_syscall(__NR_getpid, | 3104 | listener = user_trap_syscall(__NR_getpid, |
| 3105 | SECCOMP_FILTER_FLAG_NEW_LISTENER); | 3105 | SECCOMP_FILTER_FLAG_NEW_LISTENER); |
| 3106 | EXPECT_GE(listener, 0); | 3106 | ASSERT_GE(listener, 0); |
| 3107 | 3107 | ||
| 3108 | /* | 3108 | /* |
| 3109 | * Check that nothing bad happens when we kill the task in the middle | 3109 | * Check that nothing bad happens when we kill the task in the middle |
| @@ -3152,7 +3152,7 @@ TEST(user_notification_signal) | |||
| 3152 | 3152 | ||
| 3153 | listener = user_trap_syscall(__NR_gettid, | 3153 | listener = user_trap_syscall(__NR_gettid, |
| 3154 | SECCOMP_FILTER_FLAG_NEW_LISTENER); | 3154 | SECCOMP_FILTER_FLAG_NEW_LISTENER); |
| 3155 | EXPECT_GE(listener, 0); | 3155 | ASSERT_GE(listener, 0); |
| 3156 | 3156 | ||
| 3157 | pid = fork(); | 3157 | pid = fork(); |
| 3158 | ASSERT_GE(pid, 0); | 3158 | ASSERT_GE(pid, 0); |
| @@ -3215,7 +3215,7 @@ TEST(user_notification_closed_listener) | |||
| 3215 | 3215 | ||
| 3216 | listener = user_trap_syscall(__NR_getpid, | 3216 | listener = user_trap_syscall(__NR_getpid, |
| 3217 | SECCOMP_FILTER_FLAG_NEW_LISTENER); | 3217 | SECCOMP_FILTER_FLAG_NEW_LISTENER); |
| 3218 | EXPECT_GE(listener, 0); | 3218 | ASSERT_GE(listener, 0); |
| 3219 | 3219 | ||
| 3220 | /* | 3220 | /* |
| 3221 | * Check that we get an ENOSYS when the listener is closed. | 3221 | * Check that we get an ENOSYS when the listener is closed. |
| @@ -3376,7 +3376,7 @@ TEST(seccomp_get_notif_sizes) | |||
| 3376 | { | 3376 | { |
| 3377 | struct seccomp_notif_sizes sizes; | 3377 | struct seccomp_notif_sizes sizes; |
| 3378 | 3378 | ||
| 3379 | EXPECT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0); | 3379 | ASSERT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0); |
| 3380 | EXPECT_EQ(sizes.seccomp_notif, sizeof(struct seccomp_notif)); | 3380 | EXPECT_EQ(sizes.seccomp_notif, sizeof(struct seccomp_notif)); |
| 3381 | EXPECT_EQ(sizes.seccomp_notif_resp, sizeof(struct seccomp_notif_resp)); | 3381 | EXPECT_EQ(sizes.seccomp_notif_resp, sizeof(struct seccomp_notif_resp)); |
| 3382 | } | 3382 | } |
diff --git a/tools/testing/selftests/vm/gup_benchmark.c b/tools/testing/selftests/vm/gup_benchmark.c index 880b96fc80d4..c0534e298b51 100644 --- a/tools/testing/selftests/vm/gup_benchmark.c +++ b/tools/testing/selftests/vm/gup_benchmark.c | |||
| @@ -25,6 +25,7 @@ struct gup_benchmark { | |||
| 25 | __u64 size; | 25 | __u64 size; |
| 26 | __u32 nr_pages_per_call; | 26 | __u32 nr_pages_per_call; |
| 27 | __u32 flags; | 27 | __u32 flags; |
| 28 | __u64 expansion[10]; /* For future use */ | ||
| 28 | }; | 29 | }; |
| 29 | 30 | ||
| 30 | int main(int argc, char **argv) | 31 | int main(int argc, char **argv) |
diff --git a/tools/testing/selftests/x86/mpx-mini-test.c b/tools/testing/selftests/x86/mpx-mini-test.c index 50f7e9272481..bf1bb15b6fbe 100644 --- a/tools/testing/selftests/x86/mpx-mini-test.c +++ b/tools/testing/selftests/x86/mpx-mini-test.c | |||
| @@ -1503,7 +1503,7 @@ exit: | |||
| 1503 | exit(20); | 1503 | exit(20); |
| 1504 | } | 1504 | } |
| 1505 | if (successes != total_nr_tests) { | 1505 | if (successes != total_nr_tests) { |
| 1506 | eprintf("ERROR: succeded fewer than number of tries (%d != %d)\n", | 1506 | eprintf("ERROR: succeeded fewer than number of tries (%d != %d)\n", |
| 1507 | successes, total_nr_tests); | 1507 | successes, total_nr_tests); |
| 1508 | exit(21); | 1508 | exit(21); |
| 1509 | } | 1509 | } |
diff --git a/tools/testing/selftests/x86/unwind_vdso.c b/tools/testing/selftests/x86/unwind_vdso.c index 00a26a82fa98..97311333700e 100644 --- a/tools/testing/selftests/x86/unwind_vdso.c +++ b/tools/testing/selftests/x86/unwind_vdso.c | |||
| @@ -44,7 +44,6 @@ int main() | |||
| 44 | #include <stdbool.h> | 44 | #include <stdbool.h> |
| 45 | #include <sys/ptrace.h> | 45 | #include <sys/ptrace.h> |
| 46 | #include <sys/user.h> | 46 | #include <sys/user.h> |
| 47 | #include <sys/ucontext.h> | ||
| 48 | #include <link.h> | 47 | #include <link.h> |
| 49 | #include <sys/auxv.h> | 48 | #include <sys/auxv.h> |
| 50 | #include <dlfcn.h> | 49 | #include <dlfcn.h> |
