]> git.saurik.com Git - apt.git/blob - test/libapt/run-tests
* apt-pkg/deb/debmetaindex.cc:
[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
11 # detect if output is on a terminal (colorful) or better not
12 if 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'
17 else
18 COLHIGH=''
19 COLRESET=''
20 TESTOKAY='OK'
21 TESTFAIL='###FAILED###'
22 fi
23
24 for testapp in $(ls ${LDPATH}/*$EXT)
25 do
26 name=$(basename ${testapp})
27 NAME="${COLHIGH}${name}${COLRESET}"
28 tmppath=""
29
30 if [ $name = "GetListOfFilesInDir${EXT}" ]; then
31 # TODO: very-low: move env creation to the actual test-app
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"
55 mkdir "${tmppath}/invaliddir" \
56 "${tmppath}/directory.conf" \
57 "${tmppath}/directory.list" \
58 "${tmppath}/directory.wron" \
59 "${tmppath}/directory.list.disabled"
60 ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
61 ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
62 elif [ $name = "getLanguages${EXT}" ]; then
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~" \
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"
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
76 elif [ $name = "CompareVersion${EXT}" ]; then
77 tmppath="${DIR}/versions.lst"
78 fi
79
80 echo -n "Testing with ${NAME} "
81 LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "$TESTOKAY" || echo "$TESTFAIL"
82
83 if [ -n "$tmppath" -a -d "$tmppath" ]; then
84 rm -rf "$tmppath"
85 fi
86 done