Переглянути джерело

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
David Kalnischkies 11 роки тому
батько
коміт
081c9d442a

+ 2 - 2
cmdline/apt-cache.cc

@@ -116,7 +116,7 @@ static bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important)
 		  continue;
 		  continue;
 
 
 	    // Skip conflicts and replaces
 	    // Skip conflicts and replaces
-	    if (End.IsNegative() == true)
+	    if (End.IsNegative() == true || End->Type == pkgCache::Dep::Replaces)
 	       continue;
 	       continue;
 
 
 	    // Verify the or group
 	    // Verify the or group
@@ -133,7 +133,7 @@ static bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important)
 		  break;
 		  break;
 	       }
 	       }
 	       delete [] VList;
 	       delete [] VList;
-	       
+
 	       if (Start == End)
 	       if (Start == End)
 		  break;
 		  break;
 	       ++Start;
 	       ++Start;

+ 1 - 1
test/integration/framework

@@ -300,7 +300,7 @@ getarchitecture() {
 }
 }
 
 
 getarchitectures() {
 getarchitectures() {
-	echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
+	aptconfig dump --no-empty --format '%v%n' APT::Architecture APT::Architectures | sort -u | tr '\n' ' '
 }
 }
 
 
 getarchitecturesfromcommalist() {
 getarchitecturesfromcommalist() {

+ 11 - 0
test/integration/test-00-commands-have-help

@@ -50,3 +50,14 @@ done
 for CMD in 'apt-dump-solver'  'apt-internal-solver'; do
 for CMD in 'apt-dump-solver'  'apt-internal-solver'; do
 	checkoptions "$(echo "$CMD" | tr -d '-')"
 	checkoptions "$(echo "$CMD" | tr -d '-')"
 done
 done
+
+# in times of need, we all look for super cow to save the day
+testsuccess aptget moo
+testsuccess aptget moo -q=2
+testsuccess aptget moo moo
+testsuccess aptget moo moo -q=2
+testsuccess aptget moo moo --color
+testsuccess aptget moo moo moo
+testsuccess aptget moo moo moo -q=2
+testsuccess aptget moo moo moo moo
+testsuccess aptget moo moo moo moo -q=2

+ 124 - 0
test/integration/test-apt-cache

@@ -0,0 +1,124 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+DESCR='Some description
+ That has multiple lines'
+insertpackage 'unstable' 'fancy' 'all' '1'
+insertpackage 'unstable,installed' 'foo' 'all' '1' 'Depends: bar
+Conflicts: foobar
+Recommends: cool (>= 2) | cooler (<< 5)' "$DESCR"
+insertpackage 'unstable' 'bar' 'all' '1' 'Depends: bar
+Breaks: foo (<< 1)
+Replaces: foo (<< 1)' "$DESCR"
+
+setupaptarchive
+
+# dpkg is installed by our framework
+testdpkginstalled 'dpkg'
+testempty aptcache unmet dpkg
+
+# FIXME: Find some usecase for unmet as it seems kinda useless/broken
+#testsuccess aptcache unmet
+#testsuccess aptcache unmet foo
+
+# not too useful to test, but makes coverage green…
+testsuccess aptcache stats
+cp rootdir/tmp/testsuccess.output stats.output
+testsuccess test -s stats.output
+testsuccess aptcache xvcg foo
+cp rootdir/tmp/testsuccess.output xvcg.output
+testsuccess test -s xvcg.output
+testsuccess aptcache dotty foo
+cp rootdir/tmp/testsuccess.output dotty.output
+testsuccess test -s dotty.output
+# for this, even the sourcecode says it is useless (expect debugging)
+testsuccess aptcache dump
+cp rootdir/tmp/testsuccess.output dump.output
+testsuccess test -s dump.output
+
+testequal 'dpkg
+bar
+fancy
+foo' aptcache pkgnames
+testequal 'bar' aptcache pkgnames bar
+testequal 'fancy
+foo' aptcache pkgnames f
+
+testequal "       foo |          1 | file:$(readlink -f .)/aptarchive/ unstable/main amd64 Packages" aptcache madison foo
+
+### depends
+
+testequal 'foo
+  Depends: bar
+ |Recommends: <cool>
+  Recommends: <cooler>
+  Conflicts: <foobar>
+  Conflicts: <foobar:i386>' aptcache depends foo
+testequal 'foo
+  Depends: bar
+  Recommends: <cool>
+  Conflicts: <foobar>
+  Conflicts: <foobar:i386>' aptcache depends foo -o APT::Cache::ShowOnlyFirstOr=1
+testequal 'foo
+  Depends: bar
+ |Recommends: <cool> (>= 2)
+  Recommends: <cooler> (<< 5)
+  Conflicts: <foobar>
+  Conflicts: <foobar:i386>' aptcache depends foo -o APT::Cache::ShowVersion=1
+testequal 'foo
+  Depends: bar
+  Conflicts: <foobar>
+  Conflicts: <foobar:i386>' aptcache depends foo --no-recommends
+testequal 'foo
+  Depends: bar' aptcache depends foo --important
+testequal 'foo
+  Conflicts: <foobar>
+  Conflicts: <foobar:i386>' aptcache depends foo --important --no-depends --conflicts
+testequal 'foo
+  Depends: bar
+ |Recommends: <cool>
+  Recommends: <cooler>
+  Conflicts: <foobar>
+  Conflicts: <foobar:i386>
+bar
+  Depends: bar
+  Breaks: foo
+  Breaks: <foo:i386>
+  Replaces: foo
+  Replaces: <foo:i386>
+<cool>
+<cooler>
+<foobar>
+<foobar:i386>
+<foo:i386>' aptcache depends foo --recurse
+testequal 'foo
+  Depends: bar
+bar
+  Depends: bar
+  Replaces: foo
+  Replaces: <foo:i386>
+<foo:i386>' aptcache depends foo --recurse --important --replaces
+
+## rdpends
+
+testequal 'foo
+Reverse Depends:
+  bar
+  bar' aptcache rdepends foo
+testequal 'foo
+Reverse Depends:
+  Replaces: bar
+  Breaks: bar' aptcache rdepends foo -o APT::Cache::ShowDependencyType=1
+testequal 'foo
+Reverse Depends:
+  Replaces: bar (<< 1)
+  Breaks: bar (<< 1)' aptcache rdepends foo -o APT::Cache::ShowDependencyType=1 -o APT::Cache::ShowVersion=1
+testequal 'foo
+Reverse Depends:
+  Breaks: bar (<< 1)' aptcache rdepends foo -o APT::Cache::ShowDependencyType=1 -o APT::Cache::ShowVersion=1 --important --breaks

+ 3 - 0
test/integration/test-apt-cli-search

@@ -25,6 +25,9 @@ setupaptarchive
 
 
 APTARCHIVE=$(readlink -f ./aptarchive)
 APTARCHIVE=$(readlink -f ./aptarchive)
 
 
+testequal 'E: You must give at least one search pattern' aptcache search
+testequal 'E: You must give at least one search pattern' apt search
+
 # with OP progress 
 # with OP progress 
 testequal "Sorting...
 testequal "Sorting...
 Full Text Search...
 Full Text Search...

+ 11 - 0
test/integration/test-apt-cli-show

@@ -36,3 +36,14 @@ APT-Sources: file:$APTARCHIVE/ unstable/main i386 Packages
 Description: Some description 
 Description: Some description 
  That has multiple lines
  That has multiple lines
 " apt show foo
 " apt show foo
+
+# this is the default, but disabled by the testcases
+testsuccess apt show foo -o Apt::Cmd::Disable-Script-Warning=0
+cp rootdir/tmp/testsuccess.output aptshow.output
+testsuccess grep '^WARNING: ' aptshow.output
+
+if [ "$(id -u)" != '0' ]; then
+	testsuccess apt install foo -s -o APT::Get::Show-User-Simulation-Note=1
+	cp rootdir/tmp/testsuccess.output aptshow.output
+	testsuccess grep '^NOTE: ' aptshow.output
+fi

+ 7 - 0
test/integration/test-apt-cli-update

@@ -8,10 +8,17 @@ setupenvironment
 configarchitecture "i386"
 configarchitecture "i386"
 
 
 insertpackage 'unstable' 'foo' 'all' '2.0'
 insertpackage 'unstable' 'foo' 'all' '2.0'
+cp rootdir/var/lib/dpkg/status dpkg.status
 insertinstalledpackage 'foo' 'all' '1.0'
 insertinstalledpackage 'foo' 'all' '1.0'
 
 
 setupaptarchive --no-update
 setupaptarchive --no-update
 
 
 APTARCHIVE=$(readlink -f ./aptarchive)
 APTARCHIVE=$(readlink -f ./aptarchive)
 
 
+testequal 'E: The update command takes no arguments' apt update -q arguments
+
 testequal "1 package can be upgraded. Run 'apt list --upgradable' to see it." apt update -q
 testequal "1 package can be upgraded. Run 'apt list --upgradable' to see it." apt update -q
+
+cp dpkg.status rootdir/var/lib/dpkg/status
+insertinstalledpackage 'foo' 'all' '2.0'
+testequal 'All packages are up to date.' apt update -q

+ 36 - 0
test/integration/test-apt-config

@@ -0,0 +1,36 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64'
+
+testsuccess aptconfig dump
+testequal 'APT::Architecture "amd64";' aptconfig dump APT::Architecture
+testempty aptconfig dump config::which::does::not::exist
+
+testequal 'APT::Architectures "";
+APT::Architectures:: "amd64";' aptconfig dump APT::Architectures
+testequal 'APT::Architectures:: "amd64";' aptconfig dump --no-empty APT::Architectures
+testequal 'amd64' aptconfig dump --no-empty --format='%v%n' APT::Architectures
+
+testempty aptconfig shell
+testequal 'E: Arguments not in pairs' aptconfig shell APT::Architecture
+testempty aptconfig shell APT::Architecture ARCH # incorrect order
+testequal "ARCH='amd64'" aptconfig shell ARCH APT::Architecture
+
+ROOTDIR="$(readlink -f rootdir)"
+testequal "CONFIG='apt.conf'" aptconfig shell CONFIG Dir::Etc::main
+testequal "CONFIG='${ROOTDIR}/etc/apt/apt.conf'" aptconfig shell CONFIG Dir::Etc::main/f
+testequal "CONFIG='etc/apt/'" aptconfig shell CONFIG Dir::Etc
+testequal "CONFIG='${ROOTDIR}/etc/apt/'" aptconfig shell CONFIG Dir::Etc/ # old style
+testequal "CONFIG='${ROOTDIR}/etc/apt/'" aptconfig shell CONFIG Dir::Etc/d
+
+testempty aptconfig dump --no-empty --format='%v%n' APT::Build-Profiles
+export DEB_BUILD_PROFILES='nodoc stage1'
+testequal 'nodoc
+stage1' aptconfig dump --no-empty --format='%v%n' APT::Build-Profiles
+unset DEB_BUILD_PROFILES
+testempty aptconfig dump --no-empty --format='%v%n' APT::Build-Profiles

+ 7 - 5
test/integration/test-apt-helper

@@ -53,7 +53,7 @@ echo "http://some-proxy"
 EOF
 EOF
     chmod 755 apt-proxy-detect
     chmod 755 apt-proxy-detect
     echo "Acquire::http::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
     echo "Acquire::http::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
-    
+
     testequal "Using proxy 'http://some-proxy' for URL 'http://www.example.com/'" apthelper auto-detect-proxy http://www.example.com
     testequal "Using proxy 'http://some-proxy' for URL 'http://www.example.com/'" apthelper auto-detect-proxy http://www.example.com
 
 
 
 
@@ -64,13 +64,15 @@ echo "https://https-proxy"
 EOF
 EOF
     chmod 755 apt-proxy-detect
     chmod 755 apt-proxy-detect
     echo "Acquire::https::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
     echo "Acquire::https::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
-    
-    testequal "Using proxy 'https://https-proxy' for URL 'https://ssl.example.com/'" apthelper auto-detect-proxy https://ssl.example.com 
 
 
-
-    
+    testequal "Using proxy 'https://https-proxy' for URL 'https://ssl.example.com/'" apthelper auto-detect-proxy https://ssl.example.com
 }
 }
 
 
 test_apt_helper_download
 test_apt_helper_download
 test_apt_helper_detect_proxy
 test_apt_helper_detect_proxy
 
 
