]> git.saurik.com Git - apt.git/blame - test/libapt/run-tests
* test/libapt/globalerror_test.cc:
[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"
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
DK
109 echo -n "Testing with ${NAME} "
110 LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "$TESTOKAY" || echo "$TESTFAIL"
e29a6bb1
DK
111
112 if [ -n "$tmppath" -a -d "$tmppath" ]; then
e29a6bb1
DK
113 rm -rf "$tmppath"
114 fi
e4a30974 115done