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