buildsys: add "install-tests" target

Add a new "install-tests" make target that installs our unit test-*
executables and their test data files into /usr/lib/systemd/tests/.
This is useful for packaging the tests to run them with root privileges
or in CI.

Fixes #5257
This commit is contained in:
Martin Pitt 2017-02-12 23:53:53 +01:00
parent f853c6efb5
commit 4f8425b8d5
1 changed files with 20 additions and 2 deletions

View File

@ -93,6 +93,7 @@ kernelinstalldir = $(prefix)/lib/kernel/install.d
factory_etcdir = $(datadir)/factory/etc
factory_pamdir = $(datadir)/factory/etc/pam.d
bootlibdir = $(prefix)/lib/systemd/boot/efi
testsdir = $(prefix)/lib/systemd/tests
# And these are the special ones for /
rootprefix=@rootprefix@
@ -133,6 +134,7 @@ check_DATA =
dist_rootlibexec_DATA =
tests=
manual_tests =
TEST_DATA_FILES =
TEST_EXTENSIONS = .py
PY_LOG_COMPILER = $(PYTHON)
DISABLE_HARD_ERRORS = yes
@ -1606,7 +1608,7 @@ tests += \
test-seccomp
endif
EXTRA_DIST += \
TEST_DATA_FILES += \
test/a.service \
test/basic.target \
test/b.service \
@ -5649,7 +5651,7 @@ test_dns_packet_LDADD = \
$(GCRYPT_LIBS) \
-lm
EXTRA_DIST += \
TEST_DATA_FILES += \
test/test-resolve/_openpgpkey.fedoraproject.org.pkts \
test/test-resolve/fedoraproject.org.pkts \
test/test-resolve/gandi.net.pkts \
@ -5662,6 +5664,8 @@ EXTRA_DIST += \
test/test-resolve/kyhwana.org.pkts \
test/test-resolve/fake-caa.pkts
EXTRA_DIST += $(TEST_DATA_FILES)
test_dnssec_SOURCES = \
src/resolve/test-dnssec.c \
$(basic_dns_sources)
@ -6694,6 +6698,20 @@ tests += \
test-libsystemd-sym \
test-libudev-sym
.PHONY: install-tests
install-tests: $(tests) $(TEST_DATA_FILES)
for f in $(tests); do \
if [ -x .libs/$$f ]; then \
install -D -m 755 .libs/$$f $(DESTDIR)/$(testsdir)/$$f; \
else \
install -D -m 755 $$f $(DESTDIR)/$(testsdir)/$$f; \
fi; \
done
for f in $(TEST_DATA_FILES); do \
install -D -m 644 $$f $(DESTDIR)/$(testsdir)/testdata/$${f#test/}; \
done
.PHONY: cppcheck
cppcheck:
cppcheck --enable=all -q $(top_srcdir)