aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-12-16 20:00:44 -0500
committerMike Frysinger <vapier@gentoo.org>2015-12-16 20:00:44 -0500
commit706679c2071261848f964bb7b987de1bac466f46 (patch)
tree595420717fa1aff3384c4dd79295256f63f5ad65
parentbuild: defer man page expansion (diff)
downloadpax-utils-706679c2071261848f964bb7b987de1bac466f46.tar.gz
pax-utils-706679c2071261848f964bb7b987de1bac466f46.tar.bz2
pax-utils-706679c2071261848f964bb7b987de1bac466f46.zip
tests: add out-of-tree build support
-rw-r--r--tests/Makefile4
-rwxr-xr-xtests/lddtree/dotest.cmp20
-rw-r--r--tests/lddtree/dotest.sfx2
-rw-r--r--tests/lib.sh25
-rwxr-xr-xtests/scanelf/dotest2
-rwxr-xr-xtests/source/dotest26
6 files changed, 47 insertions, 32 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 1db7654..f4b81e8 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,8 +1,10 @@
SUBDIRS = $(patsubst %/Makefile,%,$(wildcard */Makefile))
+abs_top_srcdir = $(realpath $(PWD)/..)
+abs_top_builddir = $(realpath $(PWD)/..)
# DO NOT STARE AT THE SUN
all:
%:; $(MAKE) `printf '%s_$@_ ' $(SUBDIRS)`
_words = $(subst _, ,$1)
_dir = $(firstword $(call _words,$@))
_targ = $(lastword $(call _words,$@))
-%_:; $(MAKE) -C $(_dir) $(_targ)
+%_:; $(MAKE) -C $(_dir) $(_targ) srcdir=$(abs_top_srcdir)/tests/$(_dir) builddir=$(abs_top_builddir)/tests/$(_dir)
diff --git a/tests/lddtree/dotest.cmp b/tests/lddtree/dotest.cmp
index 2f04a55..89217fa 100755
--- a/tests/lddtree/dotest.cmp
+++ b/tests/lddtree/dotest.cmp
@@ -6,22 +6,30 @@
# make sure list output matches
#
for sfx in py sh ; do
- lddtree.${sfx} -l /bin/bash > lddtree.${sfx}.list &
+ lddtree.${sfx} -l /bin/bash > "${builddir}"/lddtree.${sfx}.list &
done
wait
-testit lddtree.*.list
-rm -f lddtree.*.list
+if diff -u "${builddir}"/lddtree.*.list ; then
+ pass "lddtree -l /bin/bash"
+else
+ fail "lddtree -l /bin/bash"
+fi
+rm -f "${builddir}"/lddtree.*.list
#
# Same as above but with the -a flag
#
for sfx in py sh ; do
- lddtree.${sfx} -l -a /bin/bash > lddtree.${sfx}.list-all &
+ lddtree.${sfx} -l -a /bin/bash > "${builddir}"/lddtree.${sfx}.list-all &
done
wait
-testit lddtree.*.list-all
-rm -f lddtree.*.list-all
+if diff -u "${builddir}"/lddtree.*.list-all ; then
+ pass "lddtree -l -a /bin/bash"
+else
+ fail "lddtree -l -a /bin/bash"
+fi
+rm -f "${builddir}"/lddtree.*.list-all
exit ${ret}
diff --git a/tests/lddtree/dotest.sfx b/tests/lddtree/dotest.sfx
index 1490434..fa82fd0 100644
--- a/tests/lddtree/dotest.sfx
+++ b/tests/lddtree/dotest.sfx
@@ -6,7 +6,7 @@
# smoke tests of sorts
#
lddtree.${sfx} /bin/bash | \
- grep -i 'none' > lddtree.${sfx}.smoke
+ grep -i 'none' > "${builddir}"/lddtree.${sfx}.smoke
testit lddtree.${sfx}.smoke
diff --git a/tests/lib.sh b/tests/lib.sh
index 93943a1..927e503 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -1,12 +1,17 @@
-# no out of tree building so shut it
-srcdir=`cd "${0%/*}" && pwd`
-top_srcdir=`cd "${srcdir}/../.." && pwd`
-builddir=${srcdir}
-top_builddir=${top_srcdir}
+if [[ -z ${abs_top_builddir} ]] ; then
+ srcdir=$(cd "${0%/*}" && pwd)
+ top_srcdir=$(cd "${srcdir}/../.." && pwd)
+ builddir=${srcdir}
+ top_builddir=${top_srcdir}
+else
+ mkdir -p "${builddir}"
+ top_srcdir=${abs_top_srcdir}
+ top_builddir=${abs_top_builddir}
+fi
[ -e /etc/init.d/functions.sh ] && source /etc/init.d/functions.sh
-PATH=${top_builddir}:${PATH}
+PATH="${top_srcdir}:${top_builddir}:${PATH}"
unset ROOT # who knows!
ret=0
@@ -24,13 +29,13 @@ testit() {
local tret=0 err
case $# in
1)
- if [[ -s $1 ]] ; then
+ if [[ -s ${builddir}/$1 ]] ; then
tret=1
- err=$(<"$1")
+ err=$(<"${builddir}/$1")
fi
;;
2)
- if ! err=$(diff -u "$1" "$2") ; then
+ if ! err=$(diff -u "${builddir}/$1" "${srcdir}/$2") ; then
tret=1
fi
esac
@@ -40,5 +45,5 @@ testit() {
fail "$1"
echo "${err}"
fi
- rm -f "$1"
+ rm -f "${builddir}/$1"
}
diff --git a/tests/scanelf/dotest b/tests/scanelf/dotest
index 19293f9..d06f086 100755
--- a/tests/scanelf/dotest
+++ b/tests/scanelf/dotest
@@ -6,7 +6,7 @@
# simple scanelf symbol checks
#
scanelf -qsmain -F'%s %f' "${top_builddir}"/scanelf \
- > scanelf.simple
+ > "${builddir}"/scanelf.simple
testit scanelf.simple{,.good}
diff --git a/tests/source/dotest b/tests/source/dotest
index 16297e2..4cbb54a 100755
--- a/tests/source/dotest
+++ b/tests/source/dotest
@@ -32,7 +32,7 @@ find "${top_srcdir}" \
-e '\<deamon\>' \
-e '\<derefernce\>' \
-e '\<lenght\>' \
- | sed -e "s:^\.\./\.\./::g" > src.typos
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.typos
testit src.typos
@@ -42,7 +42,7 @@ testit src.typos
#
findfiles | xargs -0 \
grep -n -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes)\>[[:space:]]*\(' \
- | sed -e "s:^\.\./\.\./::g" > src.obsolete.funcs
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.obsolete.funcs
testit src.obsolete.funcs
@@ -52,7 +52,7 @@ testit src.obsolete.funcs
#
findfiles | xargs -0 \
grep -n -E -e '\<PATH_MAX\>' | grep -v __PAX_UTILS_PATH_MAX \
- | sed -e "s:^\.\./\.\./::g" > src.bad.constants
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.bad.constants
testit src.bad.constants
@@ -62,7 +62,7 @@ testit src.bad.constants
#
findfiles | xargs -0 \
grep -n -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \
- | sed -e "s:^\.\./\.\./::g" > src.obsolete.headers
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.obsolete.headers
testit src.obsolete.headers
@@ -75,7 +75,7 @@ xfuncs=${xfuncs:0:${#xfuncs}-1}
findfiles | xargs -0 \
grep -n -E -e "\<(${xfuncs})[[:space:]]*\(" \
| grep -v xfuncs.c \
- | sed -e "s:^\.\./\.\./::g" > src.use.xfuncs
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.use.xfuncs
testit src.use.xfuncs
@@ -91,7 +91,7 @@ findfiles | xargs -0 \
-e '[[:space:]]$' \
-e '\){' \
-e '(^|[^:])//' \
- | sed -e "s:^\.\./\.\./::g" > src.style
+ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.style
testit src.style
@@ -103,13 +103,13 @@ while read -d'\0' x; do
case ${x} in
*/elf.h) continue ;; # Not our files
esac
- ./space "$x" > "$x~"
- if ! diff -u "$x" "$x~" ; then
- echo "New file: $x~"
+ ./space "${x}" > "${builddir}/${x}~"
+ if ! diff -u "${x}" "${builddir}/${x}~" ; then
+ echo "New file: ${x}~"
else
- rm -f "$x~"
+ rm -f "${builddir}/${x}~"
fi
-done > src.space < <(findfiles)
+done > "${builddir}"/src.space < <(findfiles)
testit src.space
@@ -118,7 +118,7 @@ testit src.space
# Make sure we don't keep re-importing stuff into elf.h that
# breaks non-GNU systems. #507470
#
-grep -E "features.h|_DECLS" "${top_srcdir}"/elf.h > src.elf.h
+grep -E "features.h|_DECLS" "${top_srcdir}"/elf.h > "${builddir}"/src.elf.h
testit src.elf.h
@@ -130,7 +130,7 @@ if pyflakes </dev/null 2>/dev/null; then
find "${top_srcdir}" \
'!' -ipath '*/tests/*' \
-name '*.py' \
- -exec pyflakes {} + > src.pyflakes
+ -exec pyflakes {} + > "${builddir}"/src.pyflakes
testit src.pyflakes
fi