From 374f8492e6f109e8427816a8f513e5e8feda9049 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 9 Nov 2014 15:40:19 +0100 Subject: allow uninstalled packages to be put on hold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dpkg wants to know about a package before it can be put on hold, so we have to at least hint about its existance in the available file it "maintaince" to know about such stuff. The simple thing would probably be to just feed all Packages files into dpkg as well, but what would be the point really? Exactly, so we take a shortcut here and just create dummies in the available file if we need to which isn't going to be that common as usually you are holding packages back and not off. Who would have thought that a simple feature like setting a package on hold requires more than 200 lines of codeā€¦ at least with the testcase it is now explicitly tested code. --- test/integration/test-apt-mark | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 test/integration/test-apt-mark (limited to 'test/integration/test-apt-mark') diff --git a/test/integration/test-apt-mark b/test/integration/test-apt-mark new file mode 100755 index 000000000..69e0f933d --- /dev/null +++ b/test/integration/test-apt-mark @@ -0,0 +1,72 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'i386' + +insertpackage 'unstable' 'bar' 'amd64,i386' '1' +insertpackage 'unstable' 'uninstalled' 'all' '1' +insertpackage 'unstable' 'uninstalled-native' 'amd64' '1' + +insertinstalledpackage 'foo' 'all' '1' +insertinstalledpackage 'bar' 'amd64' '1' + +setupaptarchive + +# dpkg is "installed" by our test framework +testdpkginstalled dpkg + +testnoautopkg() { + testempty aptmark showauto + testequal 'bar +dpkg +foo' aptmark showmanual + testequal 'bar +foo' aptmark showmanual bar foo uninstalled +} +testmarkonpkgasauto() { + testsuccess aptmark $1 foo + testequal 'foo' aptmark showauto + testequal 'foo' aptmark showauto foo + testequal 'bar +dpkg' aptmark showmanual + testequal 'bar' aptmark showmanual bar + + testsuccess aptmark $2 foo + testnoautopkg +} + +testequal 'E: No packages found' aptmark auto +testequal 'E: No packages found' aptmark manual + +testnoautopkg +testmarkonpkgasauto 'auto' 'manual' +testmarkonpkgasauto 'markauto' 'unmarkauto' + +testnoholdpkg() { + testempty aptmark showhold + testempty aptmark showholds # typical "typo" + testempty aptmark showhold dpkg + testempty aptmark showholds dpkg +} +testmarkonepkgashold() { + testsuccess aptmark hold $1 + testequal "$1" aptmark showhold + testequal "$1" aptmark showholds + testsuccess aptmark unhold $1 + testnoholdpkg +} + +testequal 'E: No packages found' aptmark hold +testequal 'E: No packages found' aptmark unhold + +testnoholdpkg +testmarkonepkgashold 'foo' +testmarkonepkgashold 'bar' +testmarkonepkgashold 'uninstalled' +testmarkonepkgashold 'uninstalled-native' + +testequal 'uninstalled set on hold.' aptmark hold uninstalled +testequal 'uninstalled-native set on hold.' aptmark hold uninstalled-native -- cgit v1.2.3 From 081c9d442a6d39fb9bc419fe3ce697cc791cb844 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 9 Nov 2014 21:38:53 +0100 Subject: various small additional tests and testcases Usually they don't provide a lot in terms of what they test, but they help in covering many lines from strictly anecdotal commands (stats, moo) and error messages, so that stuff which really needs to be tested, but isn't is better visible in coverage reports. Git-Dch: Ignore --- test/integration/test-apt-mark | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'test/integration/test-apt-mark') diff --git a/test/integration/test-apt-mark b/test/integration/test-apt-mark index 69e0f933d..0f62a12b4 100755 --- a/test/integration/test-apt-mark +++ b/test/integration/test-apt-mark @@ -20,21 +20,31 @@ testdpkginstalled dpkg testnoautopkg() { testempty aptmark showauto + testempty aptcache showauto testequal 'bar dpkg foo' aptmark showmanual testequal 'bar foo' aptmark showmanual bar foo uninstalled } -testmarkonpkgasauto() { - testsuccess aptmark $1 foo +testfooisauto() { testequal 'foo' aptmark showauto + testequal 'foo' aptcache showauto testequal 'foo' aptmark showauto foo + testequal 'foo' aptcache showauto foo testequal 'bar dpkg' aptmark showmanual testequal 'bar' aptmark showmanual bar +} +testmarkonpkgasauto() { + testsuccess $1 $2 foo + testfooisauto + testsuccess $1 $2 foo + testfooisauto - testsuccess aptmark $2 foo + testsuccess $1 $3 foo + testnoautopkg + testsuccess $1 $3 foo testnoautopkg } @@ -42,8 +52,9 @@ testequal 'E: No packages found' aptmark auto testequal 'E: No packages found' aptmark manual testnoautopkg -testmarkonpkgasauto 'auto' 'manual' -testmarkonpkgasauto 'markauto' 'unmarkauto' +testmarkonpkgasauto 'aptmark' 'auto' 'manual' +testmarkonpkgasauto 'aptmark' 'markauto' 'unmarkauto' +testmarkonpkgasauto 'aptget' 'markauto' 'unmarkauto' testnoholdpkg() { testempty aptmark showhold @@ -51,10 +62,19 @@ testnoholdpkg() { testempty aptmark showhold dpkg testempty aptmark showholds dpkg } -testmarkonepkgashold() { - testsuccess aptmark hold $1 +testpkgonhold() { testequal "$1" aptmark showhold testequal "$1" aptmark showholds + testequal "$1" aptmark showhold $1 + testequal "$1" aptmark showholds $1 +} +testmarkonepkgashold() { + testsuccess aptmark hold $1 + testpkgonhold $1 + testsuccess aptmark hold $1 + testpkgonhold $1 + testsuccess aptmark unhold $1 + testnoholdpkg testsuccess aptmark unhold $1 testnoholdpkg } -- cgit v1.2.3 From 1d838084dc775c0a4184edb4f3b9138903ac27fb Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 18 Nov 2014 13:41:18 +0100 Subject: use dpkg --merge-avail only if needed in apt-mark Only "recent" versions of dpkg support stdin for merge instead of a file, so as a quick fix we delay calling it until we really need it which fixes most of the problem already. Checking for a specific dpkg version here is deemed too much work, just like using a temporary file here and depends a too high requirement for this minor usecase. After all, it didn't work at all before, so we break nobody here and can fix it if someone complains (with a patch). --- test/integration/test-apt-mark | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/integration/test-apt-mark') diff --git a/test/integration/test-apt-mark b/test/integration/test-apt-mark index 0f62a12b4..5a3ae4b2f 100755 --- a/test/integration/test-apt-mark +++ b/test/integration/test-apt-mark @@ -85,6 +85,15 @@ testequal 'E: No packages found' aptmark unhold testnoholdpkg testmarkonepkgashold 'foo' testmarkonepkgashold 'bar' + +msgtest 'dpkg supports --merge-avail via' 'stdin' +if dpkg --merge-avail - < /dev/null >/dev/null 2>&1; then + msgpass +else + msgskip 'dpkg version too old' + exit 0 +fi + testmarkonepkgashold 'uninstalled' testmarkonepkgashold 'uninstalled-native' -- cgit v1.2.3 From 25b86db159fbc3c043628e285c0c1ef24dec2c6e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 10 Mar 2015 00:59:44 +0100 Subject: test exitcode as well as string equality We use test{success,failure} now all over the place in the framework, so its only consequencial to do this in the situations in which we test for a specific output as well. Git-Dch: Ignore --- test/integration/test-apt-mark | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'test/integration/test-apt-mark') diff --git a/test/integration/test-apt-mark b/test/integration/test-apt-mark index 5a3ae4b2f..9b68945f9 100755 --- a/test/integration/test-apt-mark +++ b/test/integration/test-apt-mark @@ -21,20 +21,20 @@ testdpkginstalled dpkg testnoautopkg() { testempty aptmark showauto testempty aptcache showauto - testequal 'bar + testsuccessequal 'bar dpkg foo' aptmark showmanual - testequal 'bar + testsuccessequal 'bar foo' aptmark showmanual bar foo uninstalled } testfooisauto() { - testequal 'foo' aptmark showauto - testequal 'foo' aptcache showauto - testequal 'foo' aptmark showauto foo - testequal 'foo' aptcache showauto foo - testequal 'bar + testsuccessequal 'foo' aptmark showauto + testsuccessequal 'foo' aptcache showauto + testsuccessequal 'foo' aptmark showauto foo + testsuccessequal 'foo' aptcache showauto foo + testsuccessequal 'bar dpkg' aptmark showmanual - testequal 'bar' aptmark showmanual bar + testsuccessequal 'bar' aptmark showmanual bar } testmarkonpkgasauto() { testsuccess $1 $2 foo @@ -48,8 +48,8 @@ testmarkonpkgasauto() { testnoautopkg } -testequal 'E: No packages found' aptmark auto -testequal 'E: No packages found' aptmark manual +testfailureequal 'E: No packages found' aptmark auto +testfailureequal 'E: No packages found' aptmark manual testnoautopkg testmarkonpkgasauto 'aptmark' 'auto' 'manual' @@ -63,10 +63,10 @@ testnoholdpkg() { testempty aptmark showholds dpkg } testpkgonhold() { - testequal "$1" aptmark showhold - testequal "$1" aptmark showholds - testequal "$1" aptmark showhold $1 - testequal "$1" aptmark showholds $1 + testsuccessequal "$1" aptmark showhold + testsuccessequal "$1" aptmark showholds + testsuccessequal "$1" aptmark showhold $1 + testsuccessequal "$1" aptmark showholds $1 } testmarkonepkgashold() { testsuccess aptmark hold $1 @@ -79,8 +79,8 @@ testmarkonepkgashold() { testnoholdpkg } -testequal 'E: No packages found' aptmark hold -testequal 'E: No packages found' aptmark unhold +testfailureequal 'E: No packages found' aptmark hold +testfailureequal 'E: No packages found' aptmark unhold testnoholdpkg testmarkonepkgashold 'foo' @@ -97,5 +97,5 @@ fi testmarkonepkgashold 'uninstalled' testmarkonepkgashold 'uninstalled-native' -testequal 'uninstalled set on hold.' aptmark hold uninstalled -testequal 'uninstalled-native set on hold.' aptmark hold uninstalled-native +testsuccessequal 'uninstalled set on hold.' aptmark hold uninstalled +testsuccessequal 'uninstalled-native set on hold.' aptmark hold uninstalled-native -- cgit v1.2.3