You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

295 lines
9.4 KiB

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