]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | set -e | |
3 | ||
4 | DIR=$(readlink -f $(dirname $0)) | |
5 | if [ -z "$MAKELEVEL" ]; then | |
6 | echo 'Compiling the tests …' | |
7 | (cd $DIR && make) | |
8 | echo 'Running all testcases …' | |
9 | fi | |
10 | LDPATH="$DIR/../../build/bin" | |
11 | EXT="_libapt_test" | |
12 | EXIT_CODE=0 | |
13 | ||
14 | # detect if output is on a terminal (colorful) or better not | |
15 | if 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' | |
20 | else | |
21 | COLHIGH='' | |
22 | COLRESET='' | |
23 | TESTOKAY='OK' | |
24 | TESTFAIL='###FAILED###' | |
25 | fi | |
26 | ||
27 | for testapp in $(ls ${LDPATH}/*$EXT) | |
28 | do | |
29 | name=$(basename ${testapp}) | |
30 | NAME="${COLHIGH}${name}${COLRESET}" | |
31 | tmppath="" | |
32 | ||
33 | if [ $name = "GetListOfFilesInDir${EXT}" ]; then | |
34 | # TODO: very-low: move env creation to the actual test-app | |
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" | |
58 | mkdir "${tmppath}/invaliddir" \ | |
59 | "${tmppath}/directory.conf" \ | |
60 | "${tmppath}/directory.list" \ | |
61 | "${tmppath}/directory.wron" \ | |
62 | "${tmppath}/directory.list.disabled" | |
63 | ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list" | |
64 | ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list" | |
65 | elif [ $name = "getLanguages${EXT}" ]; then | |
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~" \ | |
70 | "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \ | |
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" | |
73 | elif [ $name = "HashSums${EXT}" ]; then | |
74 | TMP="$(readlink -f "./${0}")" | |
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)" | |
80 | elif [ $name = "CompareVersion${EXT}" ]; then | |
81 | tmppath="${DIR}/versions.lst" | |
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" \ | |
95 | "${tmppath}/dists/stable/main/binary-i386/Packages.bz2" \ | |
96 | "${tmppath}/dists/stable/main/source/Sources.xz" \ | |
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" \ | |
100 | "${tmppath}/dists/unstable/main/binary-i386/Packages.xz" \ | |
101 | "${tmppath}/dists/unstable/main/binary-i386/Packages.lzma" \ | |
102 | "${tmppath}/dists/unstable/main/i18n/Translation-en" \ | |
103 | "${tmppath}/dists/unstable/main/i18n/Translation-de.bz2" \ | |
104 | "${tmppath}/dists/unstable/main/source/Sources.xz" \ | |
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" | |
111 | fi | |
112 | ||
113 | echo -n "Testing with ${NAME} " | |
114 | if MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then | |
115 | echo "$TESTOKAY" | |
116 | else | |
117 | echo "$TESTFAIL" | |
118 | EXIT_CODE=1 | |
119 | fi | |
120 | ||
121 | if [ -n "$tmppath" -a -d "$tmppath" ]; then | |
122 | rm -rf "$tmppath" | |
123 | fi | |
124 | done | |
125 | exit $EXIT_CODE |