]> git.saurik.com Git - apt.git/blame - test/libapt/run-tests
pass Target/MetaIndexParser around into pkgAcqDiffIndex so that this can be used...
[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"
12844170
DK
111 elif [ $name = "CdromFindMountPointForDevice${EXT}" ]; then
112 tmppath=$(mktemp)
113 echo 'rootfs / rootfs rw 0 0
114sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
115sysfs0 /sys0 sysfs rw,nosuid,nodev,noexec,relatime 0 0
116/dev/disk/by-uuid/fadcbc52-6284-4874-aaaa-dcee1f05fe21 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
117/dev/sda1 /boot/efi vfat rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro 0 0
118tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0' > $tmppath
e29a6bb1
DK
119 fi
120
682a3bf7 121 echo -n "Testing with ${NAME} "
037374fe
DK
122 if MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then
123 echo "$TESTOKAY"
d4ddc5b9
MV
124 else
125 echo "$TESTFAIL"
126 EXIT_CODE=1
127 fi
e29a6bb1
DK
128
129 if [ -n "$tmppath" -a -d "$tmppath" ]; then
e29a6bb1
DK
130 rm -rf "$tmppath"
131 fi
e4a30974 132done
d4ddc5b9 133exit $EXIT_CODE