]> git.saurik.com Git - apt.git/blob - test/libapt/run-tests
merge patch from Daniel Hartwig to Show a error message if {,dist-}upgrade is used...
[apt.git] / test / libapt / run-tests
1 #!/bin/sh
2 set -e
3
4 DIR=$(readlink -f $(dirname $0))
5 echo "Compiling the tests …"
6 (cd $DIR && make)
7 echo "Running all testcases …"
8 LDPATH="$DIR/../../build/bin"
9 EXT="_libapt_test"
10 EXIT_CODE=0
11
12 # detect if output is on a terminal (colorful) or better not
13 if 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'
18 else
19 COLHIGH=''
20 COLRESET=''
21 TESTOKAY='OK'
22 TESTFAIL='###FAILED###'
23 fi
24
25 for testapp in $(ls ${LDPATH}/*$EXT)
26 do
27 name=$(basename ${testapp})
28 NAME="${COLHIGH}${name}${COLRESET}"
29 tmppath=""
30
31 if [ $name = "GetListOfFilesInDir${EXT}" ]; then
32 # TODO: very-low: move env creation to the actual test-app
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"
56 mkdir "${tmppath}/invaliddir" \
57 "${tmppath}/directory.conf" \
58 "${tmppath}/directory.list" \
59 "${tmppath}/directory.wron" \
60 "${tmppath}/directory.list.disabled"
61 ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
62 ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
63 elif [ $name = "getLanguages${EXT}" ]; then
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~" \
68 "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \
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"
71 elif [ $name = "HashSums${EXT}" ]; then
72 TMP="$(readlink -f "./${0}")"
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"
75 continue
76 elif [ $name = "CompareVersion${EXT}" ]; then
77 tmppath="${DIR}/versions.lst"
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" \
91 "${tmppath}/dists/stable/main/binary-i386/Packages.bz2" \
92 "${tmppath}/dists/stable/main/source/Sources.xz" \
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" \
96 "${tmppath}/dists/unstable/main/binary-i386/Packages.xz" \
97 "${tmppath}/dists/unstable/main/binary-i386/Packages.lzma" \
98 "${tmppath}/dists/unstable/main/i18n/Translation-en" \
99 "${tmppath}/dists/unstable/main/i18n/Translation-de.bz2" \
100 "${tmppath}/dists/unstable/main/source/Sources.xz" \
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"
107 fi
108
109 echo -n "Testing with ${NAME} "
110 if LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then
111 echo "$TESTOKAY"
112 else
113 echo "$TESTFAIL"
114 EXIT_CODE=1
115 fi
116
117 if [ -n "$tmppath" -a -d "$tmppath" ]; then
118 rm -rf "$tmppath"
119 fi
120 done
121 exit $EXIT_CODE