]> git.saurik.com Git - apt.git/blame - test/integration/test-external-dependency-solver-protocol
refactor EDSP classes for better internal reuse
[apt.git] / test / integration / test-external-dependency-solver-protocol
CommitLineData
1f6cf9e7
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
1f6cf9e7
DK
6setupenvironment
7configarchitecture 'amd64' 'i386'
8
9insertinstalledpackage 'cool' 'all' '1'
10insertinstalledpackage 'stuff' 'all' '1'
188a6fcf 11insertinstalledpackage 'somestuff' 'all' '1' 'Depends: cool, stuff'
1f6cf9e7
DK
12
13insertpackage 'unstable' 'cool' 'all' '2' 'Multi-Arch: foreign'
14insertpackage 'unstable' 'stuff' 'all' '2' 'Multi-Arch: foreign'
15insertpackage 'unstable' 'coolstuff' 'i386,amd64' '2' 'Depends: cool, stuff'
081c9d44
DK
16insertpackage 'unstable' 'awesome' 'all' '2' 'Multi-Arch: foreign
17Conflicts: badstuff'
18insertpackage 'unstable' 'badstuff' 'all' '2' 'Multi-Arch: foreign
19Conflicts: awesome'
1f6cf9e7
DK
20insertpackage 'unstable' 'awesomecoolstuff' 'i386' '2' 'Depends: coolstuff, awesome'
21
22insertpackage 'experimental' 'cool' 'all' '3' 'Multi-Arch: foreign'
23insertpackage 'experimental' 'stuff' 'all' '3' 'Multi-Arch: foreign'
24insertpackage 'experimental' 'coolstuff' 'i386,amd64' '3' 'Depends: cool, stuff'
25
26setupaptarchive
27
92b2e38d
DK
28testfailure aptget install --solver dump coolstuff -s
29testsuccess grep ERR_NO_FILENAME rootdir/tmp/testfailure.output
7414af7f
DK
30export APT_EDSP_DUMP_FILENAME="/nonexistent/apt/edsp.dump"
31testfailure aptget install --solver dump coolstuff -s
32testsuccess grep ERR_WRITE_ERROR rootdir/tmp/testfailure.output
92b2e38d
DK
33export APT_EDSP_DUMP_FILENAME="${TMPWORKINGDIRECTORY}/downloaded/dump.edsp"
34
25b86db1 35testfailureequal 'Reading package lists...
1f6cf9e7
DK
36Building dependency tree...
37Execute external solver...
38The solver encountered an error of type: ERR_JUST_DUMPING
39The following information might help you to understand what is wrong:
40I am too dumb, i can just dump!
41Please use one of my friends instead!
42
43E: External solver failed with: I am too dumb, i can just dump!' aptget install --solver dump coolstuff -s
92b2e38d
DK
44testsuccess test -s "$APT_EDSP_DUMP_FILENAME"
45rm -f "$APT_EDSP_DUMP_FILENAME"
1f6cf9e7 46
188a6fcf
DK
47testsuccessequal 'Reading package lists...
48Building dependency tree...
49Execute external solver...
50The following NEW packages will be installed:
51 coolstuff
520 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
53Inst coolstuff (2 unstable [amd64])
54Conf coolstuff (2 unstable [amd64])' aptget install --solver apt coolstuff -s
55
25b86db1 56testsuccessequal 'Reading package lists...
1f6cf9e7
DK
57Building dependency tree...
58Execute external solver...
59The following NEW packages will be installed:
60 coolstuff
610 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
62Inst coolstuff (3 experimental [amd64])
188a6fcf 63Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff -s -t experimental
1f6cf9e7 64
294a8020
DK
65testsuccessequal "Reading package lists...
66Building dependency tree...
67Selected version '3' (experimental [amd64]) for 'coolstuff'
68Execute external solver...
69The following NEW packages will be installed:
70 coolstuff
710 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
72Inst coolstuff (3 experimental [amd64])
73Conf coolstuff (3 experimental [amd64])" aptget install --solver apt coolstuff/experimental -sq=0
74
75testsuccessequal 'Reading package lists...
76Building dependency tree...
77Execute external solver...
78The following NEW packages will be installed:
79 coolstuff
800 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
81Inst coolstuff (3 experimental [amd64])
82Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff=3 -sq=0
83
25b86db1 84testsuccessequal 'Reading package lists...
081c9d44
DK
85Building dependency tree...
86Execute external solver...
87The following packages will be REMOVED:
188a6fcf
DK
88 somestuff
890 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
90Remv somestuff [1]' aptget autoremove --solver apt somestuff -s
91testsuccess aptmark auto cool stuff
92testsuccessequal 'Reading package lists...
93Building dependency tree...
94Reading state information...
95Execute external solver...
96The following packages will be REMOVED:
97 cool somestuff stuff
980 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
99Remv somestuff [1]
100Remv cool [1]
101Remv stuff [1]' aptget autoremove --solver apt somestuff -s
102
73fe49f9
DK
103AUTOREMOVE='apt autoremove'
104if [ -n "$SUDO_USER" ]; then
105 AUTOREMOVE="sudo $AUTOREMOVE"
106fi
188a6fcf
DK
107testsuccessequal "Reading package lists...
108Building dependency tree...
109Reading state information...
110Execute external solver...
111The following package was automatically installed and is no longer required:
112 stuff
73fe49f9 113Use '$AUTOREMOVE' to remove it.
188a6fcf
DK
114The following packages will be REMOVED:
115 cool* somestuff*
90e7fba4 1160 upgraded, 0 newly installed, 2 to remove and 1 not upgraded.
188a6fcf
DK
117Purg somestuff [1]
118Purg cool [1]" aptget purge --solver apt cool -s
081c9d44 119
1f6cf9e7
DK
120testsuccess aptget install awesomecoolstuff:i386 -s
121testsuccess aptget install --solver apt awesomecoolstuff:i386 -s
122
92b2e38d 123rm -f "$APT_EDSP_DUMP_FILENAME"
1f6cf9e7 124testfailure aptget install --solver dump awesomecoolstuff:i386 -s
92b2e38d
DK
125testsuccess test -s "$APT_EDSP_DUMP_FILENAME"
126testequal 'Install: awesomecoolstuff:i386' grep :i386 "$APT_EDSP_DUMP_FILENAME"
a66e1837 127testfailure grep -e ':amd64' -e 'Architecture: any' "$APT_EDSP_DUMP_FILENAME"
1f6cf9e7 128
172947cd
DK
129testsuccess aptget dist-upgrade -s
130testsuccess aptget dist-upgrade -s --solver apt
131
132testsuccess aptget upgrade -s
133testsuccess aptget upgrade -s --solver apt
134
081c9d44
DK
135testfailure aptget install awesome badstuff -s
136testfailure aptget install awesome badstuff -s --solver apt
137testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output
138
1f6cf9e7 139configarchitecture 'armel'
7414af7f
DK
140testfailure aptget install --solver apt awesomecoolstuff:i386 -s
141msgtest 'An invalid EDSP file generates a' 'hard error'
87d6947d 142if echo "Request: This is a test\nFoo: bar\n\n" | aptinternalsolver > solver.result 2>&1; then
7414af7f
DK
143 cat solver.result
144 msgfail
145else
146 msgpass
147fi
1f6cf9e7 148msgtest 'Test direct calling is okay for' 'apt-internal-solver'
87d6947d 149cat "$APT_EDSP_DUMP_FILENAME" | aptinternalsolver > solver.result 2>&1 || true
1f6cf9e7
DK
150if [ "$(tail -n2 solver.result | head -n1 )" = "Message: Done" ]; then
151 msgpass
152else
153 cat solver.result
154 msgfail
155fi
307d9eb2
DK
156testsuccess grep '^APT-ID: 1$' "$APT_EDSP_DUMP_FILENAME"
157sed -i -e 's#^APT-ID: 1$#APT-ID: 10000#' "$APT_EDSP_DUMP_FILENAME"
158cat "$APT_EDSP_DUMP_FILENAME" | aptinternalsolver > solver.result 2>&1 || true
159testsuccessequal 'Message: Done
160' tail -n2 solver.result
92b2e38d 161rm -f "$APT_EDSP_DUMP_FILENAME"
1f6cf9e7 162
081c9d44 163testsuccess aptinternalsolver scenario
25b86db1 164testsuccessequal 'Package: stuff
081c9d44 165Architecture: all
1dd20368 166Version: 3
1dd20368 167APT-ID: 1
5caf35a7
DK
168Multi-Arch: foreign
169Source: stuff
170Source-Version: 3
1dd20368
DK
171Priority: optional
172Section: other
1dd20368
DK
173APT-Release:
174 a=experimental,n=experimental,c=main,b=all
175APT-Pin: 1
176
177Package: stuff
1dd20368
DK
178Architecture: all
179Version: 2
1dd20368 180APT-ID: 3
5caf35a7
DK
181Multi-Arch: foreign
182Source: stuff
183Source-Version: 2
1dd20368
DK
184Priority: optional
185Section: other
1dd20368
DK
186APT-Release:
187 a=unstable,n=sid,c=main,b=all
188APT-Pin: 500
189APT-Candidate: yes
190
191Package: stuff
1dd20368 192Architecture: all
081c9d44 193Version: 1
1dd20368 194APT-ID: 8
5caf35a7
DK
195Source: stuff
196Source-Version: 1
081c9d44
DK
197Priority: optional
198Section: other
5caf35a7 199Installed: yes
081c9d44 200APT-Pin: 100
081c9d44 201' aptinternalsolver scenario stuff
90e7fba4
DK
202
203cat > rootdir/usr/lib/apt/solvers/explicitremove << EOF
204#!/bin/sh
205set -e
206while read line; do
207 if [ "APT-ID" = "\${line%:*}" ]; then
208 cat << APT
209Install: \${line#*:}
210
211Remove: \${line#*:}
212
213APT
214 fi
215done
216EOF
217chmod +x rootdir/usr/lib/apt/solvers/explicitremove
218testfailure apt full-upgrade -s --solver explicitremove
219testsuccess grep 'had a previous stanza' rootdir/tmp/testfailure.output
220
221cat > rootdir/usr/lib/apt/solvers/removeall << EOF
222#!/bin/sh
223set -e
224while read line; do
225 if [ "APT-ID" = "\${line%:*}" ]; then
226 cat << APT
227Remove: \${line#*:}
228
229APT
230 fi
231done
232EOF
233chmod +x rootdir/usr/lib/apt/solvers/removeall
234testwarning apt full-upgrade -s --solver removeall
235testsuccess grep "which isn't installed!" rootdir/tmp/testwarning.output
236
237cat > rootdir/usr/lib/apt/solvers/installall << EOF
238#!/bin/sh
239set -e
240while read line; do
241 if [ "APT-ID" = "\${line%:*}" ]; then
242 cat << APT
243Install: \${line#*:}
244
245APT
246 fi
247done
248EOF
249chmod +x rootdir/usr/lib/apt/solvers/installall
250testfailure apt full-upgrade -s --solver installall
251testsuccess grep "is already installed!" rootdir/tmp/testfailure.output