selftests: Add install target
This adds make install support to selftests. The basic usage is: $ cd tools/testing/selftests $ make install That installs into tools/testing/selftests/install, which can then be copied where ever necessary. The install destination is also configurable using eg: $ INSTALL_PATH=/mnt/selftests make install The implementation uses two targets in the child makefiles. The first "install" is expected to install all files into $(INSTALL_PATH). The second, "emit_tests", is expected to emit the test instructions (ie. bash script) on stdout. Separating this from install means the child makefiles need no knowledge of the location of the test script. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
This commit is contained in:
parent
5e29a9105b
commit
32dcfba6f8
@ -47,7 +47,40 @@ clean_hotplug:
|
|||||||
make -C $$TARGET clean; \
|
make -C $$TARGET clean; \
|
||||||
done;
|
done;
|
||||||
|
|
||||||
|
INSTALL_PATH ?= install
|
||||||
|
INSTALL_PATH := $(abspath $(INSTALL_PATH))
|
||||||
|
ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
|
||||||
|
|
||||||
|
install:
|
||||||
|
ifdef INSTALL_PATH
|
||||||
|
@# Ask all targets to install their files
|
||||||
|
mkdir -p $(INSTALL_PATH)
|
||||||
|
for TARGET in $(TARGETS); do \
|
||||||
|
mkdir -p $(INSTALL_PATH)/$$TARGET ; \
|
||||||
|
make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
|
||||||
|
done;
|
||||||
|
|
||||||
|
@# Ask all targets to emit their test scripts
|
||||||
|
echo "#!/bin/bash" > $(ALL_SCRIPT)
|
||||||
|
echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
|
||||||
|
echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
|
||||||
|
|
||||||
|
for TARGET in $(TARGETS); do \
|
||||||
|
echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
|
||||||
|
echo "echo ========================================" >> $(ALL_SCRIPT); \
|
||||||
|
echo "cd $$TARGET" >> $(ALL_SCRIPT); \
|
||||||
|
make -s --no-print-directory -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
|
||||||
|
echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
|
||||||
|
done;
|
||||||
|
|
||||||
|
chmod u+x $(ALL_SCRIPT)
|
||||||
|
else
|
||||||
|
$(error Error: set INSTALL_PATH to use install)
|
||||||
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
for TARGET in $(TARGETS); do \
|
for TARGET in $(TARGETS); do \
|
||||||
make -C $$TARGET clean; \
|
make -C $$TARGET clean; \
|
||||||
done;
|
done;
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
@ -6,6 +6,7 @@ test_objs = open-unlink create-read
|
|||||||
all: $(test_objs)
|
all: $(test_objs)
|
||||||
|
|
||||||
TEST_PROGS := efivarfs.sh
|
TEST_PROGS := efivarfs.sh
|
||||||
|
TEST_FILES := $(test_objs)
|
||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
|
@ -19,8 +19,11 @@ execveat.denatured: execveat
|
|||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
TEST_PROGS := execveat
|
TEST_PROGS := execveat
|
||||||
|
TEST_FILES := $(DEPS)
|
||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
|
override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
|
rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
|
||||||
|
@ -7,4 +7,25 @@ endef
|
|||||||
run_tests: all
|
run_tests: all
|
||||||
$(RUN_TESTS)
|
$(RUN_TESTS)
|
||||||
|
|
||||||
.PHONY: run_tests all clean
|
define INSTALL_RULE
|
||||||
|
mkdir -p $(INSTALL_PATH)
|
||||||
|
install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_FILES)
|
||||||
|
endef
|
||||||
|
|
||||||
|
install: all
|
||||||
|
ifdef INSTALL_PATH
|
||||||
|
$(INSTALL_RULE)
|
||||||
|
else
|
||||||
|
$(error Error: set INSTALL_PATH to use install)
|
||||||
|
endif
|
||||||
|
|
||||||
|
define EMIT_TESTS
|
||||||
|
@for TEST in $(TEST_PROGS); do \
|
||||||
|
echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
|
||||||
|
done;
|
||||||
|
endef
|
||||||
|
|
||||||
|
emit_tests:
|
||||||
|
$(EMIT_TESTS)
|
||||||
|
|
||||||
|
.PHONY: run_tests all clean install emit_tests
|
||||||
|
@ -2,7 +2,9 @@ all:
|
|||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
|
TEST_PROGS := on-off-test.sh
|
||||||
override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]"
|
override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]"
|
||||||
|
override EMIT_TESTS := echo "$(RUN_TESTS)"
|
||||||
|
|
||||||
run_full_test:
|
run_full_test:
|
||||||
@/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
|
@/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
|
||||||
|
@ -7,7 +7,9 @@ unprivileged-remount-test: unprivileged-remount-test.c
|
|||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
|
TEST_PROGS := unprivileged-remount-test
|
||||||
override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
|
override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
|
||||||
|
override EMIT_TESTS := echo "$(RUN_TESTS)"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f unprivileged-remount-test
|
rm -f unprivileged-remount-test
|
||||||
|
@ -9,5 +9,12 @@ override define RUN_TESTS
|
|||||||
@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
|
@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
TEST_PROGS := mq_open_tests mq_perf_tests
|
||||||
|
|
||||||
|
override define EMIT_TESTS
|
||||||
|
echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\""
|
||||||
|
echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\""
|
||||||
|
endef
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f mq_open_tests mq_perf_tests
|
rm -f mq_open_tests mq_perf_tests
|
||||||
|
@ -12,6 +12,7 @@ all: $(NET_PROGS)
|
|||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
|
TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
|
||||||
|
TEST_FILES := $(NET_PROGS)
|
||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
all:
|
all:
|
||||||
|
|
||||||
TEST_PROGS := run_numerictests run_stringtests
|
TEST_PROGS := run_numerictests run_stringtests
|
||||||
|
TEST_FILES := common_tests
|
||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ all: $(BINARIES)
|
|||||||
$(CC) $(CFLAGS) -o $@ $^ -lrt
|
$(CC) $(CFLAGS) -o $@ $^ -lrt
|
||||||
|
|
||||||
TEST_PROGS := run_vmtests
|
TEST_PROGS := run_vmtests
|
||||||
|
TEST_FILES := $(BINARIES)
|
||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user