]> git.saurik.com Git - apt.git/blame - test/libapt/run-tests
merged lp:~mvo/apt/add-missing-dsc-hashes
[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"
d4ddc5b9 10EXIT_CODE=0
682a3bf7
DK
11
12# detect if output is on a terminal (colorful) or better not
13if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
14 COLHIGH='\033[1;35m'
15 COLRESET='\033[0m'
16 TESTOKAY='\033[1;32mOKAY\033[0m'
17 TESTFAIL='\033[1;31mFAILED\033[0m'
18else
19 COLHIGH=''
20 COLRESET=''
21 TESTOKAY='OK'
22 TESTFAIL='###FAILED###'
23fi
24
e29a6bb1 25for testapp in $(ls ${LDPATH}/*$EXT)
e4a30974 26do
e29a6bb1 27 name=$(basename ${testapp})
682a3bf7 28 NAME="${COLHIGH}${name}${COLRESET}"
e29a6bb1
DK
29 tmppath=""
30
31 if [ $name = "GetListOfFilesInDir${EXT}" ]; then
32 # TODO: very-low: move env creation to the actual test-app
e29a6bb1
DK
33 tmppath=$(mktemp -d)
34 touch "${tmppath}/anormalfile" \
35 "${tmppath}/01yet-anothernormalfile" \
36 "${tmppath}/anormalapt.conf" \
37 "${tmppath}/01yet-anotherapt.conf" \
38 "${tmppath}/anormalapt.list" \
39 "${tmppath}/01yet-anotherapt.list" \
40 "${tmppath}/wrongextension.wron" \
41 "${tmppath}/wrong-extension.wron" \
42 "${tmppath}/strangefile." \
43 "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \
44 "${tmppath}/.hiddenfile" \
45 "${tmppath}/.hiddenfile.conf" \
46 "${tmppath}/.hiddenfile.list" \
47 "${tmppath}/multi..dot" \
48 "${tmppath}/multi.dot.conf" \
49 "${tmppath}/multi.dot.list" \
50 "${tmppath}/disabledfile.disabled" \
51 "${tmppath}/disabledfile.conf.disabled" \
52 "${tmppath}/disabledfile.list.disabled" \
53 "${tmppath}/invälid.conf" \
54 "${tmppath}/invalíd" \
55 "${tmppath}/01invalíd"
491058e3
DK
56 mkdir "${tmppath}/invaliddir" \
57 "${tmppath}/directory.conf" \
58 "${tmppath}/directory.list" \
59 "${tmppath}/directory.wron" \
60 "${tmppath}/directory.list.disabled"
e29a6bb1
DK
61 ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
62 ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
3f2d77b5 63 elif [ $name = "getLanguages${EXT}" ]; then
3f2d77b5
DK
64 tmppath=$(mktemp -d)
65 touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \
66 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
67 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
7cb28948 68 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \
527df5a2
DK
69 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE" \
70 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tlh%5fDE"
67dc3830 71 elif [ $name = "HashSums${EXT}" ]; then
809cf6d2 72 TMP="$(readlink -f "./${0}")"
b058a788
DK
73 echo -n "Testing with ${NAME} "
74 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 "$TESTOKAY" || echo "$TESTFAIL"
67dc3830 75 continue
1e08114a
DK
76 elif [ $name = "CompareVersion${EXT}" ]; then
77 tmppath="${DIR}/versions.lst"
2c405a44
DK
78 elif [ $name = "CdromFindPackages${EXT}" ]; then
79 tmppath=$(mktemp -d)
80 mkdir -p "${tmppath}/.disk" "${tmppath}/pool" \
81 "${tmppath}/dists/stable/main/binary-i386" \
82 "${tmppath}/dists/stable/main/source" \
83 "${tmppath}/dists/stable/contrib/binary-amd64" \
84 "${tmppath}/dists/stable/contrib/binary-all" \
85 "${tmppath}/dists/unstable/main/binary-i386" \
86 "${tmppath}/dists/unstable/main/i18n" \
87 "${tmppath}/dists/unstable/main/source" \
88 "${tmppath}/dists/broken/non-free/source"
89 touch "${tmppath}/dists/broken/.aptignr" \
90 "${tmppath}/dists/stable/main/binary-i386/Packages" \
eed564b8
DK
91 "${tmppath}/dists/stable/main/binary-i386/Packages.bz2" \
92 "${tmppath}/dists/stable/main/source/Sources.xz" \
2c405a44
DK
93 "${tmppath}/dists/stable/contrib/binary-amd64/Packages" \
94 "${tmppath}/dists/stable/contrib/binary-amd64/Packages.gz" \
95 "${tmppath}/dists/stable/contrib/binary-all/Packages" \
eed564b8
DK
96 "${tmppath}/dists/unstable/main/binary-i386/Packages.xz" \
97 "${tmppath}/dists/unstable/main/binary-i386/Packages.lzma" \
2c405a44 98 "${tmppath}/dists/unstable/main/i18n/Translation-en" \
eed564b8
DK
99 "${tmppath}/dists/unstable/main/i18n/Translation-de.bz2" \
100 "${tmppath}/dists/unstable/main/source/Sources.xz" \
2c405a44
DK
101 "${tmppath}/dists/broken/non-free/source/Sources.gz" \
102 "${tmppath}/dists/stable/Release.gpg" \
103 "${tmppath}/dists/stable/Release" \
104 "${tmppath}/dists/unstable/InRelease" \
105 "${tmppath}/dists/broken/Release.gpg"
106 ln -s "${tmppath}/dists/unstable" "${tmppath}/dists/sid"
e29a6bb1
DK
107 fi
108
682a3bf7 109 echo -n "Testing with ${NAME} "
d4ddc5b9
MV
110 if LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then
111 echo "$TESTOKAY"
112 else
113 echo "$TESTFAIL"
114 EXIT_CODE=1
115 fi
e29a6bb1
DK
116
117 if [ -n "$tmppath" -a -d "$tmppath" ]; then
e29a6bb1
DK
118 rm -rf "$tmppath"
119 fi
e4a30974 120done
d4ddc5b9 121exit $EXIT_CODE