aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-security/libseccomp/files/0001-tests-create-install-tests-target.patch
blob: 55eaf818fb27aadf13851db28283896bf9ae203f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
From e8e166cdc1fc31e02d568424e17b9f9fc1e95256 Mon Sep 17 00:00:00 2001
From: Joe MacDonald <joe@deserted.net>
Date: Mon, 28 Oct 2013 15:40:14 -0400
Subject: [PATCH 1/3] tests: create install-tests target

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 an
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.

Upstream-Status: Submitted [http://www.mail-archive.com/libseccomp-discuss@lists.sourceforge.net/msg00470.html]

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

diff --git a/Makefile b/Makefile
index 1f61f20..8cb0a16 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 check check-syntax ctags cstags clean dist-clean \
 	$(SUBDIRS_BUILD)
@@ -106,6 +107,14 @@ check: tools tests
 check-syntax:
 	@./tools/check-syntax
 
+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 6df5b3a..e7c196d 100644
--- a/macros.mk
+++ b/macros.mk
@@ -206,6 +206,24 @@ 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)";
+
+ifeq ($(V),0)
 	INSTALL_MAN1_MACRO = \
 		@echo " INSTALL manpages ($(INSTALL_MAN_DIR)/man1)";
 endif
diff --git a/tests/Makefile b/tests/Makefile
index 5fdbca7..135551c 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: check clean
+.PHONY: check clean install-tests
 
 all: $(TESTS) $(OBJS)
 
@@ -91,5 +92,9 @@ $(TEST_PRIVATE): 00-test.c $(OBJS) ../src/libseccomp.a
 check: $(TESTS)
 	./regression
 
+install-tests: $(TESTS) $(TESTS:%=%.tests)
+	$(INSTALL_TEST_MACRO)
+	$(INSTALL_REGRESSION_TEST_MACRO)
+
 clean:
 	$(RM) $(DEPS_TESTS) $(DEPS_OBJS) $(TESTS) $(TEST_PRIVATE) $(OBJS) *.pyc
diff --git a/tests/regression b/tests/regression
index 790d5e1..3c293a4 100755
--- a/tests/regression
+++ b/tests/regression
@@ -23,9 +23,18 @@
 
 GLBL_ARCH_SUPPORT="x86 x86_64 x32 arm"
 
-GLBL_SYS_ARCH="../tools/scmp_arch_detect"
-GLBL_SYS_RESOLVER="../tools/scmp_sys_resolver"
-GLBL_SYS_SIM="../tools/scmp_bpf_sim"
+GLBL_SYS_PATH=$(dirname $(readlink -m $0))
+if [ -d $GLBL_SYS_PATH/../tools/ ]; then
+	# prepend ../tools to $PATH so we can use verify_deps to check for
+	# scmp_* support binaries if regression is running out of the build
+	# tree.
+	PATH=$GLBL_SYS_PATH/../tools/:$PATH
+	export PATH
+fi
+
+GLBL_SYS_ARCH=$(which scmp_arch_detect)
+GLBL_SYS_RESOLVER=$(which scmp_sys_resolver)
+GLBL_SYS_SIM=$(which scmp_bpf_sim)
 
 ####
 # functions
@@ -761,6 +770,9 @@ verify_deps head
 verify_deps sed
 verify_deps seq
 verify_deps tr
+verify_deps scmp_arch_detect
+verify_deps scmp_sys_resolver
+verify_deps scmp_bpf_sim
 
 # global variables
 declare -a batch_list
@@ -865,6 +877,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