test-bug-lp1550741-heisestate 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. insertpackage 'unstable' 'module-init-tools' 'amd64' '1.0' 'Depends: libkmod2 (= 21-1)'
  8. insertpackage 'unstable' 'libkmod2' 'amd64' '0.22-1'
  9. insertinstalledpackage 'module-init-tools' 'amd64' '0.1'
  10. setupaptarchive
  11. # this test only works if the python-apt is build against the same
  12. # ABI version as the apt we are testing here
  13. PYAPT_LIB_VER=$(runpython3 -c 'import apt_pkg;print(apt_pkg.LIB_VERSION)' 2>/dev/null || true)
  14. if [ ! -f $LIBRARYPATH/libapt-pkg.so.$PYAPT_LIB_VER ]; then
  15. msgskip "python-apt build with the wrong library version: $PYAPT_LIB_VER"
  16. exit 0
  17. fi
  18. # we can not test this using our normal sh tests
  19. cat > test.py <<EOF
  20. #!/usr/bin/python3
  21. import sys
  22. import apt
  23. def in_valid_state(pkg):
  24. return (pkg.marked_keep or
  25. pkg.marked_install or
  26. pkg.marked_upgrade or
  27. pkg.marked_delete or
  28. pkg.marked_downgrade or
  29. pkg.marked_reinstall)
  30. # main
  31. cache=apt.Cache()
  32. pkgname="module-init-tools"
  33. if not in_valid_state(cache[pkgname]):
  34. print("the test is broken, %s should be in a valid state" % pkgname)
  35. sys.exit(99)
  36. cache.upgrade(True)
  37. if not in_valid_state(cache[pkgname]):
  38. print("package %s is in a heisen-state" % pkgname)
  39. sys.exit(2)
  40. EOF
  41. testsuccess runpython3 test.py