aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-12-22 19:30:46 +0000
committerMike Frysinger <vapier@gentoo.org>2011-12-22 19:30:46 +0000
commite436cbd9649f3c61cc88b59452944a0df1c14436 (patch)
treebcab471501730a39e04f7d2396dc6b1aafc93004
parentignore generated files (diff)
downloadportage-utils-e436cbd9649f3c61cc88b59452944a0df1c14436.tar.gz
portage-utils-e436cbd9649f3c61cc88b59452944a0df1c14436.tar.bz2
portage-utils-e436cbd9649f3c61cc88b59452944a0df1c14436.zip
redo test output to get info on a per-test basis
-rwxr-xr-xtests/atom_explode/dotest9
-rw-r--r--tests/init.sh34
-rwxr-xr-xtests/install/dotest15
-rwxr-xr-xtests/mkdir/dotest12
-rwxr-xr-xtests/qfile/dotest7
-rwxr-xr-xtests/qlist/dotest30
-rwxr-xr-xtests/qtbz2/dotest23
-rwxr-xr-xtests/quse/dotest7
-rwxr-xr-xtests/qxpak/dotest21
-rwxr-xr-xtests/reinitialize/dotest5
-rwxr-xr-xtests/source/dotest9
11 files changed, 111 insertions, 61 deletions
diff --git a/tests/atom_explode/dotest b/tests/atom_explode/dotest
index 23241eb..3b134e2 100755
--- a/tests/atom_explode/dotest
+++ b/tests/atom_explode/dotest
@@ -25,8 +25,7 @@ printf "portage:"
time echo "${files}" | "$s"/atom-explode.py > "$b"/py || exit $?
echo
-if diff -U 0 "$b"/me "$b"/py ; then
- pass
-else
- fail
-fi
+diff -U 0 "$b"/me "$b"/py
+tend $? "portage-utils vs portage atom parsing"
+
+end
diff --git a/tests/init.sh b/tests/init.sh
index ce8812f..f700598 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -30,20 +30,40 @@ unset ROOT PORTAGE_CONFIGROOT PORTAGE_QUIET
q -i -q
-fail() {
- echo "${BAD}FAILED:${NORMAL} $*"
- exit 1
+tret=0
+tpassed=0
+tfailed=0
+
+tfail() {
+ echo "${BAD}FAIL:${NORMAL} $*"
+ : $(( ++tfailed ))
+ tret=1
+ return 1
+}
+tpass() {
+ echo "${GOOD}PASS:${NORMAL} $*"
+ : $(( ++tpassed ))
+ return 0
+}
+tend() {
+ local r=$1; shift
+ [[ $r -eq 0 ]] && tpass "$@" || tfail "$@"
+ return $r
+}
+
+die() {
+ tfail "$@"
+ end
}
-die() { fail "$@" ; }
skip() {
echo "${WARN}SKIPPED:${NORMAL} $*"
exit 0
}
-pass() {
- echo "${GOOD}PASSED:${NORMAL} ${PWD##*/}"
- exit 0
+end() {
+ echo "${HILITE}${PWD##*/}:${NORMAL} ${tpassed} passes / ${tfailed} fails"
+ exit ${tret}
}
mktmpdir() {
diff --git a/tests/install/dotest b/tests/install/dotest
index 63ce482..0502a45 100755
--- a/tests/install/dotest
+++ b/tests/install/dotest
@@ -14,15 +14,20 @@ rm -f ${applets}
if ! ln -f `which q` ; then
skip "could not 'ln -f'"
fi
-./q -i || die "./q -i"
+f./q -i || die "./q -i"
for app in ${applets} ; do
- [ ! -e $app ] && die "$app does not exist"
- if [ "$app" != "q" ] ; then
+ if [ ! -e $app ] ; then
+ tfail "$app does not exist"
+ elif [ "$app" != "q" ] ; then
t=$(readlink $app)
- [ "$t" != "q" ] && die "$app target is not 'q', it is '$t'"
+ if [ "$t" != "q" ] ; then
+ tfail "$app target is not 'q', it is '$t'"
+ else
+ tpass "${app}"
+ fi
fi
done
rm ${applets}
-pass
+end
diff --git a/tests/mkdir/dotest b/tests/mkdir/dotest
index ef62059..1034aa3 100755
--- a/tests/mkdir/dotest
+++ b/tests/mkdir/dotest
@@ -10,6 +10,7 @@ mktmpdir
# check mkdir
m="${_m} m"
for d in a a/ a/b a/b/ a/b/c a/b/c/ ; do
+ _d=${d}
$m ${d}
rmdir ${d}
@@ -18,9 +19,12 @@ for d in a a/ a/b a/b/ a/b/c a/b/c/ ; do
d=${d%/*}
rmdir ${d}
done
+
+ tpass "empty ${_d}"
done
for d in a a/ a/b a/b/ a/b/c a/b/c/ ; do
+ _d=${d}
mkdir -p ${d}
$m ${d}
@@ -30,6 +34,8 @@ for d in a a/ a/b a/b/ a/b/c a/b/c/ ; do
d=${d%/*}
rmdir ${d}
done
+
+ tpass "exist ${_d}"
done
# check rm_rf
@@ -38,16 +44,19 @@ m="${_m} rm"
mkdir -p a/b/c/d
$m a/b/
rmdir a
+tpass "rm a/b/"
mkdir -p a/b/c/d
$m a/b
rmdir a
+tpass "rm a/b"
mkdir -p a/b/c/d
cd a
$m . || : # ignore EBUSY failure
cd ..
rmdir a
+tpass "rm ."
mkdir -p a/b/c/d
ln -s . a/b/d
@@ -58,7 +67,8 @@ touch a/b/f
ln -s ../f a/b/c/f
$m a
[ ! -e a ]
+tpass "rm a tree"
cleantmpdir
-pass
+end
diff --git a/tests/qfile/dotest b/tests/qfile/dotest
index 084259d..0206d09 100755
--- a/tests/qfile/dotest
+++ b/tests/qfile/dotest
@@ -34,14 +34,13 @@ while [[ $# -gt 0 ]] ; do
exp=$1; shift
res=$(eval ${test})
- if [[ "${res}" != "${exp}" ]] ; then
+ [[ "${res}" == "${exp}" ]]
+ if ! tend $? "${test}" ; then
(
- echo "Test failed: ${test}"
echo " - expected result was: ${exp}"
echo " - actual result was: ${res}"
) > /dev/stderr
- fail
fi
done
-pass
+end
diff --git a/tests/qlist/dotest b/tests/qlist/dotest
index 39f8e9c..8a4d183 100755
--- a/tests/qlist/dotest
+++ b/tests/qlist/dotest
@@ -9,34 +9,34 @@ export Q_VDB=/
mktmpdir
+test() {
+ local num=$1; shift
+ eval "$@" > list
+ diff -u list ${as}/list${num}.good
+ tend $? "$*"
+}
+
# simple install check
-qlist -IC | grep -v CVS > list
-diff -u list ${as}/list01.good
+test 01 "qlist -IC | grep -v CVS"
# simple files list
-qlist -C cpio > list
-diff -u list ${as}/list02.good
+test 02 "qlist -C cpio"
# symlink verbose list
-qlist -C mtools -e -v > list
-diff -u list ${as}/list03.good
+test 03 "qlist -C mtools -e -v"
# dir test
-qlist -C mtools -d > list
-diff -u list ${as}/list04.good
+test 04 "qlist -C mtools -d"
# obj test
-qlist -C mtools -o > list
-diff -u list ${as}/list05.good
+test 05 "qlist -C mtools -o"
# sym test
-qlist -C mtools -s > list
-diff -u list ${as}/list06.good
+test 06 "qlist -C mtools -s"
# SLOT test
-qlist -ICSL | grep -v CVS > list
-diff -u list ${as}/list07.good
+test 07 "qlist -ICSL | grep -v CVS"
cleantmpdir
-pass
+end
diff --git a/tests/qtbz2/dotest b/tests/qtbz2/dotest
index 123f7d4..1f10ac1 100755
--- a/tests/qtbz2/dotest
+++ b/tests/qtbz2/dotest
@@ -30,33 +30,38 @@ raw_tar_check()
rm $1
}
-# check basic creation
+################
qtbz2 -j tarbz2 xpak tbz2
raw_tar_check tbz2
+tpass "check basic creation"
-# check basic creation with dir change
+################
mkdir new
cd new
qtbz2 -j tarbz2 xpak tbz2 -d ..
raw_tar_check tbz2
cd ..
rmdir new
+tpass "check basic creation with dir change"
-# check basic creation (with guess)
+################
qtbz2 -j tarbz2 xpak
raw_tar_check tarbz2.tbz2
+tpass "check basic creation (with guess)"
-# check basic creation (with better guess)
+################
mv tarbz2 x.tar.bz2
mv xpak x.xpak
qtbz2 -j x.tar.bz2 x.xpak
raw_tar_check x.tbz2
+tpass "check basic creation (with better guess)"
-# check basic creation (with best guess)
+################
qtbz2 -j x.tar.bz2
raw_tar_check x.tbz2
+tpass "check basic creation (with best guess)"
-# check basic splitting
+################
qtbz2 -j x.tar.bz2
mkdir new
cd new
@@ -66,15 +71,17 @@ cmp {.,..}/x.xpak
rm x.{xpak,tar.bz2}
cd ..
rmdir new
+tpass "check basic splitting"
-# check basic splitting to diff dir
+################
mkdir new
qtbz2 -s x.tbz2 -d new
cmp {.,new}/x.tar.bz2
cmp {.,new}/x.xpak
rm new/x.{xpak,tar.bz2}
rmdir new
+tpass "check basic splitting to diff dir"
cleantmpdir
-pass
+end
diff --git a/tests/quse/dotest b/tests/quse/dotest
index 2fa7309..139e881 100755
--- a/tests/quse/dotest
+++ b/tests/quse/dotest
@@ -25,6 +25,7 @@ done
quse -CD ${all} > x
diff -u x all.good
rm x good all.good
+tpass "arch.list"
# check use.desc
f="$d/use.desc"
@@ -38,6 +39,7 @@ done
quse -CD ${all} > x
diff -u x all.good
rm x good all.good
+tpass "use.desc"
# check use.local.desc
f="$d/use.local.desc"
@@ -51,6 +53,7 @@ done
quse -CD ${all} > x
diff -u x all.good
rm x good all.good
+tpass "use.local.desc"
# check desc subdir
f="$d/desc/elibc.desc"
@@ -64,6 +67,7 @@ done
quse -CD ${all} > x
diff -u x all.good
rm x good all.good
+tpass "desc/elibc.desc"
# check cross file matches
# sort because quse order depends on the readdir order
@@ -72,11 +76,12 @@ rm x good all.good
quse -CD abc | LC_ALL=C sort > x
diff -u ${as}/list01.good x
rm x
+tpass "multi file match"
trimtmpdir
###### faster test needed.########
-pass
+end
##################################
type -p mksquashfs || exit 0
diff --git a/tests/qxpak/dotest b/tests/qxpak/dotest
index e479c46..c892c84 100755
--- a/tests/qxpak/dotest
+++ b/tests/qxpak/dotest
@@ -11,45 +11,50 @@ for l in ${files} ; do
echo $l > $l
done
-# check basic creation
+################
qxpak -c xpak ${files}
qxpak -l -v xpak > list
diff -u list ${as}/list01.good
+tpass "check basic creation"
-# check single extraction
+################
for l in ${files} ; do
mv $l $l.good
qxpak -x xpak $l
diff -u $l $l.good
+ tpass "single file extraction: $l"
done
-# check multiple extraction
+################
rm ${files}
qxpak -x xpak ${files}
for l in ${files} ; do
diff -u $l $l.good
done
+tpass "multi file extraction"
-# check unpacking to diff dir
+################
mkdir new
qxpak -d new -x xpak ${files}
for l in ${files} ; do
diff -u $l new/$l
done
+tpass "check unpacking to diff dir"
-# check creating from diff dir
+################
rm -f ${files} ?.good
qxpak -c xpak -d new ${files}
qxpak -l -v xpak > list
diff -u list ${as}/list01.good
qxpak -d . -x xpak ${files}
+tpass "check creating from diff dir"
-# check creation with clobbered output
-# check creation with file order
+################
qxpak -c xpak `echo ${files} | tr ' ' '\n' | tac`
qxpak -l -v xpak > list
diff -u list ${as}/list02.good
+tpass "check creation with clobbered output and file order"
cleantmpdir
-pass
+end
diff --git a/tests/reinitialize/dotest b/tests/reinitialize/dotest
index 5c21457..c4e3a50 100755
--- a/tests/reinitialize/dotest
+++ b/tests/reinitialize/dotest
@@ -2,4 +2,7 @@
. ../init.sh
-q -Cr && pass || fail
+q -Cr
+tend $? "q -CR"
+
+end
diff --git a/tests/source/dotest b/tests/source/dotest
index 6d65adb..2db78c2 100755
--- a/tests/source/dotest
+++ b/tests/source/dotest
@@ -2,18 +2,15 @@
. ../init.sh
-ret=0
-
testit() {
if [ -s $1 ] ; then
- echo "${BAD}FAIL:${NORMAL} $1"
+ tfail "$1"
cat $1
rm -f $1
- ret=1
return
fi
rm -f $1
- echo "${GOOD}PASS:${NORMAL} $1"
+ tpass "$1"
}
prune=(
@@ -149,4 +146,4 @@ for x in $(find ${ats} "${src_files[@]}" -print); do
done > src.space
testit src.space
-exit ${ret}
+end