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