summaryrefslogtreecommitdiffstats
path: root/test/integration/test-external-installation-planner-protocol
blob: 192f21bb3fffe6d2cfb7bcce79a43b7a240e8cd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
set -e

TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"
setupenvironment
configarchitecture 'amd64'

buildsimplenativepackage 'libfoo' 'amd64' '3' 'experimental' 'Multi-Arch: same'
buildsimplenativepackage 'foo' 'all' '3' 'experimental' 'Depends: newstuff'
buildsimplenativepackage 'foo' 'all' '2' 'unstable' 'Depends: libfoo:amd64, stuff
Conflicts: bar, libfoo:i386
Recommends: unrelated'
buildsimplenativepackage 'libfoo' 'amd64' '2' 'unstable' 'Multi-Arch: same'
buildsimplenativepackage 'unrelated-2' 'amd64' '2' 'unstable'
insertinstalledpackage 'foo' 'all' '1'
insertinstalledpackage 'bar' 'all' '1'
insertinstalledpackage 'stuff' 'all' '1'
insertinstalledpackage 'unrelated-1' 'all' '1'

setupaptarchive --no-update

EIPPLOG="${TMPWORKINGDIRECTORY}/rootdir/var/log/apt/eipp.log"
echo "Dir::Log::Planner \"$EIPPLOG\";" > ./rootdir/etc/apt/apt.conf.d/eipp-logging

testsuccess apt update
export APT_EDSP_DUMP_FILENAME="${TMPWORKINGDIRECTORY}/downloaded/dump.eipp"
testfailure test -r "$EIPPLOG"
testfailure aptget install foo --planner dump -y
testfailure test -r "$EIPPLOG"
testfailure grep 'unrelated-2' "$APT_EDSP_DUMP_FILENAME"
testsuccessequal '2' grep -c '^Package: foo$' "$APT_EDSP_DUMP_FILENAME"
testsuccessequal '1' grep -c '^Package: libfoo$' "$APT_EDSP_DUMP_FILENAME"
testsuccessequal 'Planner: dump' grep '^Planner: ' "$APT_EDSP_DUMP_FILENAME"

testsuccess aptget install foo -s
testsuccess aptget install foo -y
testsuccess test -r "$EIPPLOG"
testsuccessequal 'Request: EIPP 0.1
Architecture: amd64
Architectures: amd64
Remove: bar:amd64
Install: foo:amd64 libfoo:amd64
Planner: internal' head -n 6 "$EIPPLOG"
aptinternalplanner < "$EIPPLOG" > planner.log || true
testsuccessequal 'Remove: 6
Unpack: 2
Unpack: 4' grep -e '^Unpack:' -e '^Install:' -e '^Configure:' -e '^Remove:' planner.log

rm -f "$EIPPLOG"
testsuccess aptget install foo -s --reinstall
testsuccess aptget install foo -y --reinstall
testsuccess test -r "$EIPPLOG"
testsuccessequal 'Request: EIPP 0.1
Architecture: amd64
Architectures: amd64
ReInstall: foo:amd64
Planner: internal' head -n 5 "$EIPPLOG"
aptinternalplanner < "$EIPPLOG" > planner.log || true
testsuccessequal 'Unpack: 4' grep -e '^Unpack:' -e '^Install:' -e '^Configure:' -e '^Remove:' planner.log

rm -f "$EIPPLOG"
testsuccess aptget purge foo -s
testsuccess aptget purge foo -y
testsuccess test -r "$EIPPLOG"
testsuccessequal 'Request: EIPP 0.1
Architecture: amd64
Architectures: amd64
Remove: foo:amd64
Planner: internal' head -n 5 "$EIPPLOG"
aptinternalplanner < "$EIPPLOG" > planner.log || true
testsuccessequal 'Remove: 4' grep -e '^Unpack:' -e '^Install:' -e '^Configure:' -e '^Remove:' planner.log

testplannerfailuremsg() {
	local PLANNER="rootdir/usr/lib/apt/planners/$1"
	echo "$2" > "$PLANNER"
	chmod +x "$PLANNER"
	testfailuremsg "$3" apt install foo -s --planner $1
}

testplannerfailuremsg 'exit0withmsg' "#!/bin/sh
echo 'Error: instant-exit
Message: This planner exits instantly'
exit 0" 'E: External planner failed with: This planner exits instantly'

testplannerfailuremsg 'exit1withoutmsg' "#!/bin/sh
exit 1" 'E: Sub-process exit1withoutmsg returned an error code (1)'

testplannerfailuremsg 'exit1withmsg' "#!/bin/sh
echo 'Error: instant-exit
Message: This planner exits instantly'
exit 1" 'E: External planner failed with: This planner exits instantly
E: Sub-process exit1withmsg returned an error code (1)'