diff options
Diffstat (limited to 'tools/testing')
24 files changed, 124 insertions, 68 deletions
diff --git a/tools/testing/selftests/.gitignore b/tools/testing/selftests/.gitignore index f0600d20ce7d..91750352459d 100644 --- a/tools/testing/selftests/.gitignore +++ b/tools/testing/selftests/.gitignore @@ -1 +1,5 @@ kselftest +gpiogpio-event-mon +gpiogpio-hammer +gpioinclude/ +gpiolsgpio diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index d8593f1251ec..26ce4f7168be 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -39,7 +39,7 @@ TARGETS += x86 TARGETS += zram #Please keep the TARGETS list alphabetically sorted # Run "make quicktest=1 run_tests" or -# "make quicktest=1 kselftest from top level Makefile +# "make quicktest=1 kselftest" from top level Makefile TARGETS_HOTPLUG = cpu-hotplug TARGETS_HOTPLUG += memory-hotplug @@ -133,4 +133,4 @@ clean: make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ done; -.PHONY: install +.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile index 72aa103e4141..6b214b7b10fb 100644 --- a/tools/testing/selftests/breakpoints/Makefile +++ b/tools/testing/selftests/breakpoints/Makefile @@ -5,7 +5,7 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) ifeq ($(ARCH),x86) TEST_GEN_PROGS := breakpoint_test endif -ifeq ($(ARCH),aarch64) +ifneq (,$(filter $(ARCH),aarch64 arm64)) TEST_GEN_PROGS := breakpoint_test_arm64 endif diff --git a/tools/testing/selftests/cpufreq/config b/tools/testing/selftests/cpufreq/config new file mode 100644 index 000000000000..27ff72ebd0f5 --- /dev/null +++ b/tools/testing/selftests/cpufreq/config @@ -0,0 +1,15 @@ +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_STAT=y +CONFIG_CPU_FREQ_GOV_POWERSAVE=y +CONFIG_CPU_FREQ_GOV_USERSPACE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y +CONFIG_DEBUG_RT_MUTEXES=y +CONFIG_DEBUG_PI_LIST=y +CONFIG_DEBUG_SPINLOCK=y +CONFIG_DEBUG_MUTEXES=y +CONFIG_DEBUG_LOCK_ALLOC=y +CONFIG_PROVE_LOCKING=y +CONFIG_LOCKDEP=y +CONFIG_DEBUG_ATOMIC_SLEEP=y diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selftests/ftrace/config index ef8214661612..8a1c9f949fe0 100644 --- a/tools/testing/selftests/ftrace/config +++ b/tools/testing/selftests/ftrace/config @@ -1 +1,2 @@ +CONFIG_KPROBES=y CONFIG_FTRACE=y diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc index 0a78705b43b2..c75faefb4fff 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc @@ -26,7 +26,7 @@ check_types() { test $X2 = $X3 test 0x$X3 = $3 - B4=`printf "%x" $4` + B4=`printf "%02x" $4` B3=`echo -n $X3 | tail -c 3 | head -c 2` test $B3 = $B4 } diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selftests/futex/Makefile index 653c5cd9e44d..e2fbb890aef9 100644 --- a/tools/testing/selftests/futex/Makefile +++ b/tools/testing/selftests/futex/Makefile @@ -8,7 +8,7 @@ include ../lib.mk all: for DIR in $(SUBDIRS); do \ - BUILD_TARGET=$$OUTPUT/$$DIR; \ + BUILD_TARGET=$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ done @@ -22,7 +22,7 @@ override define INSTALL_RULE install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) @for SUBDIR in $(SUBDIRS); do \ - BUILD_TARGET=$$OUTPUT/$$SUBDIR; \ + BUILD_TARGET=$(OUTPUT)/$$SUBDIR; \ mkdir $$BUILD_TARGET -p; \ $(MAKE) OUTPUT=$$BUILD_TARGET -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \ done; @@ -32,9 +32,10 @@ override define EMIT_TESTS echo "./run.sh" endef -clean: +override define CLEAN for DIR in $(SUBDIRS); do \ - BUILD_TARGET=$$OUTPUT/$$DIR; \ + BUILD_TARGET=$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ done +endef diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 205e4d10e085..298929df97e6 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -2,13 +2,20 @@ TEST_PROGS := gpio-mockup.sh TEST_FILES := gpio-mockup-sysfs.sh $(BINARIES) BINARIES := gpio-mockup-chardev +EXTRA_PROGS := ../gpiogpio-event-mon ../gpiogpio-hammer ../gpiolsgpio +EXTRA_DIRS := ../gpioinclude/ +EXTRA_OBJS := ../gpiogpio-event-mon-in.o ../gpiogpio-event-mon.o +EXTRA_OBJS += ../gpiogpio-hammer-in.o ../gpiogpio-utils.o ../gpiolsgpio-in.o +EXTRA_OBJS += ../gpiolsgpio.o include ../lib.mk all: $(BINARIES) -clean: - $(RM) $(BINARIES) +override define CLEAN + $(RM) $(BINARIES) $(EXTRA_PROGS) $(EXTRA_OBJS) + $(RM) -r $(EXTRA_DIRS) +endef CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ LDLIBS += -lmount -I/usr/include/libmount diff --git a/tools/testing/selftests/gpio/config b/tools/testing/selftests/gpio/config new file mode 100644 index 000000000000..abaa6902b7b6 --- /dev/null +++ b/tools/testing/selftests/gpio/config @@ -0,0 +1,2 @@ +CONFIG_GPIOLIB=y +CONFIG_GPIO_MOCKUP=m diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 775c589ac3c0..959273c3a52e 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -51,8 +51,12 @@ endef emit_tests: $(EMIT_TESTS) -clean: +define CLEAN $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN) +endef + +clean: + $(CLEAN) $(OUTPUT)/%:%.c $(LINK.c) $^ $(LDLIBS) -o $@ diff --git a/tools/testing/selftests/lib/config b/tools/testing/selftests/lib/config new file mode 100644 index 000000000000..126933bcc950 --- /dev/null +++ b/tools/testing/selftests/lib/config @@ -0,0 +1,3 @@ +CONFIG_TEST_PRINTF=m +CONFIG_TEST_BITMAP=m +CONFIG_PRIME_NUMBERS=m diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile index 03e1617367d3..72c3ac2323e1 100644 --- a/tools/testing/selftests/powerpc/Makefile +++ b/tools/testing/selftests/powerpc/Makefile @@ -60,12 +60,13 @@ override define EMIT_TESTS done; endef -clean: +override define CLEAN @for TARGET in $(SUB_DIRS); do \ BUILD_TARGET=$(OUTPUT)/$$TARGET; \ $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \ done; rm -f tags +endef tags: find . -name '*.c' -o -name '*.h' | xargs ctags diff --git a/tools/testing/selftests/splice/Makefile b/tools/testing/selftests/splice/Makefile index de51f439d4a6..9fc78e5e5451 100644 --- a/tools/testing/selftests/splice/Makefile +++ b/tools/testing/selftests/splice/Makefile @@ -4,5 +4,4 @@ all: $(TEST_PROGS) $(EXTRA) include ../lib.mk -clean: - rm -fr $(TEST_PROGS) $(EXTRA) +EXTRA_CLEAN := $(EXTRA) diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile index 87ac400507c0..4981c6b6d050 100644 --- a/tools/testing/selftests/sync/Makefile +++ b/tools/testing/selftests/sync/Makefile @@ -20,5 +20,4 @@ TESTS += sync_stress_merge.o sync_test: $(OBJS) $(TESTS) -clean: - $(RM) sync_test $(OBJS) $(TESTS) +EXTRA_CLEAN := sync_test $(OBJS) $(TESTS) diff --git a/tools/testing/selftests/timers/clocksource-switch.c b/tools/testing/selftests/timers/clocksource-switch.c index fd88e3025bed..5ff165373f8b 100644 --- a/tools/testing/selftests/timers/clocksource-switch.c +++ b/tools/testing/selftests/timers/clocksource-switch.c @@ -159,7 +159,7 @@ int main(int argv, char **argc) } - printf("Running Asyncrhonous Switching Tests...\n"); + printf("Running Asynchronous Switching Tests...\n"); pid = fork(); if (!pid) return run_tests(60); diff --git a/tools/testing/selftests/vm/config b/tools/testing/selftests/vm/config index 698c7ed28a26..1c0d76cb5adf 100644 --- a/tools/testing/selftests/vm/config +++ b/tools/testing/selftests/vm/config @@ -1 +1,2 @@ +CONFIG_SYSVIPC=y CONFIG_USERFAULTFD=y diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/vm/map_hugetlb.c index addcd6fc1ecc..77687ab59f77 100644 --- a/tools/testing/selftests/vm/map_hugetlb.c +++ b/tools/testing/selftests/vm/map_hugetlb.c @@ -62,7 +62,7 @@ int main(void) void *addr; int ret; - addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, 0, 0); + addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, -1, 0); if (addr == MAP_FAILED) { perror("mmap"); exit(1); diff --git a/tools/testing/selftests/vm/mlock2-tests.c b/tools/testing/selftests/vm/mlock2-tests.c index ff0cda2b19c9..e5dbc87b4297 100644 --- a/tools/testing/selftests/vm/mlock2-tests.c +++ b/tools/testing/selftests/vm/mlock2-tests.c @@ -293,7 +293,7 @@ static int test_mlock_lock() unsigned long page_size = getpagesize(); map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (map == MAP_FAILED) { perror("test_mlock_locked mmap"); goto out; @@ -402,7 +402,7 @@ static int test_mlock_onfault() unsigned long page_size = getpagesize(); map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (map == MAP_FAILED) { perror("test_mlock_locked mmap"); goto out; @@ -445,7 +445,7 @@ static int test_lock_onfault_of_present() uint64_t page1_flags, page2_flags; map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (map == MAP_FAILED) { perror("test_mlock_locked mmap"); goto out; @@ -492,7 +492,7 @@ static int test_munlockall() unsigned long page_size = getpagesize(); map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (map == MAP_FAILED) { perror("test_munlockall mmap"); @@ -518,7 +518,7 @@ static int test_munlockall() munmap(map, 2 * page_size); map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (map == MAP_FAILED) { perror("test_munlockall second mmap"); @@ -573,7 +573,7 @@ static int test_vma_management(bool call_mlock) struct vm_boundaries page3; map = mmap(NULL, 3 * page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (map == MAP_FAILED) { perror("mmap()"); return ret; diff --git a/tools/testing/selftests/vm/on-fault-limit.c b/tools/testing/selftests/vm/on-fault-limit.c index 0ae458f32fdb..7f96a5c2e292 100644 --- a/tools/testing/selftests/vm/on-fault-limit.c +++ b/tools/testing/selftests/vm/on-fault-limit.c @@ -26,7 +26,7 @@ static int test_limit(void) } map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, 0, 0); + MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0); if (map != MAP_FAILED) printf("mmap should have failed, but didn't\n"); else { diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index 0640923ded7e..07548a1fa901 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests @@ -49,9 +49,9 @@ fi mkdir $mnt mount -t hugetlbfs none $mnt -echo "--------------------" +echo "---------------------" echo "running hugepage-mmap" -echo "--------------------" +echo "---------------------" ./hugepage-mmap if [ $? -ne 0 ]; then echo "[FAIL]" @@ -77,9 +77,9 @@ fi echo $shmmax > /proc/sys/kernel/shmmax echo $shmall > /proc/sys/kernel/shmall -echo "--------------------" +echo "-------------------" echo "running map_hugetlb" -echo "--------------------" +echo "-------------------" ./map_hugetlb if [ $? -ne 0 ]; then echo "[FAIL]" @@ -92,9 +92,9 @@ echo "NOTE: The above hugetlb tests provide minimal coverage. Use" echo " https://github.com/libhugetlbfs/libhugetlbfs.git for" echo " hugetlb regression testing." -echo "--------------------" +echo "-------------------" echo "running userfaultfd" -echo "--------------------" +echo "-------------------" ./userfaultfd anon 128 32 if [ $? -ne 0 ]; then echo "[FAIL]" @@ -103,10 +103,10 @@ else echo "[PASS]" fi -echo "----------------------------" +echo "---------------------------" echo "running userfaultfd_hugetlb" -echo "----------------------------" -# 258MB total huge pages == 128MB src and 128MB dst +echo "---------------------------" +# 256MB total huge pages == 128MB src and 128MB dst ./userfaultfd hugetlb 128 32 $mnt/ufd_test_file if [ $? -ne 0 ]; then echo "[FAIL]" @@ -116,9 +116,9 @@ else fi rm -f $mnt/ufd_test_file -echo "----------------------------" +echo "-------------------------" echo "running userfaultfd_shmem" -echo "----------------------------" +echo "-------------------------" ./userfaultfd shmem 128 32 if [ $? -ne 0 ]; then echo "[FAIL]" @@ -143,9 +143,9 @@ else echo "[PASS]" fi -echo "--------------------" +echo "----------------------" echo "running on-fault-limit" -echo "--------------------" +echo "----------------------" sudo -u nobody ./on-fault-limit if [ $? -ne 0 ]; then echo "[FAIL]" diff --git a/tools/testing/selftests/vm/thuge-gen.c b/tools/testing/selftests/vm/thuge-gen.c index 0bc737a75150..88a2ab535e01 100644 --- a/tools/testing/selftests/vm/thuge-gen.c +++ b/tools/testing/selftests/vm/thuge-gen.c @@ -146,7 +146,7 @@ void test_mmap(unsigned long size, unsigned flags) before = read_free(size); map = mmap(NULL, size*NUM_PAGES, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB|flags, 0, 0); + MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB|flags, -1, 0); if (map == (char *)-1) err("mmap"); memset(map, 0xff, size*NUM_PAGES); diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 6983d05097e2..a74c9d739d07 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c @@ -24,9 +24,11 @@ const char v = 'V'; static void keep_alive(void) { int dummy; + int ret; - printf("."); - ioctl(fd, WDIOC_KEEPALIVE, &dummy); + ret = ioctl(fd, WDIOC_KEEPALIVE, &dummy); + if (!ret) + printf("."); } /* @@ -51,6 +53,7 @@ int main(int argc, char *argv[]) int flags; unsigned int ping_rate = 1; int ret; + int i; setbuf(stdout, NULL); @@ -61,31 +64,35 @@ int main(int argc, char *argv[]) exit(-1); } - if (argc > 1) { - if (!strncasecmp(argv[1], "-d", 2)) { - flags = WDIOS_DISABLECARD; - ioctl(fd, WDIOC_SETOPTIONS, &flags); - printf("Watchdog card disabled.\n"); - goto end; - } else if (!strncasecmp(argv[1], "-e", 2)) { - flags = WDIOS_ENABLECARD; - ioctl(fd, WDIOC_SETOPTIONS, &flags); - printf("Watchdog card enabled.\n"); - goto end; - } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) { - flags = atoi(argv[2]); - ioctl(fd, WDIOC_SETTIMEOUT, &flags); - printf("Watchdog timeout set to %u seconds.\n", flags); - goto end; - } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) { - ping_rate = strtoul(argv[2], NULL, 0); - printf("Watchdog ping rate set to %u seconds.\n", ping_rate); - } else { - printf("-d to disable, -e to enable, -t <n> to set " \ - "the timeout,\n-p <n> to set the ping rate, and \n"); - printf("run by itself to tick the card.\n"); - goto end; - } + for (i = 1; i < argc; i++) { + if (!strncasecmp(argv[i], "-d", 2)) { + flags = WDIOS_DISABLECARD; + ret = ioctl(fd, WDIOC_SETOPTIONS, &flags); + if (!ret) + printf("Watchdog card disabled.\n"); + } else if (!strncasecmp(argv[i], "-e", 2)) { + flags = WDIOS_ENABLECARD; + ret = ioctl(fd, WDIOC_SETOPTIONS, &flags); + if (!ret) + printf("Watchdog card enabled.\n"); + } else if (!strncasecmp(argv[i], "-t", 2) && argv[2]) { + flags = atoi(argv[i + 1]); + ret = ioctl(fd, WDIOC_SETTIMEOUT, &flags); + if (!ret) + printf("Watchdog timeout set to %u seconds.\n", flags); + i++; + } else if (!strncasecmp(argv[i], "-p", 2) && argv[2]) { + ping_rate = strtoul(argv[i + 1], NULL, 0); + printf("Watchdog ping rate set to %u seconds.\n", ping_rate); + i++; + } else { + printf("-d to disable, -e to enable, -t <n> to set " + "the timeout,\n-p <n> to set the ping rate, and "); + printf("run by itself to tick the card.\n"); + printf("Parameters are parsed left-to-right in real-time.\n"); + printf("Example: %s -d -t 10 -p 5 -e\n", argv[0]); + goto end; + } } printf("Watchdog Ticking Away!\n"); diff --git a/tools/testing/selftests/x86/.gitignore b/tools/testing/selftests/x86/.gitignore index 15034fef9698..7757f73ff9a3 100644 --- a/tools/testing/selftests/x86/.gitignore +++ b/tools/testing/selftests/x86/.gitignore @@ -1,2 +1,15 @@ *_32 *_64 +single_step_syscall +sysret_ss_attrs +syscall_nt +ptrace_syscall +test_mremap_vdso +check_initial_reg_state +sigreturn +ldt_gdt +iopl +mpx-mini-test +ioperm +protection_keys +test_vdso diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile index 38e0a9ca5d71..97f187e2663f 100644 --- a/tools/testing/selftests/x86/Makefile +++ b/tools/testing/selftests/x86/Makefile @@ -40,8 +40,7 @@ all_32: $(BINARIES_32) all_64: $(BINARIES_64) -clean: - $(RM) $(BINARIES_32) $(BINARIES_64) +EXTRA_CLEAN := $(BINARIES_32) $(BINARIES_64) $(BINARIES_32): $(OUTPUT)/%_32: %.c $(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm |