]>
Commit | Line | Data |
---|---|---|
d151adbf DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR=$(readlink -f $(dirname $0)) | |
5 | . $TESTDIR/framework | |
6 | ||
7 | setupenvironment | |
8 | configarchitecture 'native' | |
9fc0b435 | 9 | configdpkgnoopchroot |
d151adbf DK |
10 | |
11 | # create a bunch of failures | |
12 | createfailure() { | |
13 | setupsimplenativepackage "failure-$1" 'native' '1.0' 'unstable' 'Depends: dependee' | |
14 | BUILDDIR="incoming/failure-$1-1.0" | |
15 | echo '#!/bin/sh | |
16 | exit 29' > ${BUILDDIR}/debian/$1 | |
17 | buildpackage "$BUILDDIR" 'unstable' 'main' 'native' | |
18 | rm -rf "$BUILDDIR" | |
19 | } | |
20 | ||
21 | buildsimplenativepackage 'dependee' 'native' '1.0' 'unstable' | |
22 | createfailure 'preinst' | |
23 | createfailure 'postinst' | |
24 | createfailure 'prerm' | |
25 | createfailure 'postrm' | |
26 | ||
27 | setupaptarchive | |
28 | ||
d151adbf DK |
29 | # setup some pre- and post- invokes to check the output isn't garbled later |
30 | APTHOOK="${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apthook" | |
31 | echo '#!/bin/sh | |
32 | echo "$1: START" | |
33 | echo "$1: MaiN" | |
34 | echo "$1: ENd"' > $APTHOOK | |
35 | chmod +x $APTHOOK | |
36 | echo "DPKG::Pre-Invoke:: \"${APTHOOK} PRE\"; | |
37 | DPKG::Post-Invoke:: \"${APTHOOK} POST\";" > rootdir/etc/apt/apt.conf.d/99apthooks | |
38 | ||
39 | testmyfailure() { | |
40 | local PROGRESS='rootdir/tmp/progress.log' | |
41 | exec 3> $PROGRESS | |
42 | testfailure "$@" -o APT::Status-Fd=3 | |
43 | msgtest 'Test for failure message of maintainerscript in' 'console log' | |
44 | local TEST='rootdir/tmp/testfailure.output' | |
a11f6c97 | 45 | if grep -q 'exit status 29' "$TEST"; then |
d151adbf DK |
46 | msgpass |
47 | else | |
48 | cat $TEST | |
49 | msgfail | |
50 | fi | |
51 | msgtest 'Test for proper execution of invoke scripts in' 'console log' | |
52 | if grep -q '^PRE: START$' $TEST && | |
53 | grep -q '^PRE: MaiN$' $TEST && | |
54 | grep -q '^PRE: ENd$' $TEST && | |
55 | grep -q '^POST: START$' $TEST && | |
56 | grep -q '^POST: MaiN$' $TEST && | |
57 | grep -q '^POST: ENd$' $TEST; then | |
58 | msgpass | |
59 | else | |
60 | cat $TEST | |
61 | msgfail | |
62 | fi | |
63 | msgtest 'Test for failure message of maintainerscript in' 'progress log' | |
64 | if grep -q '^pmerror:.\+exit status 29$' "$PROGRESS"; then | |
65 | msgpass | |
66 | else | |
67 | cat $PROGRESS | |
68 | msgfail | |
69 | fi | |
70 | testmarkedauto 'dependee' | |
71 | } | |
72 | ||
73 | cp -a rootdir/var/lib/dpkg/status rootdir/var/lib/dpkg/status.backup | |
74 | testmyfailure aptget install failure-preinst -y | |
75 | cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status | |
76 | testmyfailure aptget install failure-postinst -y | |
77 | cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status | |
78 | testsuccess aptget install failure-prerm -y | |
79 | testdpkginstalled failure-prerm | |
80 | testmyfailure aptget purge failure-prerm -y | |
81 | cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status | |
82 | testsuccess aptget install failure-postrm -y | |
83 | testdpkginstalled failure-postrm | |
84 | testmyfailure aptget purge failure-postrm -y | |
85 | ||
86 | # FIXME: test with output going to a PTY as it usually does | |
87 | #cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status | |
88 | #aptget install failure-preinst -y |