]> git.saurik.com Git - apt.git/blob - test/integration/test-external-dependency-solver-protocol
fix insecure use of /tmp in EDSP solver 'dump'
[apt.git] / test / integration / test-external-dependency-solver-protocol
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6 setupenvironment
7 configarchitecture 'amd64' 'i386'
8
9 insertinstalledpackage 'cool' 'all' '1'
10 insertinstalledpackage 'stuff' 'all' '1'
11
12 insertpackage 'unstable' 'cool' 'all' '2' 'Multi-Arch: foreign'
13 insertpackage 'unstable' 'stuff' 'all' '2' 'Multi-Arch: foreign'
14 insertpackage 'unstable' 'coolstuff' 'i386,amd64' '2' 'Depends: cool, stuff'
15 insertpackage 'unstable' 'awesome' 'all' '2' 'Multi-Arch: foreign
16 Conflicts: badstuff'
17 insertpackage 'unstable' 'badstuff' 'all' '2' 'Multi-Arch: foreign
18 Conflicts: awesome'
19 insertpackage 'unstable' 'awesomecoolstuff' 'i386' '2' 'Depends: coolstuff, awesome'
20
21 insertpackage 'experimental' 'cool' 'all' '3' 'Multi-Arch: foreign'
22 insertpackage 'experimental' 'stuff' 'all' '3' 'Multi-Arch: foreign'
23 insertpackage 'experimental' 'coolstuff' 'i386,amd64' '3' 'Depends: cool, stuff'
24
25 setupaptarchive
26
27 testfailure aptget install --solver dump coolstuff -s
28 testsuccess grep ERR_NO_FILENAME rootdir/tmp/testfailure.output
29 export APT_EDSP_DUMP_FILENAME="${TMPWORKINGDIRECTORY}/downloaded/dump.edsp"
30
31 testfailureequal 'Reading package lists...
32 Building dependency tree...
33 Execute external solver...
34 The solver encountered an error of type: ERR_JUST_DUMPING
35 The following information might help you to understand what is wrong:
36 I am too dumb, i can just dump!
37 Please use one of my friends instead!
38
39 E: External solver failed with: I am too dumb, i can just dump!' aptget install --solver dump coolstuff -s
40 testsuccess test -s "$APT_EDSP_DUMP_FILENAME"
41 rm -f "$APT_EDSP_DUMP_FILENAME"
42
43 #FIXME: this should be unstable, but we don't support pinning yet
44 testsuccessequal 'Reading package lists...
45 Building dependency tree...
46 Execute external solver...
47 The following NEW packages will be installed:
48 coolstuff
49 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
50 Inst coolstuff (3 experimental [amd64])
51 Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff -s
52
53 testsuccessequal 'Reading package lists...
54 Building dependency tree...
55 Execute external solver...
56 The following packages will be REMOVED:
57 cool*
58 0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
59 Purg cool [1]' aptget purge --solver apt cool -s
60
61 testsuccess aptget install awesomecoolstuff:i386 -s
62 testsuccess aptget install --solver apt awesomecoolstuff:i386 -s
63
64 rm -f "$APT_EDSP_DUMP_FILENAME"
65 testfailure aptget install --solver dump awesomecoolstuff:i386 -s
66 testsuccess test -s "$APT_EDSP_DUMP_FILENAME"
67 testequal 'Install: awesomecoolstuff:i386' grep :i386 "$APT_EDSP_DUMP_FILENAME"
68 testempty grep -e ':amd64' -e 'Architecture: any' "$APT_EDSP_DUMP_FILENAME"
69
70 testsuccess aptget dist-upgrade -s
71 testsuccess aptget dist-upgrade -s --solver apt
72
73 testsuccess aptget upgrade -s
74 testsuccess aptget upgrade -s --solver apt
75
76 testfailure aptget install awesome badstuff -s
77 testfailure aptget install awesome badstuff -s --solver apt
78 testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output
79
80 configarchitecture 'armel'
81 msgtest 'Test direct calling is okay for' 'apt-internal-solver'
82 cat "$APT_EDSP_DUMP_FILENAME" | aptinternalsolver -q=0 > solver.result 2>&1 || true
83 if [ "$(tail -n2 solver.result | head -n1 )" = "Message: Done" ]; then
84 msgpass
85 else
86 cat solver.result
87 msgfail
88 fi
89 rm -f "$APT_EDSP_DUMP_FILENAME"
90
91 testfailure aptget install --solver apt awesomecoolstuff:i386 -s
92
93 testsuccess aptinternalsolver scenario
94 testsuccessequal 'Package: stuff
95 Source: stuff
96 Architecture: all
97 Version: 1
98 Source-Version: 1
99 Installed: yes
100 APT-ID: 2
101 Priority: optional
102 Section: other
103 APT-Pin: 100
104 APT-Candidate: yes
105 ' aptinternalsolver scenario stuff