]>
Commit | Line | Data |
---|---|---|
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 | "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tlh%5fDE" | |
70 | elif [ $name = "HashSums${EXT}" ]; then | |
71 | TMP="$(readlink -f "./${0}")" | |
72 | echo -n "Testing with ${NAME} " | |
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 "$TESTOKAY" || echo "$TESTFAIL" | |
74 | continue | |
75 | elif [ $name = "CompareVersion${EXT}" ]; then | |
76 | tmppath="${DIR}/versions.lst" | |
77 | elif [ $name = "CdromFindPackages${EXT}" ]; then | |
78 | tmppath=$(mktemp -d) | |
79 | mkdir -p "${tmppath}/.disk" "${tmppath}/pool" \ | |
80 | "${tmppath}/dists/stable/main/binary-i386" \ | |
81 | "${tmppath}/dists/stable/main/source" \ | |
82 | "${tmppath}/dists/stable/contrib/binary-amd64" \ | |
83 | "${tmppath}/dists/stable/contrib/binary-all" \ | |
84 | "${tmppath}/dists/unstable/main/binary-i386" \ | |
85 | "${tmppath}/dists/unstable/main/i18n" \ | |
86 | "${tmppath}/dists/unstable/main/source" \ | |
87 | "${tmppath}/dists/broken/non-free/source" | |
88 | touch "${tmppath}/dists/broken/.aptignr" \ | |
89 | "${tmppath}/dists/stable/main/binary-i386/Packages" \ | |
90 | "${tmppath}/dists/stable/main/binary-i386/Packages.bz2" \ | |
91 | "${tmppath}/dists/stable/main/source/Sources.xz" \ | |
92 | "${tmppath}/dists/stable/contrib/binary-amd64/Packages" \ | |
93 | "${tmppath}/dists/stable/contrib/binary-amd64/Packages.gz" \ | |
94 | "${tmppath}/dists/stable/contrib/binary-all/Packages" \ | |
95 | "${tmppath}/dists/unstable/main/binary-i386/Packages.xz" \ | |
96 | "${tmppath}/dists/unstable/main/binary-i386/Packages.lzma" \ | |
97 | "${tmppath}/dists/unstable/main/i18n/Translation-en" \ | |
98 | "${tmppath}/dists/unstable/main/i18n/Translation-de.bz2" \ | |
99 | "${tmppath}/dists/unstable/main/source/Sources.xz" \ | |
100 | "${tmppath}/dists/broken/non-free/source/Sources.gz" \ | |
101 | "${tmppath}/dists/stable/Release.gpg" \ | |
102 | "${tmppath}/dists/stable/Release" \ | |
103 | "${tmppath}/dists/unstable/InRelease" \ | |
104 | "${tmppath}/dists/broken/Release.gpg" | |
105 | ln -s "${tmppath}/dists/unstable" "${tmppath}/dists/sid" | |
106 | fi | |
107 | ||
108 | echo -n "Testing with ${NAME} " | |
109 | LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "$TESTOKAY" || echo "$TESTFAIL" | |
110 | ||
111 | if [ -n "$tmppath" -a -d "$tmppath" ]; then | |
112 | rm -rf "$tmppath" | |
113 | fi | |
114 | done |