summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2016-03-15 13:13:54 +0100
committerJulian Andres Klode <jak@debian.org>2016-03-15 18:55:02 +0100
commit0390edd5452b081f8efcf412f96d535a1d959457 (patch)
tree51ac5fe01a309f4f59b3bb639bc9b2fc1176a416 /test
parent07ea3af0fe55fdfe976ab847c5c88efd703d1282 (diff)
Fix bug where the problemresolve can put a pkg into a heisenstate
The problemresolver will set the candidate version for pkg P back to the current version if it encounters an impossible to satisfy critical dependency on P. However it did not set the State of the package back as well which lead to a situation where P is neither in Keep,Install,Upgrade,Delete state. Note that this can not be tested via the traditional sh based framework. I added a python-apt based test for this. LP: #1550741 [jak@debian.org: Make the test not fail if apt_pkg cannot be imported]
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework1
-rwxr-xr-xtest/integration/test-bug-lp1550741-heisestate48
2 files changed, 49 insertions, 0 deletions
diff --git a/test/integration/framework b/test/integration/framework
index b65b0b86f..a1db232e9 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -175,6 +175,7 @@ runapt() {
esac
MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}" "$CMD" "$@"
}
+runpython3() { runapt command python3 "$@"; }
aptconfig() { runapt apt-config "$@"; }
aptcache() { runapt apt-cache "$@"; }
aptcdrom() { runapt apt-cdrom "$@"; }
diff --git a/test/integration/test-bug-lp1550741-heisestate b/test/integration/test-bug-lp1550741-heisestate
new file mode 100755
index 000000000..76fdcb83c
--- /dev/null
+++ b/test/integration/test-bug-lp1550741-heisestate
@@ -0,0 +1,48 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'amd64'
+
+insertpackage 'unstable' 'module-init-tools' 'amd64' '1.0' 'Depends: libkmod2 (= 21-1)'
+insertpackage 'unstable' 'libkmod2' 'amd64' '0.22-1'
+insertinstalledpackage 'module-init-tools' 'amd64' '0.1'
+
+setupaptarchive
+
+# this test only works if the python-apt is build against the same
+# ABI version as the apt we are testing here
+PYAPT_LIB_VER=$(runpython3 -c 'import apt_pkg;print(apt_pkg.LIB_VERSION)' 2>/dev/null || true)
+if [ ! -f $LIBRARYPATH/libapt-pkg.so.$PYAPT_LIB_VER ]; then
+ msgskip "python-apt build with the wrong library version: $PYAPT_LIB_VER"
+ exit 0
+fi
+
+# we can not test this using our normal sh tests
+cat > test.py <<EOF
+#!/usr/bin/python3
+import sys
+import apt
+def in_valid_state(pkg):
+ return (pkg.marked_keep or
+ pkg.marked_install or
+ pkg.marked_upgrade or
+ pkg.marked_delete or
+ pkg.marked_downgrade or
+ pkg.marked_reinstall)
+# main
+cache=apt.Cache()
+pkgname="module-init-tools"
+if not in_valid_state(cache[pkgname]):
+ print("the test is broken, %s should be in a valid state" % pkgname)
+ sys.exit(99)
+cache.upgrade(True)
+if not in_valid_state(cache[pkgname]):
+ print("package %s is in a heisen-state" % pkgname)
+ sys.exit(2)
+
+EOF
+testsuccess runpython3 test.py