test-external-dependency-solver-protocol 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. testfailure aptget install --solver dump coolstuff -s
  23. testsuccess grep ERR_NO_FILENAME rootdir/tmp/testfailure.output
  24. export APT_EDSP_DUMP_FILENAME="/nonexistent/apt/edsp.dump"
  25. testfailure aptget install --solver dump coolstuff -s
  26. testsuccess grep ERR_WRITE_ERROR rootdir/tmp/testfailure.output
  27. export APT_EDSP_DUMP_FILENAME="${TMPWORKINGDIRECTORY}/downloaded/dump.edsp"
  28. testfailureequal 'Reading package lists...
  29. Building dependency tree...
  30. Execute external solver...
  31. The solver encountered an error of type: ERR_JUST_DUMPING
  32. The following information might help you to understand what is wrong:
  33. I am too dumb, i can just dump!
  34. Please use one of my friends instead!
  35. E: External solver failed with: I am too dumb, i can just dump!' aptget install --solver dump coolstuff -s
  36. testsuccess test -s "$APT_EDSP_DUMP_FILENAME"
  37. rm -f "$APT_EDSP_DUMP_FILENAME"
  38. testsuccessequal 'Reading package lists...
  39. Building dependency tree...
  40. Execute external solver...
  41. The following NEW packages will be installed:
  42. coolstuff
  43. 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
  44. Inst coolstuff (2 unstable [amd64])
  45. Conf coolstuff (2 unstable [amd64])' aptget install --solver apt coolstuff -s
  46. testsuccessequal 'Reading package lists...
  47. Building dependency tree...
  48. Execute external solver...
  49. The following NEW packages will be installed:
  50. coolstuff
  51. 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
  52. Inst coolstuff (3 experimental [amd64])
  53. Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff -s -t experimental
  54. testsuccessequal "Reading package lists...
  55. Building dependency tree...
  56. Selected version '3' (experimental [amd64]) for 'coolstuff'
  57. Execute external solver...
  58. The following NEW packages will be installed:
  59. coolstuff
  60. 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
  61. Inst coolstuff (3 experimental [amd64])
  62. Conf coolstuff (3 experimental [amd64])" aptget install --solver apt coolstuff/experimental -sq=0
  63. testsuccessequal 'Reading package lists...
  64. Building dependency tree...
  65. Execute external solver...
  66. The following NEW packages will be installed:
  67. coolstuff
  68. 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
  69. Inst coolstuff (3 experimental [amd64])
  70. Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff=3 -sq=0
  71. testsuccessequal 'Reading package lists...
  72. Building dependency tree...
  73. Execute external solver...
  74. The following packages will be REMOVED:
  75. somestuff
  76. 0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
  77. Remv somestuff [1]' aptget autoremove --solver apt somestuff -s
  78. testsuccess aptmark auto cool stuff
  79. testsuccessequal 'Reading package lists...
  80. Building dependency tree...
  81. Reading state information...
  82. Execute external solver...
  83. The following packages will be REMOVED:
  84. cool somestuff stuff
  85. 0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
  86. Remv somestuff [1]
  87. Remv cool [1]
  88. Remv stuff [1]' aptget autoremove --solver apt somestuff -s
  89. AUTOREMOVE='apt autoremove'
  90. if [ -n "$SUDO_USER" ]; then
  91. AUTOREMOVE="sudo $AUTOREMOVE"
  92. fi
  93. testsuccessequal "Reading package lists...
  94. Building dependency tree...
  95. Reading state information...
  96. Execute external solver...
  97. The following package was automatically installed and is no longer required:
  98. stuff
  99. Use '$AUTOREMOVE' to remove it.
  100. The following packages will be REMOVED:
  101. cool* somestuff*
  102. 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
  103. Purg somestuff [1]
  104. Purg cool [1]" aptget purge --solver apt cool -s
  105. testsuccess aptget install awesomecoolstuff:i386 -s
  106. testsuccess aptget install --solver apt awesomecoolstuff:i386 -s
  107. rm -f "$APT_EDSP_DUMP_FILENAME"
  108. testfailure aptget install --solver dump awesomecoolstuff:i386 -s
  109. testsuccess test -s "$APT_EDSP_DUMP_FILENAME"
  110. testequal 'Install: awesomecoolstuff:i386' grep :i386 "$APT_EDSP_DUMP_FILENAME"
  111. testfailure grep -e ':amd64' -e 'Architecture: any' "$APT_EDSP_DUMP_FILENAME"
  112. testsuccess aptget dist-upgrade -s
  113. testsuccess aptget dist-upgrade -s --solver apt
  114. testsuccess aptget upgrade -s
  115. testsuccess aptget upgrade -s --solver apt
  116. testfailure aptget install awesome badstuff -s
  117. testfailure aptget install awesome badstuff -s --solver apt
  118. testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output
  119. configarchitecture 'armel'
  120. testfailure aptget install --solver apt awesomecoolstuff:i386 -s
  121. msgtest 'An invalid EDSP file generates a' 'hard error'
  122. if echo "Request: This is a test\nFoo: bar\n\n" | aptinternalsolver > solver.result 2>&1; then
  123. cat solver.result
  124. msgfail
  125. else
  126. msgpass
  127. fi
  128. msgtest 'Test direct calling is okay for' 'apt-internal-solver'
  129. cat "$APT_EDSP_DUMP_FILENAME" | aptinternalsolver > solver.result 2>&1 || true
  130. if [ "$(tail -n2 solver.result | head -n1 )" = "Message: Done" ]; then
  131. msgpass
  132. else
  133. cat solver.result
  134. msgfail
  135. fi
  136. rm -f "$APT_EDSP_DUMP_FILENAME"
  137. testsuccess aptinternalsolver scenario
  138. testsuccessequal 'Package: stuff
  139. Source: stuff
  140. Architecture: all
  141. Version: 3
  142. Source-Version: 3
  143. APT-ID: 1
  144. Priority: optional
  145. Section: other
  146. Multi-Arch: foreign
  147. APT-Release:
  148. a=experimental,n=experimental,c=main,b=all
  149. APT-Pin: 1
  150. Package: stuff
  151. Source: stuff
  152. Architecture: all
  153. Version: 2
  154. Source-Version: 2
  155. APT-ID: 3
  156. Priority: optional
  157. Section: other
  158. Multi-Arch: foreign
  159. APT-Release:
  160. a=unstable,n=sid,c=main,b=all
  161. APT-Pin: 500
  162. APT-Candidate: yes
  163. Package: stuff
  164. Source: stuff
  165. Architecture: all
  166. Version: 1
  167. Source-Version: 1
  168. Installed: yes
  169. APT-ID: 8
  170. Priority: optional
  171. Section: other
  172. APT-Pin: 100
  173. ' aptinternalsolver scenario stuff