diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-15 17:17:32 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-15 17:17:32 -0500 |
| commit | 09dee2a608a4a7d42f021f83084ade7de2415d7e (patch) | |
| tree | 5e5cce54d2f20763e03eaeb07aaac1bffd968f9d | |
| parent | d25b6af91ec600faaff3a7e863f19d3e16593e52 (diff) | |
| parent | 22f6592b23ef8a0c09283bcb13087340721e1154 (diff) | |
Merge tag 'linux-kselftest-4.10-rc1-update' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest updates from Shuah Khan:
"This update consists of:
- new tests to exercise the Sync Kernel Infrastructure. These tests
are part of a battery of Android libsync tests and are re-written
to test the new sync user-space interfaces from Emilio López, and
Gustavo Padovan.
- test to run hw-independent mock tests for i915.ko from Chris Wilson
- a new gpio test case from Bamvor Jian Zhang
- missing gitignore additions"
* tag 'linux-kselftest-4.10-rc1-update' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftest/gpio: add gpio test case
selftest: sync: improve assert() failure message
kselftests: Exercise hw-independent mock tests for i915.ko
selftests: add missing gitignore files/dirs
selftests: add missing set-tz to timers .gitignore
selftest: sync: stress test for merges
selftest: sync: stress consumer/producer test
selftest: sync: stress test for parallelism
selftest: sync: wait tests for sw_sync framework
selftest: sync: merge tests for sw_sync framework
selftest: sync: fence tests for sw_sync framework
selftest: sync: basic tests for sw_sync framework
24 files changed, 1948 insertions, 0 deletions
diff --git a/tools/testing/selftests/.gitignore b/tools/testing/selftests/.gitignore new file mode 100644 index 000000000000..f0600d20ce7d --- /dev/null +++ b/tools/testing/selftests/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| kselftest | |||
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index a3144a3de3a8..71b05891a6a1 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
| @@ -7,6 +7,7 @@ TARGETS += exec | |||
| 7 | TARGETS += firmware | 7 | TARGETS += firmware |
| 8 | TARGETS += ftrace | 8 | TARGETS += ftrace |
| 9 | TARGETS += futex | 9 | TARGETS += futex |
| 10 | TARGETS += gpio | ||
| 10 | TARGETS += ipc | 11 | TARGETS += ipc |
| 11 | TARGETS += kcmp | 12 | TARGETS += kcmp |
| 12 | TARGETS += lib | 13 | TARGETS += lib |
| @@ -24,6 +25,7 @@ TARGETS += seccomp | |||
| 24 | TARGETS += sigaltstack | 25 | TARGETS += sigaltstack |
| 25 | TARGETS += size | 26 | TARGETS += size |
| 26 | TARGETS += static_keys | 27 | TARGETS += static_keys |
| 28 | TARGETS += sync | ||
| 27 | TARGETS += sysctl | 29 | TARGETS += sysctl |
| 28 | ifneq (1, $(quicktest)) | 30 | ifneq (1, $(quicktest)) |
| 29 | TARGETS += timers | 31 | TARGETS += timers |
diff --git a/tools/testing/selftests/drivers/gpu/i915.sh b/tools/testing/selftests/drivers/gpu/i915.sh new file mode 100755 index 000000000000..d407f0fa1e3a --- /dev/null +++ b/tools/testing/selftests/drivers/gpu/i915.sh | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Runs hardware independent tests for i915 (drivers/gpu/drm/i915) | ||
| 3 | |||
| 4 | if ! /sbin/modprobe -q -r i915; then | ||
| 5 | echo "drivers/gpu/i915: [SKIP]" | ||
| 6 | exit 77 | ||
| 7 | fi | ||
| 8 | |||
| 9 | if /sbin/modprobe -q i915 mock_selftests=-1; then | ||
| 10 | echo "drivers/gpu/i915: ok" | ||
| 11 | else | ||
| 12 | echo "drivers/gpu/i915: [FAIL]" | ||
| 13 | exit 1 | ||
| 14 | fi | ||
diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile new file mode 100644 index 000000000000..205e4d10e085 --- /dev/null +++ b/tools/testing/selftests/gpio/Makefile | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | |||
| 2 | TEST_PROGS := gpio-mockup.sh | ||
| 3 | TEST_FILES := gpio-mockup-sysfs.sh $(BINARIES) | ||
| 4 | BINARIES := gpio-mockup-chardev | ||
| 5 | |||
| 6 | include ../lib.mk | ||
| 7 | |||
| 8 | all: $(BINARIES) | ||
| 9 | |||
| 10 | clean: | ||
| 11 | $(RM) $(BINARIES) | ||
| 12 | |||
| 13 | CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ | ||
| 14 | LDLIBS += -lmount -I/usr/include/libmount | ||
| 15 | |||
| 16 | $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h | ||
| 17 | |||
| 18 | ../../../gpio/gpio-utils.o: | ||
| 19 | make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio | ||
| 20 | |||
| 21 | ../../../../usr/include/linux/gpio.h: | ||
| 22 | make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ | ||
| 23 | |||
diff --git a/tools/testing/selftests/gpio/gpio-mockup-chardev.c b/tools/testing/selftests/gpio/gpio-mockup-chardev.c new file mode 100644 index 000000000000..667e916fa7cc --- /dev/null +++ b/tools/testing/selftests/gpio/gpio-mockup-chardev.c | |||
| @@ -0,0 +1,324 @@ | |||
| 1 | /* | ||
| 2 | * GPIO chardev test helper | ||
| 3 | * | ||
| 4 | * Copyright (C) 2016 Bamvor Jian Zhang | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License version 2 as published by | ||
| 8 | * the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #define _GNU_SOURCE | ||
| 12 | #include <unistd.h> | ||
| 13 | #include <stdio.h> | ||
| 14 | #include <stdlib.h> | ||
| 15 | #include <stdio.h> | ||
| 16 | #include <errno.h> | ||
| 17 | #include <string.h> | ||
| 18 | #include <fcntl.h> | ||
| 19 | #include <getopt.h> | ||
| 20 | #include <sys/ioctl.h> | ||
| 21 | #include <libmount.h> | ||
| 22 | #include <err.h> | ||
| 23 | #include <dirent.h> | ||
| 24 | #include <linux/gpio.h> | ||
| 25 | #include "../../../gpio/gpio-utils.h" | ||
| 26 | |||
| 27 | #define CONSUMER "gpio-selftest" | ||
| 28 | #define GC_NUM 10 | ||
| 29 | enum direction { | ||
| 30 | OUT, | ||
| 31 | IN | ||
| 32 | }; | ||
| 33 | |||
| 34 | static int get_debugfs(char **path) | ||
| 35 | { | ||
| 36 | struct libmnt_context *cxt; | ||
| 37 | struct libmnt_table *tb; | ||
| 38 | struct libmnt_iter *itr = NULL; | ||
| 39 | struct libmnt_fs *fs; | ||
| 40 | int found = 0; | ||
| 41 | |||
| 42 | cxt = mnt_new_context(); | ||
| 43 | if (!cxt) | ||
| 44 | err(EXIT_FAILURE, "libmount context allocation failed"); | ||
| 45 | |||
| 46 | itr = mnt_new_iter(MNT_ITER_FORWARD); | ||
| 47 | if (!itr) | ||
| 48 | err(EXIT_FAILURE, "failed to initialize libmount iterator"); | ||
| 49 | |||
| 50 | if (mnt_context_get_mtab(cxt, &tb)) | ||
| 51 | err(EXIT_FAILURE, "failed to read mtab"); | ||
| 52 | |||
| 53 | while (mnt_table_next_fs(tb, itr, &fs) == 0) { | ||
| 54 | const char *type = mnt_fs_get_fstype(fs); | ||
| 55 | |||
| 56 | if (!strcmp(type, "debugfs")) { | ||
| 57 | found = 1; | ||
| 58 | break; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | if (found) | ||
| 62 | asprintf(path, "%s/gpio", mnt_fs_get_target(fs)); | ||
| 63 | |||
| 64 | mnt_free_iter(itr); | ||
| 65 | mnt_free_context(cxt); | ||
| 66 | |||
| 67 | if (!found) | ||
| 68 | return -1; | ||
| 69 | |||
| 70 | return 0; | ||
| 71 | } | ||
| 72 | |||
| 73 | static int gpio_debugfs_get(const char *consumer, int *dir, int *value) | ||
| 74 | { | ||
| 75 | char *debugfs; | ||
| 76 | FILE *f; | ||
| 77 | char *line = NULL; | ||
| 78 | size_t len = 0; | ||
| 79 | char *cur; | ||
| 80 | int found = 0; | ||
| 81 | |||
| 82 | if (get_debugfs(&debugfs) != 0) | ||
| 83 | err(EXIT_FAILURE, "debugfs is not mounted"); | ||
| 84 | |||
| 85 | f = fopen(debugfs, "r"); | ||
| 86 | if (!f) | ||
| 87 | err(EXIT_FAILURE, "read from gpio debugfs failed"); | ||
| 88 | |||
| 89 | /* | ||
| 90 | * gpio-2 ( |gpio-selftest ) in lo | ||
| 91 | */ | ||
| 92 | while (getline(&line, &len, f) != -1) { | ||
| 93 | cur = strstr(line, consumer); | ||
| 94 | if (cur == NULL) | ||
| 95 | continue; | ||
