1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
#!/bin/dash
# This needs installed:
# apt, dpkg-dev, ed, python3-apt, xz, lzma, python3, dbX.Y-util
# it will fail if run over a changing hour
set -e -u
export LC_ALL=C
SRCDIR="$(readlink -e "$(dirname $0)/..")"
WORKDIR="`pwd`/testdir"
USE_VALGRIND=""
VALGRIND_LEAK=summary
VALGRIND_EXTRA_OPTIONS=""
VALGRIND_SUP=""
TESTOPTIONS=""
VERBOSEDB="1"
TESTSHELLOPTS=
testtorun="all"
verbosity=6
deleteifmarked=true
while [ $# -gt 0 ] ; do
case "$1" in
--srcdir)
shift
SRCDIR="$(readlink -e "$1")"
shift
;;
--neverdelete)
deleteifmarked=false
shift
;;
--test)
shift
testtorun="$1"
shift
;;
--trace)
shift
TESTSHELLOPTS=-x
;;
--delete)
if ! $deleteifmarked ; then
rm -r "$WORKDIR" || true
fi
shift
;;
--valgrind)
USE_VALGRIND=1
shift
;;
--valgrind)
USE_VALGRIND=1
VALGRIND_LEAK=full
shift
;;
--valgrind-supp)
USE_VALGRIND=1
shift
VALGRIND_SUP="$1"
shift
;;
--valgrind-opts)
shift
VALGRIND_EXTRA_OPTIONS="${VALGRIND_EXTRA_OPTIONS} $1"
shift
;;
--verbosity)
shift
verbosity="$1"
shift
;;
--noverbosedb)
VERBOSEDB=""
shift
;;
--*)
echo "Unsupported option $1" >&2
exit 1
;;
*)
break
;;
esac
done
if [ "2" -lt "$#" ] ; then
echo "Syntax: test.sh [<testtool-binary>] [<reprepro-binary>]" >&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
exit 1
fi
TESTSDIR="$SRCDIR/tests"
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
# leak-check=full is better than leak-check=summary,
# sadly squeeze's valgrind counts them into the error number
# with full, and we want to ignore them for childs....
TESTOPTIONS="-e -a --debug ${VALGRIND_EXTRA_OPTIONS} --leak-check=${VALGRIND_LEAK} --suppressions=$TESTSDIR/valgrind.supp"
else
TESTOPTIONS="-e -a --debug ${VALGRIND_EXTRA_OPTIONS} --leak-check=${VALGRIND_LEAK} --suppressions=$VALGRIND_SUP"
fi
fi
case "$verbosity" in
-1) VERBOSITY="-s" ;;
0) VERBOSITY="" ;;
1) VERBOSITY="-v" ;;
2) VERBOSITY="-vv" ;;
3) VERBOSITY="-vvv" ;;
4) VERBOSITY="-vvvv" ;;
5) VERBOSITY="-vvvvv" ;;
6) VERBOSITY="-vvvvvv" ;;
*) echo "Unsupported verbosity $verbosity" >&2
exit 1
;;
esac
TESTOPTIONS="-D v=$verbosity $TESTOPTIONS"
REPREPROOPTIONS="$VERBOSITY"
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"
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
if ! which fakeroot >/dev/null 2>&1 ; then
echo "WARNING: fakeroot not installed, some tests might fail!"
fi
if ! which python3 >/dev/null 2>&1 ; then
echo "WARNING: python3 not installed, some tests might fail!"
fi
if ! which lzma >/dev/null 2>&1 ; then
echo "WARNING: lzma not installed, some tests might fail!"
fi
if ! which ed >/dev/null 2>&1 ; then
echo "WARNING: ed not installed, some tests might fail!"
fi
if ! which lunzip >/dev/null 2>&1 ; then
echo "WARNING: lunzip not installed, some tests might be incomplete!"
else
if ! which lzip >/dev/null 2>&1 ; then
echo "WARNING: lunzip installed but lunzip not, some tests might fail!"
fi
fi
if ! dpkg -s python3-apt | grep -q -s "Status: .* ok installed" ; then
echo "WARNING: python3-apt not installed, some tests might fail!"
fi
if ! dpkg -s dpkg-dev | grep -q -s "Status: .* ok installed" ; then
echo "WARNING: dpkg-dev not installed, most tests might fail!"
fi
mkdir "$WORKDIR" || exit 1
echo "Remove this file to avoid silent removal" > "$WORKDIR"/ThisDirectoryWillBeDeleted
cd "$WORKDIR"
# dpkg-deb doesn't like too restrictive directories
umask 022
number_tests=0
number_missing=0
number_success=0
number_skipped=0
number_failed=0
runtest() {
if ! test -f "$SRCDIR/tests/$1.test" ; then
echo "Cannot find $SRCDIR/tests/$1.test!" >&2
number_missing="$(( $number_missing + 1 ))"
return
fi
number_tests="$(( $number_tests + 1 ))"
echo "Running test '$1'.."
TESTNAME=" $1"
mkdir "dir_$1"
rc=0
( cd "dir_$1" || exit 1
export TESTNAME
export SRCDIR TESTSDIR
export TESTTOOL RREDTOOL REPREPRO
export TRACKINGTESTOPTIONS TESTOPTIONS REPREPROOPTIONS verbosity
WORKDIR="$WORKDIR/dir_$1" CALLEDFROMTESTSUITE=true dash $TESTSHELLOPTS "$SRCDIR/tests/$1.test"
) > "log_$1" 2>&1 || rc=$?
if test "$rc" -ne 0 ; then
number_failed="$(( $number_failed + 1 ))"
echo "test '$1' failed (see $WORKDIR/log_$1 for details)!" >&2
elif grep -q -s '^SKIPPED: ' "log_$1" ; then
number_skipped="$(( $number_skipped + 1 ))"
echo "test '$1' skipped:"
sed -n -e 's/^SKIPPED://p' "log_$1"
rm -r "dir_$1" "log_$1"
else
number_success="$(( $number_success + 1 ))"
rm -r "dir_$1" "log_$1"
fi
}
if test x"$testtorun" != x"all" ; then
runtest "$testtorun"
else
runtest export
runtest buildinfo
runtest updatepullreject
runtest descriptions
runtest easyupdate
runtest srcfilterlist
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
runtest includeasc
runtest listcodenames
fi
echo "$number_tests tests, $number_success succeded, $number_failed failed, $number_skipped skipped, $number_missing missing"
exit 0
|