aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-02-14 01:14:17 +0000
committerMike Frysinger <vapier@gentoo.org>2010-02-14 01:14:17 +0000
commita5e549da56d6b6b738d020b1364e83ab36d1651f (patch)
tree9b5fbeb20403003313c1a17bac866af8f21ca61c /tests
parentmake sure we initialize new string memory (diff)
downloadpax-utils-a5e549da56d6b6b738d020b1364e83ab36d1651f.tar.gz
pax-utils-a5e549da56d6b6b738d020b1364e83ab36d1651f.tar.bz2
pax-utils-a5e549da56d6b6b738d020b1364e83ab36d1651f.zip
start some scanelf tests
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile2
-rw-r--r--tests/lib.sh35
-rw-r--r--tests/scanelf/Makefile8
-rwxr-xr-xtests/scanelf/dotest14
-rw-r--r--tests/scanelf/scanelf.simple.good1
-rwxr-xr-xtests/source/dotest35
6 files changed, 69 insertions, 26 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 8d78cfb..1a6bb22 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS = source
+SUBDIRS = $(patsubst %/Makefile,%,$(wildcard */Makefile))
.PHONY: all test check clean
all test check clean:
diff --git a/tests/lib.sh b/tests/lib.sh
new file mode 100644
index 0000000..97be2f0
--- /dev/null
+++ b/tests/lib.sh
@@ -0,0 +1,35 @@
+# no out of tree building so shut it
+srcdir=`cd "${0%/*}" && pwd`
+top_srcdir=`cd "${srcdir}/../.." && pwd`
+builddir=${srcdir}
+top_builddir=${top_srcdir}
+
+PATH=${top_builddir}:${PATH}
+
+[ -e /etc/init.d/functions.sh ] && source /etc/init.d/functions.sh
+
+ret=0
+
+testit() {
+ local tret=0 err
+ case $# in
+ 1)
+ if [ -s $1 ] ; then
+ tret=1
+ err=$(<$1)
+ fi
+ ;;
+ 2)
+ if ! err=`diff -u $1 $2` ; then
+ tret=1
+ fi
+ esac
+ if [ ${tret} -eq 0 ] ; then
+ echo ${GOOD}PASS${NORMAL}: $1
+ else
+ ret=1
+ echo ${BAD}FAIL${NORMAL}: $1
+ echo "${err}"
+ fi
+ rm -f $1
+}
diff --git a/tests/scanelf/Makefile b/tests/scanelf/Makefile
new file mode 100644
index 0000000..62084f0
--- /dev/null
+++ b/tests/scanelf/Makefile
@@ -0,0 +1,8 @@
+all: check
+
+test check:
+ ./dotest
+
+clean:
+
+.PHONY: all check clean test
diff --git a/tests/scanelf/dotest b/tests/scanelf/dotest
new file mode 100755
index 0000000..eec260b
--- /dev/null
+++ b/tests/scanelf/dotest
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+. "${0%/*}"/../lib.sh
+
+#
+# simple scanelf symbol checks
+#
+scanelf -qsmain -F'%s#F' "${top_builddir}"/scanelf \
+ > scanelf.simple
+testit scanelf.simple{,.good}
+
+
+
+exit ${ret}
diff --git a/tests/scanelf/scanelf.simple.good b/tests/scanelf/scanelf.simple.good
new file mode 100644
index 0000000..ba2906d
--- /dev/null
+++ b/tests/scanelf/scanelf.simple.good
@@ -0,0 +1 @@
+main
diff --git a/tests/source/dotest b/tests/source/dotest
index 17c86de..5a944c5 100755
--- a/tests/source/dotest
+++ b/tests/source/dotest
@@ -1,26 +1,11 @@
#!/bin/bash
-[ -e /etc/init.d/functions.sh ] && source /etc/init.d/functions.sh
-
-ret=0
-
-testit() {
- if [ -s $1 ] ; then
- echo ${BAD}FAIL${NORMAL}: $1
- cat $1
- rm -f $1
- ret=1
- return
- fi
- rm -f $1
- echo ${GOOD}PASS${NORMAL}: $1
-}
-
+. "${0%/*}"/../lib.sh
#
# check for misc common typos
#
-find ../.. \
+find "${top_srcdir}" \
'(' -type d -a '(' -name CVS -o -name tests ')' -prune ')' \
-o '(' -type f -a -print0 ')' | xargs -0 \
grep -n -I \
@@ -49,7 +34,7 @@ testit src.typos
#
# don't allow obsolete functions
#
-find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes)\>[[:space:]]*\(' \
| sed -e "s:^\.\./\.\./::g" > src.obsolete.funcs
testit src.obsolete.funcs
@@ -59,7 +44,7 @@ testit src.obsolete.funcs
#
# make sure people use our constants
#
-find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<PATH_MAX\>' | grep -v __PAX_UTILS_PATH_MAX \
| sed -e "s:^\.\./\.\./::g" > src.bad.constants
testit src.bad.constants
@@ -69,7 +54,7 @@ testit src.bad.constants
#
# don't allow obsolete headers
#
-find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \
| sed -e "s:^\.\./\.\./::g" > src.obsolete.headers
testit src.obsolete.headers
@@ -79,9 +64,9 @@ testit src.obsolete.headers
#
# make sure people use the x* helper funcs
#
-xfuncs=$(printf '%s|' $(sed -n 's:.*x\([^(]*\)(.*:\1:p' ../../xfuncs.h))
+xfuncs=$(printf '%s|' $(sed -n 's:.*x\([^(]*\)(.*:\1:p' "${top_srcdir}"/xfuncs.h))
xfuncs=${xfuncs:0:${#xfuncs}-1}
-find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e "\<(${xfuncs})[[:space:]]*\(" \
| grep -v xfuncs.c \
| sed -e "s:^\.\./\.\./::g" > src.use.xfuncs
@@ -91,7 +76,7 @@ testit src.use.xfuncs
#
# check for style
#
-find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
+find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E \
-e '\<(for|if|switch|while)\(' \
-e '\<(for|if|switch|while) \( ' \
@@ -105,8 +90,8 @@ testit src.style
# Stupid BSD makes us check for this..
if [ $(type -P md5sum) != "" ]; then
- for x in $(find ../.. '(' -name '*.c' -o -name '*.h' ')' ); do
- python space.py $x > $x~
+ for x in $(find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' ); do
+ python "${srcdir}"/space.py $x > $x~
if [[ $(md5sum $x | awk '{print $1}') != $(md5sum $x~ | awk '{print $1}') ]]; then
diff -u $x $x~
#cp $x~ $x