Commit 8e0a831b authored by Bernhard Link's avatar Bernhard Link

reorganize testsuite

- call the tests as seperate processes in their own directory
- report failed checks and store output in logfile instead of stdout
- remove some older cruft
parent b3e030ef
......@@ -5,35 +5,35 @@ dpkg-architecture \
genpackage.sh \
test.inc \
test.sh \
testatoms.sh \
testbuildneeding.sh \
testcheck.sh \
testcopy.sh \
testdiffgeneration.sh \
testexporthooks.sh \
testflat.sh \
testflood.sh \
testincludeextra.sh \
testlayeredupdate.sh \
testlayeredupdate2.sh \
testmorgue.sh \
testonlysmalldeletes.sh \
testoverride.sh \
testpackagediff.sh \
testsignatures.sh \
testsigned.sh \
testsnapshotcopyrestore.sh \
testsubcomponents.sh \
testtemplate.sh \
testtrackingcorruption.sh \
testuncompress.sh \
testupdatecorners.sh \
testuploaders.sh \
testvarious1.sh \
testvarious2.sh \
testvarious3.sh \
testverify.sh \
testwrongarch.sh \
atoms.test \
buildneeding.test \
check.test \
copy.test \
diffgeneration.test \
exporthooks.test \
flat.test \
flood.test \
includeextra.test \
layeredupdate.test \
layeredupdate2.test \
morgue.test \
onlysmalldeletes.test \
override.test \
packagediff.test \
signatures.test \
signed.test \
snapshotcopyrestore.test \
subcomponents.test \
template.test \
trackingcorruption.test \
uncompress.test \
updatecorners.test \
uploaders.test \
various1.test \
various2.test \
various3.test \
verify.test \
wrongarch.test \
tooltest.sh \
evil.key \
expired.key \
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
source $TESTSDIR/test.inc
# different tests to check the error messages when accessing
# architectures components or packagetypes...
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
mkdir conf
mkdir package-1.0
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
dodo test ! -d db
mkdir -p conf db pool
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
dodo test ! -e dists
mkdir conf db logs lists
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
# testing with Sources, as they are easier to generate...
if test -e "$RREDTOOL" ; then
if ! test -e "$RREDTOOL" ; then
echo "SKIPPED: rredtool not found, '$RREDTOOL' tried."
exit 0
fi
mkdir conf
cat > conf/distributions <<EOF
......@@ -279,17 +278,4 @@ rm 4.diff
rm -r old db pool conf dists pre_*.dsc pre_*.tar.gz test_1.dsc test_1.tar.gz results.expected patches
else
echo
echo
echo
echo
echo "WARNING: $RREDTOOL does not exists. cannot test diff generation"
echo
echo
echo
echo
echo
fi
testsuccess
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
mkdir conf
cat > conf/distributions <<EOF
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
dodo test ! -d db
mkdir -p conf
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
mkdir test-1
mkdir test-1/debian
......@@ -115,9 +111,9 @@ EOF
echo "with tracking is $tracking"
if $tracking ; then
echo "Tracking: minimal" >> conf/distributions
setoptions unchanged "" "" tracking
TRACKINGTESTOPTIONS="-D t=1"
else
setoptions unchanged "" ""
TRACKINGTESTOPTIONS="-D t=0"
fi
cat >> conf/distributions <<EOF
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
# first create a fake package with logs and byhand files:
mkdir documentation-9876AD
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
dodo test ! -d db
mkdir -p conf dists
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
dodo test ! -d db
mkdir -p conf dists
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
mkdir conf
cat > conf/options <<EOF
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
mkdir conf
cat >conf/distributions <<EOF
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
mkdir -p conf dists/{c,d}/{main,component}/{source,binary-${FAKEARCHITECTURE}}
mkdir -p dists/{c,d}/main/{source,binary-abacus}
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
mkdir conf db pool fakes old
mkdir -p dists/sourcedistribution/main/binary-coal
......
#!/bin/bash
set -u
source $TESTSDIR/test.inc
set -e
if test "${MAINTESTOPTIONS+set}" != set ; then
source $(dirname $0)/test.inc
STANDALONE="true"
else
STANDALONE=""
if ! which gpg 2>/dev/null ; then
echo "SKIPPED: gpg not found!"
exit 0
fi
rm -rf db dists pool lists conf gpgtestdir
mkdir -p gpgtestdir
export GNUPGHOME="`pwd`/gpgtestdir"
gpg --import $SRCDIR/tests/good.key $SRCDIR/tests/evil.key $SRCDIR/tests/expired.key $SRCDIR/tests/revoked.key
gpg --import $TESTSDIR/good.key $TESTSDIR/evil.key $TESTSDIR/expired.key $TESTSDIR/revoked.key
mkdir -p conf
cat > conf/options <<CONFEND
......@@ -77,7 +74,7 @@ mv test.changes.asc testsigned.changes
echo generating signature with revoked key:
gpg --expert --default-key revoked@nowhere.tld --sign -a test.changes
mv test.changes.asc testrevsigned.changes
gpg --import $SRCDIR/tests/revoked.pkey
gpg --import $TESTSDIR/revoked.pkey
testrun - -b . include ATest test.changes 3<<EOF
......@@ -309,10 +306,4 @@ EOF
rm -rf db conf dists pool gpgtestdir i tmp
rm package-addons* package_* *.changes
if test x$STANDALONE = xtrue ; then
set +v +x
echo
echo "If the script is still running to show this,"
echo "all tested cases seem to work. (Though writing some tests more can never harm)."
fi
exit 0
testsuccess
#!/bin/bash
set -e
if test "${MAINTESTOPTIONS+set}" != set ; then
source $(dirname $0)/test.inc
STANDALONE="true"
else
STANDALONE=""
fi
rm -rf db dists pool lists conf gpgtestdir
set -u
source $TESTSDIR/test.inc
mkdir -p gpgtestdir
export GNUPGHOME="`pwd`/gpgtestdir"
gpg --import $SRCDIR/tests/good.key
gpg --import $TESTSDIR/good.key
mkdir -p conf
cat > conf/distributions <<CONFEND
......@@ -75,10 +65,4 @@ dodiff dists/ATest/Release InRelease
rm -r conf db dists gpgtestdir InRelease results results.expected
if test x$STANDALONE = xtrue ; then
set +v +x
echo
echo "If the script is still running to show this,"
echo "all tested cases seem to work. (Though writing some tests more can never harm)."
fi
exit 0
testsuccess
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
mkdir -p conf
cat > conf/distributions <<CONFEND
......
#!/bin/bash
set -e
if [ "x$TESTINCSETUP" != "xissetup" ] ; then
source $(dirname $0)/test.inc
fi
set -u
source $TESTSDIR/test.inc
dodo test ! -d db
testrun - -b . _versioncompare 0 1 3<<EOF
......
set -u
source $TESTSDIR/test.inc
testsuccess
# Shell script snippets used in the test scripts...
set -e
set -e -u
export LC_ALL=C
......@@ -8,22 +8,22 @@ testrun() {
rules=$1
shift
if test "x$rules" = "x" ; then
"$TESTTOOL" -C $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
"$TESTTOOL" -C $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
elif test "x$rules" = "x-" ; then
"$TESTTOOL" -r -C $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
"$TESTTOOL" -r -C $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
else
"$TESTTOOL" -r -C $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@" 3<"$rules".rules
"$TESTTOOL" -r -C $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@" 3<"$rules".rules
fi
}
testout() {
rules=$1
shift
if test "x$rules" = "x" ; then
"$TESTTOOL" -o results $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
"$TESTTOOL" -o results $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
elif test "x$rules" = "x-" ; then
"$TESTTOOL" -o results -r $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
"$TESTTOOL" -o results -r $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
else
"$TESTTOOL" -o results -r $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@" 3<"$rules".rules
"$TESTTOOL" -o results -r $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@" 3<"$rules".rules
fi
}
dogrep() {
......@@ -43,220 +43,32 @@ echo "$@"
"$@"
}
function setverbosity() {
if test "x$1" = "xdefault" ; then
set -- "$DEFAULTVERBOSITY"
fi
case "$1" in
-1)
VERBOSITYOPTIONS="-D v=-1"
VERBOSITY="-s"
verbosity=-1
;;
0)
VERBOSITYOPTIONS="-D v=0"
VERBOSITY=""
verbosity=0
;;
1)
VERBOSITYOPTIONS="-D v=1"
VERBOSITY="-v"
verbosity=1
;;
2)
VERBOSITYOPTIONS="-D v=2"
VERBOSITY="-vv"
verbosity=2
;;
3)
VERBOSITYOPTIONS="-D v=3"
VERBOSITY="-vvv"
verbosity=3
;;
4)
VERBOSITYOPTIONS="-D v=4"
VERBOSITY="-vvvv"
verbosity=4
;;
5)
VERBOSITYOPTIONS="-D v=5"
VERBOSITY="-vvvvv"
verbosity=5
;;
6)
VERBOSITYOPTIONS="-D v=6"
VERBOSITY="-vvvvvv"
verbosity=6
;;
unchanged)
;;
*)
echo "Unsupported verbosity" >&2
exit 1
;;
esac
}
FAKEARCHITECTURE=abacus
SRCDIR="$(readlink -e "$(dirname $0)/..")"
WORKDIR="`pwd`/testdir"
USE_VALGRIND=""
VALGRIND_SUP=""
VERBOSEDB="1"
DEFAULTVERBOSITY=6
deleteifmarked=true
while [ $# -gt 0 ] ; do
case "$1" in
--srcdir)
shift
SRCDIR="$(readlink -e "$1")"
shift
;;
--neverdelete)
deleteifmarked=false
shift
;;
--delete)
if ! $deleteifmarked ; then
rm -r "$WORKDIR" || true
fi
shift
;;
--valgrind)
USE_VALGRIND=1
shift
;;
--valgrind-supp)
USE_VALGRIND=1
shift
VALGRIND_SUP="$1"
shift
;;
--fake-architecture)
shift
FAKEARCHITECTURE="$1"
shift
;;
--verbosity)
shift
DEFAULTVERBOSITY="$1"
shift
;;
--noverbosedb)
VERBOSEDB=""
shift
;;
--*)
echo "Unsupported option $1" >&2
exit 1
;;
*)
break
;;
esac
done
export FAKEARCHITECTURE
export FALEN=${#FAKEARCHITECTURE}
# new dpkg-dev supports a fake architecture without tricks (and the old tricks no longer work):
export DEB_HOST_ARCH="$FAKEARCHITECTURE"
if [ "2" -lt "$#" ] ; then
echo "Syntax: test.sh [<testtool-binary>] [<reprepro-binary>]" >&2
if test -z "$SRCDIR" || ! test -d "$SRCDIR" ; then
echo "SRCDIR='$SRCDIR' not a valid directory!" >&2
exit 1
fi
echo "SRCDIR is '$SRCDIR'"
if [ ! -d "$SRCDIR" ] || [ ! -d "$SRCDIR/tests" ] ; then
echo "Error: Could not find source directory (tried: '$SRCDIR')!" >&2
if test -z "$TESTSDIR" || ! test -d "$TESTSDIR" ; then
echo "TESTSDIR='$TESTSDIR' not a valid directory!" >&2
exit 1
fi
if [ "1" -le "$#" ] ; then
TESTTOOL="$(readlink -e "$1")"
else
TESTTOOL=testtool
fi
if [ "2" -le "$#" ] ; then
REPREPRO="$(readlink -e "$2")"
else
REPREPRO="$SRCDIR/reprepro"
fi
RREDTOOL="$(dirname "$REPREPRO")/rredtool"
if [ -z "$TESTOPTIONS" ] ; then
if [ -z "$USE_VALGRIND" ] ; then
TESTOPTIONS="-e -a"
elif [ -z "$VALGRIND_SUP" ] ; then
TESTOPTIONS="-e -a --debug --leak-check=full --suppressions=$SRCDIR/valgrind.supp"
else
TESTOPTIONS="-e -a --debug --leak-check=full --suppressions=$VALGRIND_SUP"
fi
if test -z "$WORKDIR" || ! test -d "$WORKDIR" ; then
echo "WORKDIR='$WORKDIR' not a valid directory!" >&2
exit 1
fi
MAINTESTOPTIONS="$TESTOPTIONS"
export FAKEARCHITECTURE
export FALEN=${#FAKEARCHITECTURE}
# new dpkg-dev supports a fake architecture without tricks (and the old tricks no longer work):
export DEB_HOST_ARCH="$FAKEARCHITECTURE"
function setoptions() {
if test $# -lt 3 ; then
echo "setoptions: Wrong argument count!" >&2
exit 1
fi
setverbosity "$1"
shift
TESTOPTIONS="$1 $VERBOSITYOPTIONS $MAINTESTOPTIONS"
shift
REPREPROOPTIONS="$1 $VERBOSITY"
shift
if test -n "$VERBOSEDB" ; then
TESTOPTIONS="-D x=0 -D d=1 $TESTOPTIONS"
REPREPROOPTIONS="--verbosedb $REPREPROOPTIONS"
else
TESTOPTIONS="-D x=0 -D d=0 $TESTOPTIONS"
fi
TRACKINGTESTOPTIONS="-D t=0"
while test $# -gt 0 ; do
case $1 in
tracking)
if test -n "$VERBOSEDB" ; then
TRACKINGTESTOPTIONS="-D t=1"
fi
;;
*)
echo "setoptions: unsupported third argument!" >&2
exit 1
;;
esac
shift
done
TESTOPTIONS="$TRACKINGTESTOPTIONS $TESTOPTIONS"
echo testoptions are set to: $TESTOPTIONS
echo reprepro options are set to: $REPREPROOPTIONS
}
export PATH="$SRCDIR/tests:$PATH"
export PATH="$TESTSDIR:$PATH"
if ! [ -x "$REPREPRO" ] ; then
echo "Could not find $REPREPRO!" >&2
exit 1
fi
TESTTOOLVERSION="`$TESTTOOL --version`"
case $TESTTOOLVERSION in
"testtool version "*) ;;
*) echo "Failed to get version of testtool($TESTTOOL)"
exit 1
;;
esac
if test -d "$WORKDIR" && test -f "$WORKDIR/ThisDirectoryWillBeDeleted" && $deleteifmarked ; then
rm -r "$WORKDIR" || exit 3
fi
mkdir "$WORKDIR" || exit 1
echo "Remove this file to avoid silent removal" > "$WORKDIR"/ThisDirectoryWillBeDeleted
cd "$WORKDIR"
touch results.empty
cat > empty.rules <<EOF
stdout
stderr
returns 0
EOF
function checknolog() {
dodo test ! -f logs/"$1"
}
......@@ -359,14 +171,13 @@ EMPTYSHA2="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0"
EMPTYGZSHA2="59869db34853933b239f1e2219cf7d431da006aa919635478511fabbfc8849d2 20"
EMPTYBZ2SHA2="d3dda84eb03b9738d118eb2be78e246106900493c0ae07819ad60815134a8058 14"
function runtest() {
echo "Running test '$1'.."
TESTNAME=" $1"
source "$SRCDIR/tests/test$1.sh"
}
function testsuccess() {
echo "Test$TESTNAME completed successfully"
}
setoptions default "" ""
TESTINCSETUP=issetup
cat > empty.rules <<EOF
stdout
stderr
returns 0
EOF
......@@ -4,38 +4,211 @@
# apt, dpkg-dev, ed, python-apt, lzma
# it will fail if run over a changing hour
set -e
source $(dirname $0)/test.inc
runtest uploaders
runtest wrongarch
runtest flood
runtest exporthooks
runtest updatecorners
runtest packagediff
runtest includeextra
runtest atoms
runtest trackingcorruption
runtest layeredupdate
runtest layeredupdate2
runtest uncompress
runtest check
runtest flat
runtest subcomponents
runtest snapshotcopyrestore
runtest various1
runtest various2
runtest various3
runtest copy
runtest buildneeding
runtest morgue
runtest diffgeneration
runtest onlysmalldeletes
runtest override
set +v +x
echo
echo "If the script is still running to show this,"
echo "all tested cases seem to work. (Though writing some tests more can never harm)."
set -e -u
export LC_ALL=C
SRCDIR="$(readlink -e "$(dirname $0)/..")"
WORKDIR="`pwd`/testdir"
USE_VALGRIND=""
VALGRIND_SUP=""
TESTOPTIONS=""
VERBOSEDB="1"
testtorun="all"
verbosity=6
deleteifmarked=true
while [ $# -gt 0 ] ; do
case "$1" in
--srcdir)
shift
SRCDIR="$(readlink -e "$1")"
shift