It can be useful, in particular on a cross-build setup, to install the
tests and regression suite in addition to the library itself.  Since most
people probably don't want that by default, though, create in
install-tests target that will place tests and regression script in
$(INSTALL_LIB_DIR)/libseccomp/tests and install the necessary tools in
$(INSTALL_BIN_DIR)/bin.

Signed-off-by: Joe MacDonald <j...@deserted.net>
---
 Makefile         |    9 +++++++++
 README           |    8 ++++++++
 install.mk       |    1 +
 macros.mk        |   19 +++++++++++++++++++
 tests/Makefile   |    7 ++++++-
 tests/regression |    1 +
 tools/Makefile   |    3 +++
 7 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 4fd50c6..0bdcd7e 100644
--- a/Makefile
+++ b/Makefile
@@ -40,6 +40,7 @@ include install.mk
 CONFIGS = configure.mk configure.h version_info.mk libseccomp.pc
 SUBDIRS_BUILD = include src tests tools
 SUBDIRS_INSTALL = include src tools doc
+SUBDIRS_INSTALL_TEST = tools tests
 
 .PHONY: tarball install ctags cstags clean dist-clean $(SUBDIRS_BUILD)
 
@@ -98,6 +99,14 @@ install: $(SUBDIRS_BUILD)
                $(MAKE) -C $$dir install; \
        done
 
+install-tests: $(SUBDIRS_INSTALL_TEST)
+       @$(ECHO_INFO) "installing tests in $(INSTALL_PREFIX) ..."
+       $(ECHO_INFO) "installing from $$dir/"
+       @for dir in $(SUBDIRS_INSTALL_TEST); do \
+               $(ECHO_INFO) "installing from $$dir/"; \
+               $(MAKE) -C $$dir install-tests; \
+       done
+
 ctags:
        @$(ECHO_INFO) "generating ctags for the project ..."
        @ctags -R *
diff --git a/README b/README
index 37b9709..14ae254 100644
--- a/README
+++ b/README
@@ -41,6 +41,14 @@ to run all of the tests you can simply run the script:
 However, the script takes a number of options to customize its execution; the
 options can be displayed by running "./regression -h".
 
+It is also possible to install the tests and regression script to the system by
+issuing:
+
+   # make install-tests
+
+When complete, installed tests and regression script may be found in
+$LIBDIR/lib/libseccomp/test
+
 * Other Useful Tools
 
 The "tools/" directory includes a number of tools which may be helpful in the
diff --git a/install.mk b/install.mk
index 123af33..f6aa311 100644
--- a/install.mk
+++ b/install.mk
@@ -24,6 +24,7 @@ INSTALL_PREFIX ?= $(CONF_INSTALL_PREFIX)
 INSTALL_SBIN_DIR ?= $(DESTDIR)/$(INSTALL_PREFIX)/sbin
 INSTALL_BIN_DIR ?= $(DESTDIR)/$(INSTALL_PREFIX)/bin
 INSTALL_LIB_DIR ?= $(DESTDIR)/$(CONF_INSTALL_LIBDIR)
+INSTALL_TEST_DIR ?= $(DESTDIR)/$(CONF_INSTALL_LIBDIR)/libseccomp/tests
 INSTALL_INC_DIR ?= $(DESTDIR)/$(INSTALL_PREFIX)/include
 INSTALL_MAN_DIR ?= $(DESTDIR)/$(INSTALL_PREFIX)/share/man
 
diff --git a/macros.mk b/macros.mk
index 15529f6..b33bfae 100644
--- a/macros.mk
+++ b/macros.mk
@@ -205,6 +205,25 @@ INSTALL_INC_MACRO += \
                        $^ "$(INSTALL_INC_DIR)";
 
 ifeq ($(V),0)
+       INSTALL_TEST_MACRO = @echo " INSTALL $^ ($(INSTALL_TEST_DIR))";
+endif
+INSTALL_TEST_MACRO += \
+               $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \
+                       -d "$(INSTALL_TEST_DIR)"; \
+               $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0755 \
+                       $^ "$(INSTALL_TEST_DIR)";
+
+ifeq ($(V),0)
+       INSTALL_REGRESSION_TEST_MACRO = @echo " INSTALL regression 
($(INSTALL_TEST_DIR))";
+endif
+INSTALL_REGRESSION_TEST_MACRO += \
+               $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \
+                       -d "$(INSTALL_TEST_DIR)"; \
+               $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0755 \
+                       regression "$(INSTALL_TEST_DIR)"; \
+               $(SED) -i "s=../tools/=$(INSTALL_BIN_DIR)/=" 
"$(INSTALL_TEST_DIR)/regression";
+
+ifeq ($(V),0)
        INSTALL_MAN1_MACRO = \
                @echo " INSTALL manpages ($(INSTALL_MAN_DIR)/man1)";
 endif
diff --git a/tests/Makefile b/tests/Makefile
index adb5820..49277ec 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -31,6 +31,7 @@ include ../macros.mk
 
 include $(TOPDIR)/version_info.mk
 include $(TOPDIR)/configure.mk
+include $(TOPDIR)/install.mk
 
 OBJS = util.o
 
@@ -71,7 +72,7 @@ DEPS_TESTS = $(TESTS:%=%.d)
 # targets
 #
 
-.PHONY: clean
+.PHONY: clean install-tests
 
 all: $(TESTS) $(OBJS)
 
@@ -88,5 +89,9 @@ $(TESTS):
 $(TEST_PRIVATE): 00-test.c $(OBJS) ../src/libseccomp.a
        $(COMPILE_EXEC)
 
+install-tests: $(TESTS) $(TESTS:%=%.tests)
+       $(INSTALL_TEST_MACRO)
+       $(INSTALL_REGRESSION_TEST_MACRO)
+
 clean:
        $(RM) $(DEPS_TESTS) $(DEPS_OBJS) $(TESTS) $(TEST_PRIVATE) $(OBJS)
diff --git a/tests/regression b/tests/regression
index 6e3d6d1..73bfa68 100755
--- a/tests/regression
+++ b/tests/regression
@@ -812,6 +812,7 @@ arch=$($GLBL_SYS_ARCH)
 # display the test output and run the requested tests
 echo "=============== $(date) ===============" >&$logfd
 echo "Regression Test Report (\"regression $*\")" >&$logfd
+cd $(dirname $0)
 for mode in $mode_list; do
        run_tests
 done
diff --git a/tools/Makefile b/tools/Makefile
index 79c7d25..9f4ffea 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -62,5 +62,8 @@ $(TOOLS):
 install: $(TOOLS_INSTALL)
        $(INSTALL_BIN_MACRO)
 
+install-tests: $(TOOLS)
+       $(INSTALL_BIN_MACRO)
+
 clean:
        $(RM) $(DEPS) $(TOOLS)
-- 
1.7.10.4


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
libseccomp-discuss mailing list
libseccomp-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss

Reply via email to