test-apt-mark 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64' 'i386'
  7. insertpackage 'unstable' 'bar' 'amd64,i386' '1'
  8. insertpackage 'unstable' 'uninstalled' 'all' '1'
  9. insertpackage 'unstable' 'uninstalled-native' 'amd64' '1'
  10. insertinstalledpackage 'foo' 'all' '1'
  11. insertinstalledpackage 'bar' 'amd64' '1'
  12. setupaptarchive
  13. # dpkg is "installed" by our test framework
  14. testdpkginstalled dpkg
  15. testnoautopkg() {
  16. testempty aptmark showauto
  17. testempty aptcache -q=1 showauto
  18. testsuccessequal 'bar
  19. dpkg
  20. foo' aptmark showmanual
  21. testsuccessequal 'bar
  22. foo' aptmark showmanual bar foo uninstalled
  23. }
  24. testfooisauto() {
  25. testsuccessequal 'foo' aptmark showauto
  26. testsuccessequal 'foo' aptcache -q=1 showauto
  27. testsuccessequal 'foo' aptmark showauto foo
  28. testsuccessequal 'foo' aptcache -q=1 showauto foo
  29. testsuccessequal 'bar
  30. dpkg' aptmark showmanual
  31. testsuccessequal 'bar' aptmark showmanual bar
  32. }
  33. testmarkonpkgasauto() {
  34. testsuccess $1 -q=1 $2 foo
  35. testfooisauto
  36. testsuccess $1 -q=1 $2 foo
  37. testfooisauto
  38. testsuccess $1 -q=1 $3 foo
  39. testnoautopkg
  40. testsuccess $1 -q=1 $3 foo
  41. testnoautopkg
  42. }
  43. testfailureequal 'E: No packages found' aptmark auto
  44. testfailureequal 'E: No packages found' aptmark manual
  45. testnoautopkg
  46. testmarkonpkgasauto 'aptmark' 'auto' 'manual'
  47. testmarkonpkgasauto 'aptmark' 'markauto' 'unmarkauto'
  48. testmarkonpkgasauto 'aptget' 'markauto' 'unmarkauto'
  49. testnoholdpkg() {
  50. testempty aptmark showhold
  51. testempty aptmark showholds # typical "typo"
  52. testempty aptmark showhold dpkg
  53. testempty aptmark showholds dpkg
  54. }
  55. testpkgonhold() {
  56. testsuccessequal "$1" aptmark showhold
  57. testsuccessequal "$1" aptmark showholds
  58. testsuccessequal "$1" aptmark showhold $1
  59. testsuccessequal "$1" aptmark showholds $1
  60. }
  61. testmarkonepkgashold() {
  62. testsuccess aptmark hold $1
  63. testpkgonhold $1
  64. testsuccess aptmark hold $1
  65. testpkgonhold $1
  66. testsuccess aptmark unhold $1
  67. testnoholdpkg
  68. testsuccess aptmark unhold $1
  69. testnoholdpkg
  70. }
  71. testfailureequal 'E: No packages found' aptmark hold
  72. testfailureequal 'E: No packages found' aptmark unhold
  73. testnoholdpkg
  74. testmarkonepkgashold 'foo'
  75. testmarkonepkgashold 'bar'
  76. msgtest 'dpkg supports --merge-avail via' 'stdin'
  77. if dpkg --merge-avail - < /dev/null >/dev/null 2>&1; then
  78. msgpass
  79. else
  80. msgskip 'dpkg version too old'
  81. exit 0
  82. fi
  83. testmarkonepkgashold 'uninstalled'
  84. testmarkonepkgashold 'uninstalled-native'
  85. testsuccessequal 'uninstalled set on hold.' aptmark hold uninstalled
  86. testsuccessequal 'uninstalled-native set on hold.' aptmark hold uninstalled-native
  87. #FIXME: holds on uninstalled packages are not persistent in dpkg
  88. testsuccessequal 'Reading package lists...
  89. Building dependency tree...
  90. Reading state information...
  91. The following NEW packages will be installed:
  92. uninstalled uninstalled-native
  93. The following held packages will be changed:
  94. uninstalled-native
  95. 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
  96. Inst uninstalled (1 unstable [all])
  97. Inst uninstalled-native (1 unstable [amd64])
  98. Conf uninstalled (1 unstable [all])
  99. Conf uninstalled-native (1 unstable [amd64])' aptget install uninstalled uninstalled-native -s
  100. testsuccess aptmark unhold uninstalled uninstalled-native
  101. testselections() {
  102. testsuccess aptmark hold "$1"
  103. testsuccessequal "$1" aptmark showholds "$1"
  104. testsuccess aptmark unhold "$1"
  105. testsuccessequal "$1" aptmark showinstalls "$1"
  106. testsuccess aptmark hold "$1"
  107. testsuccessequal "$1" aptmark showholds "$1"
  108. testsuccess aptmark install "$1"
  109. testsuccessequal "$1" aptmark showinstalls "$1"
  110. testsuccess aptmark remove "$1"
  111. testsuccessequal "$1" aptmark showremoves "$1"
  112. testsuccess aptmark purge "$1"
  113. testsuccessequal "$1" aptmark showpurges "$1"
  114. }
  115. testselections 'foo'
  116. testselections 'bar'
  117. testsuccessequal 'Reading package lists...
  118. Building dependency tree...
  119. Reading state information...
  120. The following packages will be REMOVED:
  121. bar* foo*
  122. 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
  123. Purg bar [1]
  124. Purg foo [1]' aptget dselect-upgrade -s
  125. testuninstalledselections() {
  126. testsuccess aptmark hold "$1"
  127. testsuccessequal "$1" aptmark showholds "$1"
  128. testsuccess aptmark unhold "$1"
  129. testsuccessequal "$1" aptmark showremoves "$1"
  130. testsuccess aptmark hold "$1"
  131. testsuccessequal "$1" aptmark showholds "$1"
  132. testsuccess aptmark install "$1"
  133. testsuccessequal "$1" aptmark showinstalls "$1"
  134. }
  135. testuninstalledselections 'uninstalled'
  136. testuninstalledselections 'uninstalled-native'