1 |
commit: 706679c2071261848f964bb7b987de1bac466f46 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Dec 17 01:00:44 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Dec 17 01:00:44 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=706679c2 |
7 |
|
8 |
tests: add out-of-tree build support |
9 |
|
10 |
tests/Makefile | 4 +++- |
11 |
tests/lddtree/dotest.cmp | 20 ++++++++++++++------ |
12 |
tests/lddtree/dotest.sfx | 2 +- |
13 |
tests/lib.sh | 25 +++++++++++++++---------- |
14 |
tests/scanelf/dotest | 2 +- |
15 |
tests/source/dotest | 26 +++++++++++++------------- |
16 |
6 files changed, 47 insertions(+), 32 deletions(-) |
17 |
|
18 |
diff --git a/tests/Makefile b/tests/Makefile |
19 |
index 1db7654..f4b81e8 100644 |
20 |
--- a/tests/Makefile |
21 |
+++ b/tests/Makefile |
22 |
@@ -1,8 +1,10 @@ |
23 |
SUBDIRS = $(patsubst %/Makefile,%,$(wildcard */Makefile)) |
24 |
+abs_top_srcdir = $(realpath $(PWD)/..) |
25 |
+abs_top_builddir = $(realpath $(PWD)/..) |
26 |
# DO NOT STARE AT THE SUN |
27 |
all: |
28 |
%:; $(MAKE) `printf '%s_$@_ ' $(SUBDIRS)` |
29 |
_words = $(subst _, ,$1) |
30 |
_dir = $(firstword $(call _words,$@)) |
31 |
_targ = $(lastword $(call _words,$@)) |
32 |
-%_:; $(MAKE) -C $(_dir) $(_targ) |
33 |
+%_:; $(MAKE) -C $(_dir) $(_targ) srcdir=$(abs_top_srcdir)/tests/$(_dir) builddir=$(abs_top_builddir)/tests/$(_dir) |
34 |
|
35 |
diff --git a/tests/lddtree/dotest.cmp b/tests/lddtree/dotest.cmp |
36 |
index 2f04a55..89217fa 100755 |
37 |
--- a/tests/lddtree/dotest.cmp |
38 |
+++ b/tests/lddtree/dotest.cmp |
39 |
@@ -6,22 +6,30 @@ |
40 |
# make sure list output matches |
41 |
# |
42 |
for sfx in py sh ; do |
43 |
- lddtree.${sfx} -l /bin/bash > lddtree.${sfx}.list & |
44 |
+ lddtree.${sfx} -l /bin/bash > "${builddir}"/lddtree.${sfx}.list & |
45 |
done |
46 |
wait |
47 |
-testit lddtree.*.list |
48 |
-rm -f lddtree.*.list |
49 |
+if diff -u "${builddir}"/lddtree.*.list ; then |
50 |
+ pass "lddtree -l /bin/bash" |
51 |
+else |
52 |
+ fail "lddtree -l /bin/bash" |
53 |
+fi |
54 |
+rm -f "${builddir}"/lddtree.*.list |
55 |
|
56 |
|
57 |
# |
58 |
# Same as above but with the -a flag |
59 |
# |
60 |
for sfx in py sh ; do |
61 |
- lddtree.${sfx} -l -a /bin/bash > lddtree.${sfx}.list-all & |
62 |
+ lddtree.${sfx} -l -a /bin/bash > "${builddir}"/lddtree.${sfx}.list-all & |
63 |
done |
64 |
wait |
65 |
-testit lddtree.*.list-all |
66 |
-rm -f lddtree.*.list-all |
67 |
+if diff -u "${builddir}"/lddtree.*.list-all ; then |
68 |
+ pass "lddtree -l -a /bin/bash" |
69 |
+else |
70 |
+ fail "lddtree -l -a /bin/bash" |
71 |
+fi |
72 |
+rm -f "${builddir}"/lddtree.*.list-all |
73 |
|
74 |
|
75 |
exit ${ret} |
76 |
|
77 |
diff --git a/tests/lddtree/dotest.sfx b/tests/lddtree/dotest.sfx |
78 |
index 1490434..fa82fd0 100644 |
79 |
--- a/tests/lddtree/dotest.sfx |
80 |
+++ b/tests/lddtree/dotest.sfx |
81 |
@@ -6,7 +6,7 @@ |
82 |
# smoke tests of sorts |
83 |
# |
84 |
lddtree.${sfx} /bin/bash | \ |
85 |
- grep -i 'none' > lddtree.${sfx}.smoke |
86 |
+ grep -i 'none' > "${builddir}"/lddtree.${sfx}.smoke |
87 |
testit lddtree.${sfx}.smoke |
88 |
|
89 |
|
90 |
|
91 |
diff --git a/tests/lib.sh b/tests/lib.sh |
92 |
index 93943a1..927e503 100644 |
93 |
--- a/tests/lib.sh |
94 |
+++ b/tests/lib.sh |
95 |
@@ -1,12 +1,17 @@ |
96 |
-# no out of tree building so shut it |
97 |
-srcdir=`cd "${0%/*}" && pwd` |
98 |
-top_srcdir=`cd "${srcdir}/../.." && pwd` |
99 |
-builddir=${srcdir} |
100 |
-top_builddir=${top_srcdir} |
101 |
+if [[ -z ${abs_top_builddir} ]] ; then |
102 |
+ srcdir=$(cd "${0%/*}" && pwd) |
103 |
+ top_srcdir=$(cd "${srcdir}/../.." && pwd) |
104 |
+ builddir=${srcdir} |
105 |
+ top_builddir=${top_srcdir} |
106 |
+else |
107 |
+ mkdir -p "${builddir}" |
108 |
+ top_srcdir=${abs_top_srcdir} |
109 |
+ top_builddir=${abs_top_builddir} |
110 |
+fi |
111 |
|
112 |
[ -e /etc/init.d/functions.sh ] && source /etc/init.d/functions.sh |
113 |
|
114 |
-PATH=${top_builddir}:${PATH} |
115 |
+PATH="${top_srcdir}:${top_builddir}:${PATH}" |
116 |
unset ROOT # who knows! |
117 |
|
118 |
ret=0 |
119 |
@@ -24,13 +29,13 @@ testit() { |
120 |
local tret=0 err |
121 |
case $# in |
122 |
1) |
123 |
- if [[ -s $1 ]] ; then |
124 |
+ if [[ -s ${builddir}/$1 ]] ; then |
125 |
tret=1 |
126 |
- err=$(<"$1") |
127 |
+ err=$(<"${builddir}/$1") |
128 |
fi |
129 |
;; |
130 |
2) |
131 |
- if ! err=$(diff -u "$1" "$2") ; then |
132 |
+ if ! err=$(diff -u "${builddir}/$1" "${srcdir}/$2") ; then |
133 |
tret=1 |
134 |
fi |
135 |
esac |
136 |
@@ -40,5 +45,5 @@ testit() { |
137 |
fail "$1" |
138 |
echo "${err}" |
139 |
fi |
140 |
- rm -f "$1" |
141 |
+ rm -f "${builddir}/$1" |
142 |
} |
143 |
|
144 |
diff --git a/tests/scanelf/dotest b/tests/scanelf/dotest |
145 |
index 19293f9..d06f086 100755 |
146 |
--- a/tests/scanelf/dotest |
147 |
+++ b/tests/scanelf/dotest |
148 |
@@ -6,7 +6,7 @@ |
149 |
# simple scanelf symbol checks |
150 |
# |
151 |
scanelf -qsmain -F'%s %f' "${top_builddir}"/scanelf \ |
152 |
- > scanelf.simple |
153 |
+ > "${builddir}"/scanelf.simple |
154 |
testit scanelf.simple{,.good} |
155 |
|
156 |
|
157 |
|
158 |
diff --git a/tests/source/dotest b/tests/source/dotest |
159 |
index 16297e2..4cbb54a 100755 |
160 |
--- a/tests/source/dotest |
161 |
+++ b/tests/source/dotest |
162 |
@@ -32,7 +32,7 @@ find "${top_srcdir}" \ |
163 |
-e '\<deamon\>' \ |
164 |
-e '\<derefernce\>' \ |
165 |
-e '\<lenght\>' \ |
166 |
- | sed -e "s:^\.\./\.\./::g" > src.typos |
167 |
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.typos |
168 |
testit src.typos |
169 |
|
170 |
|
171 |
@@ -42,7 +42,7 @@ testit src.typos |
172 |
# |
173 |
findfiles | xargs -0 \ |
174 |
grep -n -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes)\>[[:space:]]*\(' \ |
175 |
- | sed -e "s:^\.\./\.\./::g" > src.obsolete.funcs |
176 |
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.obsolete.funcs |
177 |
testit src.obsolete.funcs |
178 |
|
179 |
|
180 |
@@ -52,7 +52,7 @@ testit src.obsolete.funcs |
181 |
# |
182 |
findfiles | xargs -0 \ |
183 |
grep -n -E -e '\<PATH_MAX\>' | grep -v __PAX_UTILS_PATH_MAX \ |
184 |
- | sed -e "s:^\.\./\.\./::g" > src.bad.constants |
185 |
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.bad.constants |
186 |
testit src.bad.constants |
187 |
|
188 |
|
189 |
@@ -62,7 +62,7 @@ testit src.bad.constants |
190 |
# |
191 |
findfiles | xargs -0 \ |
192 |
grep -n -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \ |
193 |
- | sed -e "s:^\.\./\.\./::g" > src.obsolete.headers |
194 |
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.obsolete.headers |
195 |
testit src.obsolete.headers |
196 |
|
197 |
|
198 |
@@ -75,7 +75,7 @@ xfuncs=${xfuncs:0:${#xfuncs}-1} |
199 |
findfiles | xargs -0 \ |
200 |
grep -n -E -e "\<(${xfuncs})[[:space:]]*\(" \ |
201 |
| grep -v xfuncs.c \ |
202 |
- | sed -e "s:^\.\./\.\./::g" > src.use.xfuncs |
203 |
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.use.xfuncs |
204 |
testit src.use.xfuncs |
205 |
|
206 |
|
207 |
@@ -91,7 +91,7 @@ findfiles | xargs -0 \ |
208 |
-e '[[:space:]]$' \ |
209 |
-e '\){' \ |
210 |
-e '(^|[^:])//' \ |
211 |
- | sed -e "s:^\.\./\.\./::g" > src.style |
212 |
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.style |
213 |
testit src.style |
214 |
|
215 |
|
216 |
@@ -103,13 +103,13 @@ while read -d'\0' x; do |
217 |
case ${x} in |
218 |
*/elf.h) continue ;; # Not our files |
219 |
esac |
220 |
- ./space "$x" > "$x~" |
221 |
- if ! diff -u "$x" "$x~" ; then |
222 |
- echo "New file: $x~" |
223 |
+ ./space "${x}" > "${builddir}/${x}~" |
224 |
+ if ! diff -u "${x}" "${builddir}/${x}~" ; then |
225 |
+ echo "New file: ${x}~" |
226 |
else |
227 |
- rm -f "$x~" |
228 |
+ rm -f "${builddir}/${x}~" |
229 |
fi |
230 |
-done > src.space < <(findfiles) |
231 |
+done > "${builddir}"/src.space < <(findfiles) |
232 |
testit src.space |
233 |
|
234 |
|
235 |
@@ -118,7 +118,7 @@ testit src.space |
236 |
# Make sure we don't keep re-importing stuff into elf.h that |
237 |
# breaks non-GNU systems. #507470 |
238 |
# |
239 |
-grep -E "features.h|_DECLS" "${top_srcdir}"/elf.h > src.elf.h |
240 |
+grep -E "features.h|_DECLS" "${top_srcdir}"/elf.h > "${builddir}"/src.elf.h |
241 |
testit src.elf.h |
242 |
|
243 |
|
244 |
@@ -130,7 +130,7 @@ if pyflakes </dev/null 2>/dev/null; then |
245 |
find "${top_srcdir}" \ |
246 |
'!' -ipath '*/tests/*' \ |
247 |
-name '*.py' \ |
248 |
- -exec pyflakes {} + > src.pyflakes |
249 |
+ -exec pyflakes {} + > "${builddir}"/src.pyflakes |
250 |
testit src.pyflakes |
251 |
fi |