test-external-installation-planner-protocol 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. buildsimplenativepackage 'libfoo' 'amd64' '3' 'experimental' 'Multi-Arch: same'
  8. buildsimplenativepackage 'foo' 'all' '3' 'experimental' 'Depends: newstuff'
  9. buildsimplenativepackage 'foo' 'all' '2' 'unstable' 'Depends: libfoo:amd64, stuff
  10. Conflicts: bar, libfoo:i386
  11. Recommends: unrelated'
  12. buildsimplenativepackage 'libfoo' 'amd64' '2' 'unstable' 'Multi-Arch: same'
  13. buildsimplenativepackage 'unrelated-2' 'amd64' '2' 'unstable'
  14. insertinstalledpackage 'foo' 'all' '1'
  15. insertinstalledpackage 'bar' 'all' '1'
  16. insertinstalledpackage 'stuff' 'all' '1'
  17. insertinstalledpackage 'unrelated-1' 'all' '1'
  18. setupaptarchive --no-update
  19. EIPPLOG="${TMPWORKINGDIRECTORY}/rootdir/var/log/apt/eipp.log"
  20. echo "Dir::Log::Planner \"$EIPPLOG\";" > ./rootdir/etc/apt/apt.conf.d/eipp-logging
  21. testsuccess apt update
  22. export APT_EDSP_DUMP_FILENAME="${TMPWORKINGDIRECTORY}/downloaded/dump.eipp"
  23. testfailure test -r "$EIPPLOG"
  24. testfailure aptget install foo --planner dump -y
  25. testfailure test -r "$EIPPLOG"
  26. testfailure grep 'unrelated-2' "$APT_EDSP_DUMP_FILENAME"
  27. testsuccessequal '2' grep -c '^Package: foo$' "$APT_EDSP_DUMP_FILENAME"
  28. testsuccessequal '1' grep -c '^Package: libfoo$' "$APT_EDSP_DUMP_FILENAME"
  29. testsuccessequal 'Planner: dump' grep '^Planner: ' "$APT_EDSP_DUMP_FILENAME"
  30. testsuccess aptget install foo -s
  31. testsuccess aptget install foo -y
  32. testsuccess test -r "$EIPPLOG"
  33. testsuccessequal 'Request: EIPP 0.1
  34. Architecture: amd64
  35. Architectures: amd64
  36. Remove: bar:amd64
  37. Install: libfoo:amd64 foo:amd64
  38. Planner: internal' head -n 6 "$EIPPLOG"
  39. aptinternalplanner < "$EIPPLOG" > planner.log || true
  40. testsuccessequal 'Remove: 7
  41. Unpack: 2
  42. Unpack: 4' grep -e '^Unpack:' -e '^Install:' -e '^Configure:' -e '^Remove:' planner.log
  43. rm -f "$EIPPLOG"
  44. testsuccess aptget install foo -s --reinstall
  45. testsuccess aptget install foo -y --reinstall
  46. testsuccess test -r "$EIPPLOG"
  47. testsuccessequal 'Request: EIPP 0.1
  48. Architecture: amd64
  49. Architectures: amd64
  50. ReInstall: foo:amd64
  51. Planner: internal' head -n 5 "$EIPPLOG"
  52. aptinternalplanner < "$EIPPLOG" > planner.log || true
  53. testsuccessequal 'Unpack: 4' grep -e '^Unpack:' -e '^Install:' -e '^Configure:' -e '^Remove:' planner.log
  54. rm -f "$EIPPLOG"
  55. testsuccess aptget purge foo -s
  56. testsuccess aptget purge foo -y
  57. testsuccess test -r "$EIPPLOG"
  58. testsuccessequal 'Request: EIPP 0.1
  59. Architecture: amd64
  60. Architectures: amd64
  61. Remove: foo:amd64
  62. Planner: internal' head -n 5 "$EIPPLOG"
  63. aptinternalplanner < "$EIPPLOG" > planner.log || true
  64. testsuccessequal 'Remove: 4' grep -e '^Unpack:' -e '^Install:' -e '^Configure:' -e '^Remove:' planner.log
  65. testplannerfailuremsg() {
  66. local PLANNER="rootdir/usr/lib/apt/planners/$1"
  67. echo "$2" > "$PLANNER"
  68. chmod +x "$PLANNER"
  69. testfailuremsg "$3" apt install foo -s --planner $1
  70. }
  71. testplannerfailuremsg 'exit0withmsg' "#!/bin/sh
  72. echo 'Error: instant-exit
  73. Message: This planner exits instantly'
  74. exit 0" 'E: External planner failed with: This planner exits instantly'
  75. testplannerfailuremsg 'exit1withoutmsg' "#!/bin/sh
  76. exit 1" 'E: Sub-process exit1withoutmsg returned an error code (1)'
  77. testplannerfailuremsg 'exit1withmsg' "#!/bin/sh
  78. echo 'Error: instant-exit
  79. Message: This planner exits instantly'
  80. exit 1" 'E: External planner failed with: This planner exits instantly
  81. E: Sub-process exit1withmsg returned an error code (1)'