+# test failure modes
+testequal 'E: Invalid operation download' apthelper download
+testequal 'E: Must specify at least one pair url/filename' apthelper download-file
+testequal 'E: Must specify at least one pair url/filename' apthelper download-file http://example.org/
+testequal 'E: Need one URL as argument' apthelper auto-detect-proxy

+ 27 - 7
test/integration/test-apt-mark

@@ -20,21 +20,31 @@ testdpkginstalled dpkg
 
 
 testnoautopkg() {
 testnoautopkg() {
 	testempty aptmark showauto
 	testempty aptmark showauto
+	testempty aptcache showauto
 	testequal 'bar
 	testequal 'bar
 dpkg
 dpkg
 foo' aptmark showmanual
 foo' aptmark showmanual
 	testequal 'bar
 	testequal 'bar
 foo' aptmark showmanual bar foo uninstalled
 foo' aptmark showmanual bar foo uninstalled
 }
 }
-testmarkonpkgasauto() {
-	testsuccess aptmark $1 foo
+testfooisauto() {
 	testequal 'foo' aptmark showauto
 	testequal 'foo' aptmark showauto
+	testequal 'foo' aptcache showauto
 	testequal 'foo' aptmark showauto foo
 	testequal 'foo' aptmark showauto foo
+	testequal 'foo' aptcache showauto foo
 	testequal 'bar
 	testequal 'bar
 dpkg' aptmark showmanual
 dpkg' aptmark showmanual
 	testequal 'bar' aptmark showmanual bar
 	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
 	testnoautopkg
 }
 }
 
 
