]> git.saurik.com Git - apt.git/blame - test/libapt/run-tests
merge with my debian-sid branch
[apt.git] / test / libapt / run-tests
CommitLineData
e4a30974 1#!/bin/sh
e29a6bb1
DK
2set -e
3
47f9af4f 4DIR=$(readlink -f $(dirname $0))
f6bfb482 5echo "Compiling the tests …"
1c493315 6(cd $DIR && make)
f6bfb482
DK
7echo "Running all testcases …"
8LDPATH="$DIR/../../build/bin"
e29a6bb1 9EXT="_libapt_test"
682a3bf7
DK
10
11# detect if output is on a terminal (colorful) or better not
12if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
13 COLHIGH='\033[1;35m'
14 COLRESET='\033[0m'
15 TESTOKAY='\033[1;32mOKAY\033[0m'
16 TESTFAIL='\033[1;31mFAILED\033[0m'
17else
18 COLHIGH=''
19 COLRESET=''
20 TESTOKAY='OK'
21 TESTFAIL='###FAILED###'
22fi
23
e29a6bb1 24for testapp in $(ls ${LDPATH}/*$EXT)
e4a30974 25do
e29a6bb1 26 name=$(basename ${testapp})
682a3bf7 27 NAME="${COLHIGH}${name}${COLRESET}"
e29a6bb1
DK
28 tmppath=""
29
30 if [ $name = "GetListOfFilesInDir${EXT}" ]; then
31 # TODO: very-low: move env creation to the actual test-app
e29a6bb1
DK
32 tmppath=$(mktemp -d)
33 touch "${tmppath}/anormalfile" \
34 "${tmppath}/01yet-anothernormalfile" \
35 "${tmppath}/anormalapt.conf" \
36 "${tmppath}/01yet-anotherapt.conf" \
37 "${tmppath}/anormalapt.list" \
38 "${tmppath}/01yet-anotherapt.list" \
39 "${tmppath}/wrongextension.wron" \
40 "${tmppath}/wrong-extension.wron" \
41 "${tmppath}/strangefile." \
42 "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \
43 "${tmppath}/.hiddenfile" \
44 "${tmppath}/.hiddenfile.conf" \
45 "${tmppath}/.hiddenfile.list" \
46 "${tmppath}/multi..dot" \
47 "${tmppath}/multi.dot.conf" \
48 "${tmppath}/multi.dot.list" \
49 "${tmppath}/disabledfile.disabled" \
50 "${tmppath}/disabledfile.conf.disabled" \
51 "${tmppath}/disabledfile.list.disabled" \
52 "${tmppath}/invälid.conf" \
53 "${tmppath}/invalíd" \
54 "${tmppath}/01invalíd"
491058e3
DK
55 mkdir "${tmppath}/invaliddir" \
56 "${tmppath}/directory.conf" \
57 "${tmppath}/directory.list" \
58 "${tmppath}/directory.wron" \
59 "${tmppath}/directory.list.disabled"
e29a6bb1
DK
60 ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
61 ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
3f2d77b5 62 elif [ $name = "getLanguages${EXT}" ]; then
3f2d77b5
DK
63 tmppath=$(mktemp -d)
64 touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \
65 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
66 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
7cb28948
DK
67 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \
68 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE"
67dc3830
DK
69 elif [ $name = "HashSums${EXT}" ]; then
70 TMP="$(mktemp)"
71 dmesg > $TMP
72 echo -n "Testing with \033[1;35m${name}\033[0m ... "
73 LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m"
74 rm $TMP
75 continue
1e08114a
DK
76 elif [ $name = "CompareVersion${EXT}" ]; then
77 tmppath="${DIR}/versions.lst"
e29a6bb1
DK
78 fi
79
682a3bf7
DK
80 echo -n "Testing with ${NAME} "
81 LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "$TESTOKAY" || echo "$TESTFAIL"
e29a6bb1
DK
82
83 if [ -n "$tmppath" -a -d "$tmppath" ]; then
e29a6bb1
DK
84 rm -rf "$tmppath"
85 fi
e4a30974 86done