@@ -42,8 +52,9 @@ testequal 'E: No packages found' aptmark auto
 testequal 'E: No packages found' aptmark manual
 testequal 'E: No packages found' aptmark manual
 
 
 testnoautopkg
 testnoautopkg
-testmarkonpkgasauto 'auto' 'manual'
-testmarkonpkgasauto 'markauto' 'unmarkauto'
+testmarkonpkgasauto 'aptmark' 'auto' 'manual'
+testmarkonpkgasauto 'aptmark' 'markauto' 'unmarkauto'
+testmarkonpkgasauto 'aptget' 'markauto' 'unmarkauto'
 
 
 testnoholdpkg() {
 testnoholdpkg() {
 	testempty aptmark showhold
 	testempty aptmark showhold
@@ -51,10 +62,19 @@ testnoholdpkg() {
 	testempty aptmark showhold dpkg
 	testempty aptmark showhold dpkg
 	testempty aptmark showholds dpkg
 	testempty aptmark showholds dpkg
 }
 }
-testmarkonepkgashold() {
-	testsuccess aptmark hold $1
+testpkgonhold() {
 	testequal "$1" aptmark showhold
 	testequal "$1" aptmark showhold
 	testequal "$1" aptmark showholds
 	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
 	testsuccess aptmark unhold $1
 	testnoholdpkg
 	testnoholdpkg
 }
 }

+ 4 - 2
test/integration/test-apt-update-stale

@@ -14,9 +14,11 @@ configarchitecture "i386"
 
 
 insertpackage 'unstable' 'foo' 'all' '1.0'
 insertpackage 'unstable' 'foo' 'all' '1.0'
 
 
-setupaptarchive
+setupaptarchive --no-update
 changetowebserver
 changetowebserver
-aptget update -qq
+
+echo "Acquire::Languages \"none\";" > rootdir/etc/apt/apt.conf.d/00nolanguages
+testsuccess aptget update
 listcurrentlistsdirectory > lists.before
 listcurrentlistsdirectory > lists.before
 
 
 # insert new version
 # insert new version

+ 30 - 2
test/integration/test-external-dependency-solver-protocol

@@ -12,7 +12,10 @@ insertinstalledpackage 'stuff' 'all' '1'
 insertpackage 'unstable' 'cool' 'all' '2' 'Multi-Arch: foreign'
 insertpackage 'unstable' 'cool' 'all' '2' 'Multi-Arch: foreign'
 insertpackage 'unstable' 'stuff' 'all' '2' 'Multi-Arch: foreign'
 insertpackage 'unstable' 'stuff' 'all' '2' 'Multi-Arch: foreign'
 insertpackage 'unstable' 'coolstuff' 'i386,amd64' '2' 'Depends: cool, stuff'
 insertpackage 'unstable' 'coolstuff' 'i386,amd64' '2' 'Depends: cool, stuff'
-insertpackage 'unstable' 'awesome' 'all' '2' 'Multi-Arch: foreign'
+insertpackage 'unstable' 'awesome' 'all' '2' 'Multi-Arch: foreign
+Conflicts: badstuff'
+insertpackage 'unstable' 'badstuff' 'all' '2' 'Multi-Arch: foreign
+Conflicts: awesome'
 insertpackage 'unstable' 'awesomecoolstuff' 'i386' '2' 'Depends: coolstuff, awesome'
 insertpackage 'unstable' 'awesomecoolstuff' 'i386' '2' 'Depends: coolstuff, awesome'
 
 
 insertpackage 'experimental' 'cool' 'all' '3' 'Multi-Arch: foreign'
 insertpackage 'experimental' 'cool' 'all' '3' 'Multi-Arch: foreign'
@@ -44,6 +47,14 @@ The following NEW packages will be installed:
 Inst coolstuff (3 experimental [amd64])
 Inst coolstuff (3 experimental [amd64])
 Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff -s
 Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff -s
 
 
+testequal 'Reading package lists...
+Building dependency tree...
+Execute external solver...
+The following packages will be REMOVED:
+  cool*
+0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
+Purg cool [1]' aptget purge --solver apt cool -s
+
 testsuccess aptget install awesomecoolstuff:i386 -s
 testsuccess aptget install awesomecoolstuff:i386 -s
 testsuccess aptget install --solver apt awesomecoolstuff:i386 -s
 testsuccess aptget install --solver apt awesomecoolstuff:i386 -s
 
 
@@ -57,9 +68,13 @@ testsuccess aptget dist-upgrade -s --solver apt
 testsuccess aptget upgrade -s
 testsuccess aptget upgrade -s
 testsuccess aptget upgrade -s --solver apt
 testsuccess aptget upgrade -s --solver apt
 
 
+testfailure aptget install awesome badstuff -s
+testfailure aptget install awesome badstuff -s --solver apt
+testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output
+
 configarchitecture 'armel'
 configarchitecture 'armel'
 msgtest 'Test direct calling is okay for' 'apt-internal-solver'
 msgtest 'Test direct calling is okay for' 'apt-internal-solver'
-cat /tmp/dump.edsp | aptinternalsolver > solver.result 2>&1 || true
+cat /tmp/dump.edsp | aptinternalsolver -q=0 > solver.result 2>&1 || true
 if [ "$(tail -n2 solver.result | head -n1 )" = "Message: Done" ]; then
 if [ "$(tail -n2 solver.result | head -n1 )" = "Message: Done" ]; then
 	msgpass
 	msgpass
 else
 else
@@ -69,3 +84,16 @@ fi
 rm -f /tmp/dump.edsp
 rm -f /tmp/dump.edsp
 
 
 testfailure aptget install --solver apt awesomecoolstuff:i386 -s
 testfailure aptget install --solver apt awesomecoolstuff:i386 -s
+
+testsuccess aptinternalsolver scenario
+testequal 'Package: stuff
+Source: stuff
+Architecture: all
+Version: 1
+Installed: yes
+APT-ID: 2
+Priority: optional
+Section: other
+APT-Pin: 100
+APT-Candidate: yes
+' aptinternalsolver scenario stuff