From 8daf68e366fa9fa2794ae667f51562663856237c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 15 Feb 2014 13:38:39 +0100 Subject: propagate a negative score point along breaks/conflicts versioned -dev packages like db and boost have the problem of no dependencies which would give them a competitive advantage against an older incarnation of the -dev package, so they tend to be kept back until the old version is removed from the archive, which, if the user has older releases in its sources can take a long time (or never happens). The newer version has a conflicts/breaks against the older one, but the older one hasn't against the newer, so by giving via the conflicts the older one a reduced score the newer one can win if there is no other reason to keep it. If both have a conflict against each other the scoring will cancel itself out, so no harm done. This gives "action" a slightly bigger edge in breaks/conflicts cases than before, but holding back isn't a really good solution anyway. --- .../test-allow-scores-for-all-dependency-types | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 test/integration/test-allow-scores-for-all-dependency-types (limited to 'test') diff --git a/test/integration/test-allow-scores-for-all-dependency-types b/test/integration/test-allow-scores-for-all-dependency-types new file mode 100755 index 000000000..7e15a883b --- /dev/null +++ b/test/integration/test-allow-scores-for-all-dependency-types @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' + +insertinstalledpackage 'libdb-dev' 'amd64' '5.1.7' 'Depends: libdb5.1-dev' +insertinstalledpackage 'libdb5.1-dev' 'amd64' '5.1.29-7' + +insertpackage 'unstable' 'libdb-dev' 'amd64' '5.3.0' 'Depends: libdb5.3-dev +Conflicts: libdb5.1-dev' +insertpackage 'unstable' 'libdb5.1-dev' 'amd64' '5.1.29-7' +insertpackage 'unstable' 'libdb5.3-dev' 'amd64' '5.3.28-3' 'Conflicts: libdb5.1-dev' + +insertpackage 'unstable' 'foo' 'amd64' '1' +insertpackage 'unstable' 'bar' 'amd64' '1' +insertpackage 'unstable' 'foo' 'amd64' '2' 'Conflicts: bar' +insertpackage 'unstable' 'bar' 'amd64' '2' 'Conflicts: foo' + +setupaptarchive + +testequal 'Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + libdb5.1-dev +The following NEW packages will be installed: + libdb5.3-dev +The following packages will be upgraded: + libdb-dev +1 upgraded, 1 newly installed, 1 to remove and 0 not upgraded. +Remv libdb5.1-dev [5.1.29-7] [libdb-dev:amd64 ] +Inst libdb-dev [5.1.7] (5.3.0 unstable [amd64]) [] +Inst libdb5.3-dev (5.3.28-3 unstable [amd64]) +Conf libdb5.3-dev (5.3.28-3 unstable [amd64]) +Conf libdb-dev (5.3.0 unstable [amd64])' aptget dist-upgrade -s + +rm rootdir/var/lib/dpkg/status +insertinstalledpackage 'foo' 'amd64' '1' +insertinstalledpackage 'bar' 'amd64' '1' + +testequal 'Reading package lists... +Building dependency tree... +The following packages have been kept back: + bar foo +0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.' aptget dist-upgrade -s -- cgit v1.2.3 From 2252183c69fb5e3e020b45c37d9728b3437d797d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 23 Feb 2014 22:22:15 +0100 Subject: show debug output only if told so in packagemanager Git-Dch: Ignore --- test/integration/test-conflicts-loop | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/integration/test-conflicts-loop b/test/integration/test-conflicts-loop index 4407fbd9d..4978fe1e8 100755 --- a/test/integration/test-conflicts-loop +++ b/test/integration/test-conflicts-loop @@ -6,11 +6,11 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture "i386" -insertinstalledpackage 'openjdk-6-jre' 'i386' '6b16-1.8-0ubuntu1' +insertinstalledpackage 'openjdk-6-jre' 'i386' '6b16-1.8-0ubuntu1' insertpackage 'unstable' 'openjdk-6-jre' 'i386' '6b20-1.9.8-0ubuntu1~10.04.1' 'Conflicts: openjdk-6-jre-headless (<< 6b17~pre3-1), openjdk-6-jre-lib (<< 6b17~pre3-1)' -insertinstalledpackage 'openjdk-6-jre-lib' 'i386' '6b16-1.8-0ubuntu1' +insertinstalledpackage 'openjdk-6-jre-lib' 'i386' '6b16-1.8-0ubuntu1' insertpackage 'unstable' 'openjdk-6-jre-lib' 'i386' '6b20-1.9.8-0ubuntu1~10.04.1' 'Conflicts: openjdk-6-jre (<< 6b17~pre3-1), openjdk-6-jre-headless (<< 6b17~pre3-1)' -insertinstalledpackage 'openjdk-6-jre-headless' 'i386' '6b16-1.8-0ubuntu1' +insertinstalledpackage 'openjdk-6-jre-headless' 'i386' '6b16-1.8-0ubuntu1' insertpackage 'unstable' 'openjdk-6-jre-headless' 'i386' '6b20-1.9.8-0ubuntu1~10.04.1' 'Conflicts: openjdk-6-jre (<< 6b17~pre3-1), openjdk-6-jre-lib (<< 6b17~pre3-1)' setupaptarchive @@ -19,16 +19,10 @@ testequal 'Reading package lists... Building dependency tree... The following packages will be upgraded: openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib - openjdk-6-jre-lib:i386 conflicts with openjdk-6-jre:i386 - openjdk-6-jre:i386 conflicts with openjdk-6-jre-headless:i386 - openjdk-6-jre-headless:i386 conflicts with openjdk-6-jre:i386 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Remv openjdk-6-jre [6b16-1.8-0ubuntu1] - openjdk-6-jre-headless:i386 conflicts with openjdk-6-jre-lib:i386 Remv openjdk-6-jre-lib [6b16-1.8-0ubuntu1] Inst openjdk-6-jre-headless [6b16-1.8-0ubuntu1] (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) - openjdk-6-jre:i386 conflicts with openjdk-6-jre-lib:i386 - openjdk-6-jre:i386 conflicts with openjdk-6-jre-lib:i386 Inst openjdk-6-jre [6b16-1.8-0ubuntu1] (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) Inst openjdk-6-jre-lib [6b16-1.8-0ubuntu1] (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) Conf openjdk-6-jre-lib (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) -- cgit v1.2.3 From 9ec748ff103840c4c65471ca00d3b72984131ce4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 23 Feb 2014 22:24:27 +0100 Subject: check version before adding scores in resolver Prevents that "old" dependencies have an influence in the scoring. With positive dependencies this is usually not a problem, but negative dependencies can linger around for a long time. --- .../test-allow-scores-for-all-dependency-types | 131 ++++++++++++++++++--- 1 file changed, 114 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/integration/test-allow-scores-for-all-dependency-types b/test/integration/test-allow-scores-for-all-dependency-types index 7e15a883b..a5c98f3d6 100755 --- a/test/integration/test-allow-scores-for-all-dependency-types +++ b/test/integration/test-allow-scores-for-all-dependency-types @@ -6,21 +6,51 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture 'amd64' -insertinstalledpackage 'libdb-dev' 'amd64' '5.1.7' 'Depends: libdb5.1-dev' -insertinstalledpackage 'libdb5.1-dev' 'amd64' '5.1.29-7' - -insertpackage 'unstable' 'libdb-dev' 'amd64' '5.3.0' 'Depends: libdb5.3-dev +insertpackage 'unversioned' 'libdb-dev' 'amd64' '5.3.0' 'Depends: libdb5.3-dev Conflicts: libdb5.1-dev' -insertpackage 'unstable' 'libdb5.1-dev' 'amd64' '5.1.29-7' -insertpackage 'unstable' 'libdb5.3-dev' 'amd64' '5.3.28-3' 'Conflicts: libdb5.1-dev' +insertpackage 'unversioned' 'libdb5.1-dev' 'amd64' '5.1.29-7' +insertpackage 'unversioned' 'libdb5.3-dev' 'amd64' '5.3.28-3' 'Conflicts: libdb5.1-dev' + +insertpackage 'unversioned' 'foo' 'amd64' '1' +insertpackage 'unversioned' 'bar' 'amd64' '1' +insertpackage 'unversioned' 'foo' 'amd64' '2' 'Conflicts: bar' +insertpackage 'unversioned' 'bar' 'amd64' '2' 'Conflicts: foo' +insertpackage 'unversioned' 'baz' 'amd64' '2' 'Depends: bar | foo' + +insertpackage 'versioned' 'libdb-dev' 'amd64' '5.3.0' 'Depends: libdb5.3-dev +Conflicts: libdb5.1-dev (<< 5.2)' +insertpackage 'versioned' 'libdb5.3-dev' 'amd64' '5.3.28-3' 'Conflicts: libdb5.1-dev (<< 5.2)' + +insertpackage 'versioned' 'foo' 'amd64' '2' 'Conflicts: bar (<= 2)' +insertpackage 'versioned' 'bar' 'amd64' '2' 'Conflicts: foo (<= 2)' +insertpackage 'versioned' 'baz' 'amd64' '2' 'Depends: bar (>= 2) | foo (>= 2)' + +insertpackage 'multipleno' 'foo' 'amd64' '2.1' 'Conflicts: bar (<= 3)' +insertpackage 'multipleno' 'bar' 'amd64' '2.1' 'Conflicts: foo (<= 3), foo (<= 1)' -insertpackage 'unstable' 'foo' 'amd64' '1' -insertpackage 'unstable' 'bar' 'amd64' '1' -insertpackage 'unstable' 'foo' 'amd64' '2' 'Conflicts: bar' -insertpackage 'unstable' 'bar' 'amd64' '2' 'Conflicts: foo' +insertpackage 'multipleyes' 'foo' 'amd64' '2.2' 'Conflicts: bar (<= 3)' +# having foo multiple times as conflict is a non-advisable hack in general +insertpackage 'multipleyes' 'bar' 'amd64' '2.2' 'Conflicts: foo (<= 3), foo (<= 3)' +cp rootdir/var/lib/dpkg/status rootdir/var/lib/dpkg/status-backup setupaptarchive +insertinstalledpackage 'libdb-dev' 'amd64' '5.1.7' 'Depends: libdb5.1-dev' +insertinstalledpackage 'libdb5.1-dev' 'amd64' '5.1.29-7' +testequal 'Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + libdb5.1-dev +The following NEW packages will be installed: + libdb5.3-dev +The following packages will be upgraded: + libdb-dev +1 upgraded, 1 newly installed, 1 to remove and 0 not upgraded. +Remv libdb5.1-dev [5.1.29-7] [libdb-dev:amd64 ] +Inst libdb-dev [5.1.7] (5.3.0 unversioned [amd64]) [] +Inst libdb5.3-dev (5.3.28-3 unversioned [amd64]) +Conf libdb5.3-dev (5.3.28-3 unversioned [amd64]) +Conf libdb-dev (5.3.0 unversioned [amd64])' aptget dist-upgrade -st unversioned testequal 'Reading package lists... Building dependency tree... The following packages will be REMOVED: @@ -31,17 +61,84 @@ The following packages will be upgraded: libdb-dev 1 upgraded, 1 newly installed, 1 to remove and 0 not upgraded. Remv libdb5.1-dev [5.1.29-7] [libdb-dev:amd64 ] -Inst libdb-dev [5.1.7] (5.3.0 unstable [amd64]) [] -Inst libdb5.3-dev (5.3.28-3 unstable [amd64]) -Conf libdb5.3-dev (5.3.28-3 unstable [amd64]) -Conf libdb-dev (5.3.0 unstable [amd64])' aptget dist-upgrade -s +Inst libdb-dev [5.1.7] (5.3.0 versioned [amd64]) [] +Inst libdb5.3-dev (5.3.28-3 versioned [amd64]) +Conf libdb5.3-dev (5.3.28-3 versioned [amd64]) +Conf libdb-dev (5.3.0 versioned [amd64])' aptget dist-upgrade -st versioned -rm rootdir/var/lib/dpkg/status +cp -f rootdir/var/lib/dpkg/status-backup rootdir/var/lib/dpkg/status insertinstalledpackage 'foo' 'amd64' '1' insertinstalledpackage 'bar' 'amd64' '1' - testequal 'Reading package lists... Building dependency tree... The following packages have been kept back: bar foo -0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.' aptget dist-upgrade -s +0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.' aptget dist-upgrade -st unversioned +testequal 'Reading package lists... +Building dependency tree... +The following packages have been kept back: + bar foo +0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.' aptget dist-upgrade -st versioned +testequal 'Reading package lists... +Building dependency tree... +The following packages have been kept back: + bar foo +0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.' aptget dist-upgrade -st multipleno +testequal 'Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + foo +The following packages will be upgraded: + bar +1 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv foo [1] +Inst bar [1] (2.2 multipleyes [amd64]) +Conf bar (2.2 multipleyes [amd64])' aptget dist-upgrade -st multipleyes + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + baz +0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. +Inst baz (2 unversioned [amd64]) +Conf baz (2 unversioned [amd64])' aptget install baz -st unversioned +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo +The following packages will be REMOVED: + bar +The following NEW packages will be installed: + baz +The following packages will be upgraded: + foo +1 upgraded, 1 newly installed, 1 to remove and 0 not upgraded. +Remv bar [1] +Inst foo [1] (2 versioned [amd64]) +Inst baz (2 versioned [amd64]) +Conf foo (2 versioned [amd64]) +Conf baz (2 versioned [amd64])' aptget install baz -st versioned + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + baz +0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. +Inst baz (2 unversioned [amd64]) +Conf baz (2 unversioned [amd64])' aptget install baz -st unversioned +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo +The following packages will be REMOVED: + bar +The following NEW packages will be installed: + baz +The following packages will be upgraded: + foo +1 upgraded, 1 newly installed, 1 to remove and 0 not upgraded. +Remv bar [1] +Inst foo [1] (2 versioned [amd64]) +Inst baz (2 versioned [amd64]) +Conf foo (2 versioned [amd64]) +Conf baz (2 versioned [amd64])' aptget install baz -st versioned -- cgit v1.2.3 From a5414e56403537678d5be87acf59c37a05f55719 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 24 Feb 2014 23:10:25 +0100 Subject: add default and override handling for Cnf::FindVector Automatically handle the override of list options via its parent value which can even be a comma-separated list of values. It also adds an easy way of providing a default for the list. --- test/libapt/configuration_test.cc | 34 +++++++++++++++++++++++++++++++--- test/libapt/getlanguages_test.cc | 8 ++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index 2c974ee0a..957e905d5 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -98,9 +98,37 @@ int main(int argc,const char *argv[]) { equals(Cnf.FindDir("Dir::State"), "/rootdir/dev/null"); equals(Cnf.FindDir("Dir::State::lists"), "/rootdir/dev/null"); - Cnf.Set("Moo::Bar", "1"); - Cnf.Clear(); - equals(Cnf.Find("Moo::Bar"), ""); + Cnf.Set("Moo::Bar", "1"); + Cnf.Clear(); + equals(Cnf.Find("Moo::Bar"), ""); + + std::vector vec = Cnf.FindVector("Test::Vector", ""); + equals(vec.size(), 0); + vec = Cnf.FindVector("Test::Vector", "foo"); + equals(vec.size(), 1); + equals(vec[0], "foo"); + vec = Cnf.FindVector("Test::Vector", "foo,bar"); + equals(vec.size(), 2); + equals(vec[0], "foo"); + equals(vec[1], "bar"); + Cnf.Set("Test::Vector::", "baz"); + Cnf.Set("Test::Vector::", "bob"); + Cnf.Set("Test::Vector::", "dob"); + vec = Cnf.FindVector("Test::Vector"); + equals(vec.size(), 3); + equals(vec[0], "baz"); + equals(vec[1], "bob"); + equals(vec[2], "dob"); + vec = Cnf.FindVector("Test::Vector", "foo,bar"); + equals(vec.size(), 3); + equals(vec[0], "baz"); + equals(vec[1], "bob"); + equals(vec[2], "dob"); + Cnf.Set("Test::Vector", "abel,bravo"); + vec = Cnf.FindVector("Test::Vector", "foo,bar"); + equals(vec.size(), 2); + equals(vec[0], "abel"); + equals(vec[1], "bravo"); //FIXME: Test for configuration file parsing; // currently only integration/ tests test them implicitly diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index cef89bde6..51cfecee3 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -105,6 +105,14 @@ int main(int argc,char *argv[]) vec = APT::Configuration::getLanguages(false, false, env); equals(vec.size(), 1); equals(vec[0], "fr"); + + _config->Set("Acquire::Languages", "environment,en"); + env[0] = "de_DE.UTF-8"; + vec = APT::Configuration::getLanguages(false, false, env); + equals(vec.size(), 3); + equals(vec[0], "de_DE"); + equals(vec[1], "de"); + equals(vec[2], "en"); _config->Set("Acquire::Languages", ""); _config->Set("Acquire::Languages::1", "environment"); -- cgit v1.2.3 From 565ded7b65240b25ad8551789ac388c8ce72b1f4 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Date: Tue, 25 Feb 2014 00:12:20 +0100 Subject: implement BuildProfileSpec support as dpkg has in 1.17.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build-dependencies are now able to include a specification limiting usage similar to already supported [arch …]. More details: https://wiki.debian.org/BuildProfileSpec Closes: 661537 --- test/libapt/parsedepends_test.cc | 88 ++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 27 deletions(-) (limited to 'test') diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index e95016240..67dbab823 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -10,7 +10,9 @@ int main(int argc,char *argv[]) { unsigned int Null = 0; bool StripMultiArch = true; bool ParseArchFlags = false; + bool ParseRestrictionsList = false; _config->Set("APT::Architecture","amd64"); + _config->Set("APT::Build-Profiles","stage1"); const char* Depends = "debhelper:any (>= 5.0), " @@ -27,6 +29,9 @@ int main(int argc,char *argv[]) { "os-for-me [ linux-any ], " "cpu-not-for-me [ any-armel ], " "os-not-for-me [ kfreebsd-any ], " + "not-in-stage1 , " + "not-in-stage1-or-nodoc , " + "only-in-stage1 , " "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), " ; @@ -39,7 +44,7 @@ test: const char* Start = Depends; const char* End = Depends + strlen(Depends); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); if (StripMultiArch == true) equals("debhelper", Package); else @@ -47,7 +52,7 @@ test: equals("5.0", Version); equals(Null | pkgCache::Dep::GreaterEq, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); if (StripMultiArch == true) equals("libdb-dev", Package); else @@ -55,7 +60,7 @@ test: equals("", Version); equals(Null | pkgCache::Dep::NoOp, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); if (StripMultiArch == true) equals("gettext", Package); else @@ -63,7 +68,7 @@ test: equals("0.12", Version); equals(Null | pkgCache::Dep::LessEq, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); if (StripMultiArch == true) equals("libcurl4-gnutls-dev", Package); else @@ -71,104 +76,131 @@ test: equals("", Version); equals(Null | pkgCache::Dep::Or, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("libcurl3-gnutls-dev", Package); equals("7.15.5", Version); equals(Null | pkgCache::Dep::Greater, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("debiandoc-sgml", Package); equals("", Version); equals(Null | pkgCache::Dep::NoOp, Op); - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("apt", Package); equals("0.7.25", Version); equals(Null | pkgCache::Dep::GreaterEq, Op); if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("", Package); // not-for-me } else { - equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("only-for-me", Package); equals("", Version); equals(Null | pkgCache::Dep::NoOp, Op); } else { - equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("any-for-me", Package); equals("", Version); equals(Null | pkgCache::Dep::NoOp, Op); } else { - equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("not-for-darwin", Package); equals("", Version); equals(Null | pkgCache::Dep::NoOp, Op); } else { - equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("cpu-for-me", Package); equals("", Version); equals(Null | pkgCache::Dep::NoOp, Op); } else { - equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("os-for-me", Package); equals("", Version); equals(Null | pkgCache::Dep::NoOp, Op); } else { - equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("", Package); // cpu-not-for-me } else { - equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); Start = strstr(Start, ","); Start++; } if (ParseArchFlags == true) { - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); equals("", Package); // os-not-for-me } else { - equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); Start = strstr(Start, ","); Start++; } - Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + if (ParseRestrictionsList == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + equals("", Package); // not-in-stage1 + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseRestrictionsList == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + equals("", Package); // not-in-stage1-or-in-nodoc + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseRestrictionsList == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); + equals("only-in-stage1", Package); + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList)); + Start = strstr(Start, ","); + Start++; + } + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); if (StripMultiArch == true) equals("overlord-dev", Package); else @@ -176,7 +208,7 @@ test: equals("7.15.3~", Version); equals(Null | pkgCache::Dep::Equals | pkgCache::Dep::Or, Op); - debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); if (StripMultiArch == true) equals("overlord-dev", Package); else @@ -185,11 +217,13 @@ test: equals(Null | pkgCache::Dep::Greater, Op); if (StripMultiArch == false) - ParseArchFlags = true; + if (ParseArchFlags == false) + ParseRestrictionsList = !ParseRestrictionsList; + ParseArchFlags = !ParseArchFlags; StripMultiArch = !StripMultiArch; runner++; - if (runner < 4) + if (runner < 8) goto test; // this is the prove: tests are really evil ;) return 0; -- cgit v1.2.3 From ce7f128c020e1347f91c6074238fc5da58c5df71 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 25 Feb 2014 14:26:18 +0100 Subject: support DEB_BUILD_PROFILES and -P for build profiles Inspired by the rest of the patch in 661537, but abstract the parsing of various ways of setting the build profiles more so it can potentially be reused and all apt parts have the same behaviour. Especially config options, cmdline options and environment will not be combined as proposed as this isn't APTs usual behaviour and dpkg doesn't do it either, so one overrides the other as it normally does. --- test/integration/framework | 6 + .../test-bug-661537-build-profiles-support | 147 +++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100755 test/integration/test-bug-661537-build-profiles-support (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 911a4d742..9c4ac87d3 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -120,6 +120,9 @@ aptwebserver() { dpkg() { command dpkg --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log "$@" } +dpkgcheckbuilddeps() { + command dpkg-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg "$@" +} aptitude() { if [ -f ./aptconfig.conf ]; then APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} command aptitude "$@" @@ -240,6 +243,9 @@ setupenvironment() { # newer gpg versions are fine without it, but play it safe for now gpg --quiet --check-trustdb --secret-keyring $SECRETKEYRING --keyring $SECRETKEYRING >/dev/null 2>&1 + # cleanup the environment a bit + unset GREP_OPTIONS DEB_BUILD_PROFILES + msgdone "info" } diff --git a/test/integration/test-bug-661537-build-profiles-support b/test/integration/test-bug-661537-build-profiles-support new file mode 100755 index 000000000..ae1403f71 --- /dev/null +++ b/test/integration/test-bug-661537-build-profiles-support @@ -0,0 +1,147 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'i386' 'armel' + +insertinstalledpackage 'build-essential' 'all' '0' 'Multi-Arch: foreign' + +insertpackage 'unstable' 'foo' 'all' '1.0' +insertpackage 'unstable' 'bar' 'all' '1.0' + +insertsource 'unstable' 'buildprofiles' 'any' '1' 'Build-Depends: foo (>= 1.0) [i386 arm] , bar' + +# table from https://wiki.debian.org/BuildProfileSpec +insertsource 'unstable' 'spec-1' 'any' '1' 'Build-Depends: foo ' +insertsource 'unstable' 'spec-2' 'any' '1' 'Build-Depends: foo ' +insertsource 'unstable' 'spec-3' 'any' '1' 'Build-Depends: foo ' +insertsource 'unstable' 'spec-4' 'any' '1' 'Build-Depends: foo ' +insertsource 'unstable' 'spec-5' 'any' '1' 'Build-Depends: foo ' +insertsource 'unstable' 'spec-6' 'any' '1' 'Build-Depends: foo ' +# multiple stanzas not supported: error out +insertsource 'unstable' 'spec-7' 'any' '1' 'Build-Depends: foo ' +insertsource 'unstable' 'spec-8' 'any' '1' 'Build-Depends: foo ' + +setupaptarchive + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + bar +0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Inst bar (1.0 unstable [all]) +Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + bar foo +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst bar (1.0 unstable [all]) +Inst foo (1.0 unstable [all]) +Conf bar (1.0 unstable [all]) +Conf foo (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386 + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + bar +0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Inst bar (1.0 unstable [all]) +Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=armel + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + bar +0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Inst bar (1.0 unstable [all]) +Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386 -P stage1 + +KEEP='Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + foo +0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Inst foo (1.0 unstable [all]) +Conf foo (1.0 unstable [all])' +DROP='Reading package lists... +Building dependency tree... +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' + +msgtest 'Check if version of installed dpkg is high enough for' 'build profiles support' +if dpkg --compare-versions "$(command dpkg-query --showformat='${Version}' --show dpkg)" 'ge' '1.17.2'; then + msgpass + testwithdpkg() { + msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'" + local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwithdpkg.output" + if dpkgcheckbuilddeps -d "$1" -P "$2" /dev/null >$OUTPUT 2>&1; then + if [ "$3" = "$DROP" ]; then + msgpass + else + cat $OUTPUT + msgfail + fi + else + if [ "$3" = "$KEEP" ]; then + msgpass + else + cat $OUTPUT + msgfail + fi + fi + } +else + msgskip + testwithdpkg() { + msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'" + msgskip + } +fi + +testprofile() { + if [ -n "$3" ]; then + testequal "$4" aptget build-dep "$1" -s -P "$3" + export DEB_BUILD_PROFILES="$(echo "$3" | tr ',' ' ')" + testequal "$4" aptget build-dep "$1" -s -o with::environment=1 + unset DEB_BUILD_PROFILES + else + testequal "$4" aptget build-dep "$1" -s + fi + testwithdpkg "$2" "$3" "$4" +} + +testprofile 'spec-1' 'foo ' '' "$KEEP" +testprofile 'spec-1' 'foo ' 'stage1' "$DROP" +testprofile 'spec-1' 'foo ' 'notest' "$KEEP" +testprofile 'spec-1' 'foo ' 'stage1,notest' "$DROP" + +testprofile 'spec-2' 'foo ' '' "$DROP" +testprofile 'spec-2' 'foo ' 'stage1' "$KEEP" +testprofile 'spec-2' 'foo ' 'notest' "$DROP" +testprofile 'spec-2' 'foo ' 'stage1,notest' "$KEEP" + +testprofile 'spec-3' 'foo ' '' "$KEEP" +testprofile 'spec-3' 'foo ' 'stage1' "$DROP" +testprofile 'spec-3' 'foo ' 'notest' "$DROP" +testprofile 'spec-3' 'foo ' 'stage1,notest' "$DROP" + +testprofile 'spec-4' 'foo ' '' "$DROP" +testprofile 'spec-4' 'foo ' 'stage1' "$KEEP" +testprofile 'spec-4' 'foo ' 'notest' "$KEEP" +testprofile 'spec-4' 'foo ' 'stage1,notest' "$KEEP" + +testprofile 'spec-5' 'foo ' '' "$KEEP" +testprofile 'spec-5' 'foo ' 'stage1' "$DROP" +testprofile 'spec-5' 'foo ' 'notest' "$KEEP" +testprofile 'spec-5' 'foo ' 'stage1,notest' "$DROP" + +testprofile 'spec-6' 'foo ' '' "$KEEP" +testprofile 'spec-6' 'foo ' 'stage1' "$KEEP" +testprofile 'spec-6' 'foo ' 'notest' "$DROP" +testprofile 'spec-6' 'foo ' 'stage1,notest' "$KEEP" + +testfailure aptget build-dep spec-7 -s +testfailure aptget build-dep spec-8 -s -- cgit v1.2.3 From be2337962df21addb8386f4262bde0ed0fbcad86 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 25 Feb 2014 17:21:44 +0100 Subject: unset LANGUAGE in the testing framework directly Git-Dch: Ignore --- test/integration/framework | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 9c4ac87d3..83deafe88 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -226,8 +226,6 @@ setupenvironment() { echo 'quiet::NoUpdate "true";' >> aptconfig.conf echo "Acquire::https::CaInfo \"${TESTDIR}/apt.pem\";" > rootdir/etc/apt/apt.conf.d/99https echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary - export LC_ALL=C.UTF-8 - export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin" configcompression '.' 'gz' #'bz2' 'lzma' 'xz' # gpg needs a trustdb to function, but it can't be invalid (not even empty) @@ -244,6 +242,9 @@ setupenvironment() { gpg --quiet --check-trustdb --secret-keyring $SECRETKEYRING --keyring $SECRETKEYRING >/dev/null 2>&1 # cleanup the environment a bit + export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin" + export LC_ALL=C.UTF-8 + unset LANGUAGE unset GREP_OPTIONS DEB_BUILD_PROFILES msgdone "info" -- cgit v1.2.3 From c3ccac9232c2684b15f75fa8622a9a290aeca123 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 03:11:54 +0100 Subject: warning: no previous declaration for foobar() [-Wmissing-declarations] Git-Dch: Ignore Reported-By: gcc -Wmissing-declarations --- test/interactive-helper/aptwebserver.cc | 30 +++++++++++++++--------------- test/interactive-helper/extract-control.cc | 2 +- test/interactive-helper/testdeb.cc | 2 +- test/libapt/assert.h | 9 +++++++++ test/libapt/compareversion_test.cc | 6 +++--- test/libapt/sourcelist_test.cc | 2 +- test/libapt/tagfile_test.cc | 2 +- 7 files changed, 31 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index 992f802a6..7ed984fa9 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -23,7 +23,7 @@ #include #include -char const * const httpcodeToStr(int const httpcode) /*{{{*/ +static char const * const httpcodeToStr(int const httpcode) /*{{{*/ { switch (httpcode) { @@ -77,7 +77,7 @@ char const * const httpcodeToStr(int const httpcode) /*{{{*/ return NULL; } /*}}}*/ -void addFileHeaders(std::list &headers, FileFd &data) /*{{{*/ +static void addFileHeaders(std::list &headers, FileFd &data)/*{{{*/ { std::ostringstream contentlength; contentlength << "Content-Length: " << data.FileSize(); @@ -88,14 +88,14 @@ void addFileHeaders(std::list &headers, FileFd &data) /*{{{*/ headers.push_back(lastmodified); } /*}}}*/ -void addDataHeaders(std::list &headers, std::string &data) /*{{{*/ +static void addDataHeaders(std::list &headers, std::string &data)/*{{{*/ { std::ostringstream contentlength; contentlength << "Content-Length: " << data.size(); headers.push_back(contentlength.str()); } /*}}}*/ -bool sendHead(int const client, int const httpcode, std::list &headers)/*{{{*/ +static bool sendHead(int const client, int const httpcode, std::list &headers)/*{{{*/ { std::string response("HTTP/1.1 "); response.append(httpcodeToStr(httpcode)); @@ -128,7 +128,7 @@ bool sendHead(int const client, int const httpcode, std::list &head return Success; } /*}}}*/ -bool sendFile(int const client, FileFd &data) /*{{{*/ +static bool sendFile(int const client, FileFd &data) /*{{{*/ { bool Success = true; char buffer[500]; @@ -144,7 +144,7 @@ bool sendFile(int const client, FileFd &data) /*{{{*/ return Success; } /*}}}*/ -bool sendData(int const client, std::string const &data) /*{{{*/ +static bool sendData(int const client, std::string const &data) /*{{{*/ { if (FileFd::Write(client, data.c_str(), data.size()) == false) { @@ -154,7 +154,7 @@ bool sendData(int const client, std::string const &data) /*{{{*/ return true; } /*}}}*/ -void sendError(int const client, int const httpcode, std::string const &request,/*{{{*/ +static void sendError(int const client, int const httpcode, std::string const &request,/*{{{*/ bool content, std::string const &error = "") { std::list headers; @@ -179,13 +179,13 @@ void sendError(int const client, int const httpcode, std::string const &request, if (content == true) sendData(client, response); } -void sendSuccess(int const client, std::string const &request, +static void sendSuccess(int const client, std::string const &request, bool content, std::string const &error = "") { sendError(client, 200, request, content, error); } /*}}}*/ -void sendRedirect(int const client, int const httpcode, std::string const &uri,/*{{{*/ +static void sendRedirect(int const client, int const httpcode, std::string const &uri,/*{{{*/ std::string const &request, bool content) { std::list headers; @@ -222,7 +222,7 @@ void sendRedirect(int const client, int const httpcode, std::string const &uri,/ sendData(client, response); } /*}}}*/ -int filter_hidden_files(const struct dirent *a) /*{{{*/ +static int filter_hidden_files(const struct dirent *a) /*{{{*/ { if (a->d_name[0] == '.') return 0; @@ -236,7 +236,7 @@ int filter_hidden_files(const struct dirent *a) /*{{{*/ #endif return 1; } -int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) { +static int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) { #ifdef _DIRENT_HAVE_D_TYPE if ((*a)->d_type == DT_DIR && (*b)->d_type == DT_DIR); else if ((*a)->d_type == DT_DIR && (*b)->d_type == DT_REG) @@ -260,7 +260,7 @@ int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) { return strcasecmp((*a)->d_name, (*b)->d_name); } /*}}}*/ -void sendDirectoryListing(int const client, std::string const &dir, /*{{{*/ +static void sendDirectoryListing(int const client, std::string const &dir,/*{{{*/ std::string const &request, bool content) { std::list headers; @@ -312,7 +312,7 @@ void sendDirectoryListing(int const client, std::string const &dir, /*{{{*/ sendData(client, response); } /*}}}*/ -bool parseFirstLine(int const client, std::string const &request, /*{{{*/ +static bool parseFirstLine(int const client, std::string const &request,/*{{{*/ std::string &filename, std::string ¶ms, bool &sendContent, bool &closeConnection) { @@ -432,7 +432,7 @@ bool parseFirstLine(int const client, std::string const &request, /*{{{*/ return true; } /*}}}*/ -bool handleOnTheFlyReconfiguration(int const client, std::string const &request, std::vector const &parts)/*{{{*/ +static bool handleOnTheFlyReconfiguration(int const client, std::string const &request, std::vector const &parts)/*{{{*/ { size_t const pcount = parts.size(); if (pcount == 4 && parts[1] == "set") @@ -475,7 +475,7 @@ bool handleOnTheFlyReconfiguration(int const client, std::string const &request, return false; } /*}}}*/ -void * handleClient(void * voidclient) /*{{{*/ +static void * handleClient(void * voidclient) /*{{{*/ { int client = *((int*)(voidclient)); std::clog << "ACCEPT client " << client << std::endl; diff --git a/test/interactive-helper/extract-control.cc b/test/interactive-helper/extract-control.cc index 3f7feabcb..94fe9dca8 100644 --- a/test/interactive-helper/extract-control.cc +++ b/test/interactive-helper/extract-control.cc @@ -7,7 +7,7 @@ using namespace std; -bool ExtractMember(const char *File,const char *Member) +static bool ExtractMember(const char *File,const char *Member) { FileFd Fd(File,FileFd::ReadOnly); debDebFile Deb(Fd); diff --git a/test/interactive-helper/testdeb.cc b/test/interactive-helper/testdeb.cc index d28f20114..89375af13 100644 --- a/test/interactive-helper/testdeb.cc +++ b/test/interactive-helper/testdeb.cc @@ -9,7 +9,7 @@ class NullStream : public pkgDirStream virtual bool DoItem(Item &Itm,int &Fd) {return true;}; }; -bool Test(const char *File) +static bool Test(const char *File) { FileFd Fd(File,FileFd::ReadOnly); debDebFile Deb(Fd); diff --git a/test/libapt/assert.h b/test/libapt/assert.h index 113c057ed..cde6a6351 100644 --- a/test/libapt/assert.h +++ b/test/libapt/assert.h @@ -1,6 +1,11 @@ #include #include +#if __GNUC__ >= 4 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wmissing-declarations" +#endif + #define equals(x,y) assertEquals(y, x, __LINE__) #define equalsNot(x,y) assertEqualsNot(y, x, __LINE__) @@ -111,3 +116,7 @@ void dumpVector(X vec) { v != vec.end(); ++v) std::cout << *v << std::endl; } + +#if __GNUC__ >= 4 + #pragma GCC diagnostic pop +#endif diff --git a/test/libapt/compareversion_test.cc b/test/libapt/compareversion_test.cc index fdb1d5674..44f8e9d78 100644 --- a/test/libapt/compareversion_test.cc +++ b/test/libapt/compareversion_test.cc @@ -31,7 +31,7 @@ using namespace std; -bool callDPkg(const char *val, const char *ref, const char &op) { +static bool callDPkg(const char *val, const char *ref, const char &op) { pid_t Process = ExecFork(); if (Process == 0) { @@ -50,7 +50,7 @@ bool callDPkg(const char *val, const char *ref, const char &op) { return WIFEXITED(Ret) == true && WEXITSTATUS(Ret) == 0; } -void assertVersion(int const &CurLine, string const &A, string const &B, int const &Expected) { +static void assertVersion(int const &CurLine, string const &A, string const &B, int const &Expected) { int Res = debVS.CmpVersion(A.c_str(), B.c_str()); bool const dpkg = callDPkg(A.c_str(),B.c_str(), Expected); Res = (Res < 0) ? -1 : ( (Res > 0) ? 1 : Res); @@ -61,7 +61,7 @@ void assertVersion(int const &CurLine, string const &A, string const &B, int con _error->Error("DPkg differ with line: %u. '%s' '%s' '%s' == false",CurLine,A.c_str(),((Expected == 1) ? "<<" : ( (Expected == 0) ? "=" : ">>")),B.c_str()); } -bool RunTest(const char *File) +static bool RunTest(const char *File) { if (FileExists(File) == false) return _error->Error("Versiontestfile %s doesn't exist!", File); diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 0300ce929..e79b6d65e 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -9,7 +9,7 @@ char *tempfile = NULL; int tempfile_fd = -1; -void remove_tmpfile(void) +static void remove_tmpfile(void) { if (tempfile_fd > 0) close(tempfile_fd); diff --git a/test/libapt/tagfile_test.cc b/test/libapt/tagfile_test.cc index d12c74c95..effc3244b 100644 --- a/test/libapt/tagfile_test.cc +++ b/test/libapt/tagfile_test.cc @@ -9,7 +9,7 @@ char *tempfile = NULL; int tempfile_fd = -1; -void remove_tmpfile(void) +static void remove_tmpfile(void) { if (tempfile_fd > 0) close(tempfile_fd); -- cgit v1.2.3 From d64e130aa333837a8fda0f1bba51f2867ca520f7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 13:55:20 +0100 Subject: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] Reported-By: gcc -Wignored-qualifiers Git-Dch: Ignore --- test/interactive-helper/aptwebserver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index 7ed984fa9..fb9f7d34e 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -23,7 +23,7 @@ #include #include -static char const * const httpcodeToStr(int const httpcode) /*{{{*/ +static char const * httpcodeToStr(int const httpcode) /*{{{*/ { switch (httpcode) { -- cgit v1.2.3 From 655122418d714f342b5d9789f45f8035f3fe8b9a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 15:11:42 +0100 Subject: =?UTF-8?q?warning:=20unused=20parameter=20=E2=80=98foo=E2=80=99?= =?UTF-8?q?=20[-Wunused-parameter]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-By: gcc -Wunused-parameter Git-Dch: Ignore --- test/interactive-helper/testdeb.cc | 7 ++++++- test/libapt/cdromreducesourcelist_test.cc | 2 +- test/libapt/configuration_test.cc | 2 +- test/libapt/fileutl_test.cc | 2 +- test/libapt/getarchitectures_test.cc | 2 +- test/libapt/globalerror_test.cc | 2 +- test/libapt/hashsums_test.cc | 5 +++++ test/libapt/parsedepends_test.cc | 2 +- test/libapt/sourcelist_test.cc | 2 +- test/libapt/strutil_test.cc | 2 +- test/libapt/tagfile_test.cc | 2 +- 11 files changed, 20 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/interactive-helper/testdeb.cc b/test/interactive-helper/testdeb.cc index 89375af13..9520d1b50 100644 --- a/test/interactive-helper/testdeb.cc +++ b/test/interactive-helper/testdeb.cc @@ -6,7 +6,7 @@ class NullStream : public pkgDirStream { public: - virtual bool DoItem(Item &Itm,int &Fd) {return true;}; + virtual bool DoItem(Item &/*Itm*/, int &/*Fd*/) {return true;}; }; static bool Test(const char *File) @@ -33,6 +33,11 @@ static bool Test(const char *File) int main(int argc, const char *argv[]) { + if (argc != 2) { + std::cout << "One parameter expected - given " << argc << std::endl; + return 100; + } + Test(argv[1]); _error->DumpErrors(); return 0; diff --git a/test/libapt/cdromreducesourcelist_test.cc b/test/libapt/cdromreducesourcelist_test.cc index 729da23a6..b0314769d 100644 --- a/test/libapt/cdromreducesourcelist_test.cc +++ b/test/libapt/cdromreducesourcelist_test.cc @@ -15,7 +15,7 @@ public: } }; -int main(int argc, char const *argv[]) { +int main() { Cdrom cd; std::vector List; std::string CD("/media/cdrom/"); diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index 957e905d5..d2efc1b4b 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -5,7 +5,7 @@ #include "assert.h" -int main(int argc,const char *argv[]) { +int main() { Configuration Cnf; std::vector fds; diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc index 462bdefd9..d256ea55a 100644 --- a/test/libapt/fileutl_test.cc +++ b/test/libapt/fileutl_test.cc @@ -10,7 +10,7 @@ #include -int main(int argc,char *argv[]) +int main() { std::vector files; diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc index 807469263..508d5e458 100644 --- a/test/libapt/getarchitectures_test.cc +++ b/test/libapt/getarchitectures_test.cc @@ -7,7 +7,7 @@ #include -int main(int argc,char *argv[]) +int main() { std::vector vec; diff --git a/test/libapt/globalerror_test.cc b/test/libapt/globalerror_test.cc index b6939231d..742fa53bd 100644 --- a/test/libapt/globalerror_test.cc +++ b/test/libapt/globalerror_test.cc @@ -5,7 +5,7 @@ #include #include -int main(int argc,char *argv[]) +int main() { std::string const textOfErrnoZero(strerror(0)); diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc index 3da89052b..410e2c44d 100644 --- a/test/libapt/hashsums_test.cc +++ b/test/libapt/hashsums_test.cc @@ -43,6 +43,11 @@ template void TestMill(const char *Out) int main(int argc, char** argv) { + if (argc != 6) { + std::cout << "Five parameter expected - given " << argc << std::endl; + return 100; + } + // test HashSumValue which doesn't calculate but just stores sums { string md5sum = argv[2]; diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index 67dbab823..5a2c65573 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -3,7 +3,7 @@ #include "assert.h" -int main(int argc,char *argv[]) { +int main() { std::string Package; std::string Version; unsigned int Op = 5; diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index e79b6d65e..0637df03b 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -19,7 +19,7 @@ static void remove_tmpfile(void) } } -int main(int argc, char *argv[]) +int main() { _config->Set("APT::Sources::Use-Deb822", true); diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc index 8215654d0..a4516e7a1 100644 --- a/test/libapt/strutil_test.cc +++ b/test/libapt/strutil_test.cc @@ -2,7 +2,7 @@ #include "assert.h" -int main(int argc,char *argv[]) +int main() { std::string input, output, expected; diff --git a/test/libapt/tagfile_test.cc b/test/libapt/tagfile_test.cc index effc3244b..24f258275 100644 --- a/test/libapt/tagfile_test.cc +++ b/test/libapt/tagfile_test.cc @@ -19,7 +19,7 @@ static void remove_tmpfile(void) } } -int main(int argc, char *argv[]) +int main() { FileFd fd; const char contents[] = "FieldA-12345678: the value of the field"; -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- test/interactive-helper/aptwebserver.cc | 34 ++++++++++++++++-------------- test/interactive-helper/extract-control.cc | 3 +++ test/interactive-helper/mthdcat.cc | 2 ++ test/interactive-helper/rpmver.cc | 2 ++ test/interactive-helper/test_udevcdrom.cc | 8 ++++--- test/interactive-helper/testdeb.cc | 7 ++++++ test/libapt/cdromfindpackages_test.cc | 4 ++++ test/libapt/cdromreducesourcelist_test.cc | 4 ++-- test/libapt/commandline_test.cc | 3 +++ test/libapt/commandlineasstring_test.cc | 2 ++ test/libapt/compareversion_test.cc | 9 ++++---- test/libapt/configuration_test.cc | 2 ++ test/libapt/fileutl_test.cc | 7 +++--- test/libapt/getarchitectures_test.cc | 5 +++-- test/libapt/getlanguages_test.cc | 2 ++ test/libapt/getlistoffilesindir_test.cc | 7 +++--- test/libapt/globalerror_test.cc | 6 +++++- test/libapt/hashsums_test.cc | 15 +++++++------ test/libapt/indexcopytosourcelist_test.cc | 9 +++++--- test/libapt/parsedepends_test.cc | 6 ++++++ test/libapt/sourcelist_test.cc | 9 ++++++-- test/libapt/strutil_test.cc | 7 +++++- test/libapt/tagfile_test.cc | 6 +++++- test/libapt/uri_test.cc | 4 ++++ 24 files changed, 114 insertions(+), 49 deletions(-) (limited to 'test') diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index fb9f7d34e..34476e1af 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -1,27 +1,29 @@ #include -#include -#include -#include #include #include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include #include -#include -#include -#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include static char const * httpcodeToStr(int const httpcode) /*{{{*/ { diff --git a/test/interactive-helper/extract-control.cc b/test/interactive-helper/extract-control.cc index 94fe9dca8..852ec4ee9 100644 --- a/test/interactive-helper/extract-control.cc +++ b/test/interactive-helper/extract-control.cc @@ -1,7 +1,10 @@ +#include + #include #include #include +#include #include #include diff --git a/test/interactive-helper/mthdcat.cc b/test/interactive-helper/mthdcat.cc index 25d09a3f5..2961b2080 100644 --- a/test/interactive-helper/mthdcat.cc +++ b/test/interactive-helper/mthdcat.cc @@ -2,6 +2,8 @@ All this does is cat a file into the method without closing the FD when the file ends */ +#include + #include int main() diff --git a/test/interactive-helper/rpmver.cc b/test/interactive-helper/rpmver.cc index 15c96cbbe..017c92fba 100644 --- a/test/interactive-helper/rpmver.cc +++ b/test/interactive-helper/rpmver.cc @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/test/interactive-helper/test_udevcdrom.cc b/test/interactive-helper/test_udevcdrom.cc index 88f5f0153..b87dcd935 100644 --- a/test/interactive-helper/test_udevcdrom.cc +++ b/test/interactive-helper/test_udevcdrom.cc @@ -1,7 +1,10 @@ +#include + #include -#include -#include +#include +#include +#include #include #include @@ -17,5 +20,4 @@ int main() std::cerr << l[i].DeviceName << " " << l[i].Mounted << " " << l[i].MountPath << std::endl; - } diff --git a/test/interactive-helper/testdeb.cc b/test/interactive-helper/testdeb.cc index 9520d1b50..6aae9f563 100644 --- a/test/interactive-helper/testdeb.cc +++ b/test/interactive-helper/testdeb.cc @@ -1,7 +1,14 @@ +#include + #include #include #include #include +#include +#include + +#include +#include class NullStream : public pkgDirStream { diff --git a/test/libapt/cdromfindpackages_test.cc b/test/libapt/cdromfindpackages_test.cc index e9f5a51b0..583de1423 100644 --- a/test/libapt/cdromfindpackages_test.cc +++ b/test/libapt/cdromfindpackages_test.cc @@ -1,9 +1,13 @@ +#include + #include #include #include #include #include +#include +#include #include "assert.h" diff --git a/test/libapt/cdromreducesourcelist_test.cc b/test/libapt/cdromreducesourcelist_test.cc index b0314769d..196d0136e 100644 --- a/test/libapt/cdromreducesourcelist_test.cc +++ b/test/libapt/cdromreducesourcelist_test.cc @@ -1,7 +1,7 @@ +#include + #include -#include -#include #include #include diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc index de8a30bd6..d8c5bc5bd 100644 --- a/test/libapt/commandline_test.cc +++ b/test/libapt/commandline_test.cc @@ -1,4 +1,7 @@ +#include + #include +#include #include "assert.h" diff --git a/test/libapt/commandlineasstring_test.cc b/test/libapt/commandlineasstring_test.cc index a38957d7e..5c005e956 100644 --- a/test/libapt/commandlineasstring_test.cc +++ b/test/libapt/commandlineasstring_test.cc @@ -1,3 +1,5 @@ +#include + #include #include diff --git a/test/libapt/compareversion_test.cc b/test/libapt/compareversion_test.cc index 44f8e9d78..43b98f240 100644 --- a/test/libapt/compareversion_test.cc +++ b/test/libapt/compareversion_test.cc @@ -16,17 +16,16 @@ ##################################################################### */ /*}}}*/ -#include +#include + #include -#include #include #include -#include -#include +#include +#include #include #include -#include #include using namespace std; diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index d2efc1b4b..c9235500c 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -1,3 +1,5 @@ +#include + #include #include diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc index d256ea55a..8da832ba9 100644 --- a/test/libapt/fileutl_test.cc +++ b/test/libapt/fileutl_test.cc @@ -1,14 +1,13 @@ +#include + #include #include -#include "assert.h" #include #include - -#include -#include #include +#include "assert.h" int main() { diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc index 508d5e458..f4dfc6ae8 100644 --- a/test/libapt/getarchitectures_test.cc +++ b/test/libapt/getarchitectures_test.cc @@ -1,11 +1,12 @@ +#include + #include #include -#include "assert.h" #include #include -#include +#include "assert.h" int main() { diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index 51cfecee3..15aa4e879 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -1,3 +1,5 @@ +#include + #include #include diff --git a/test/libapt/getlistoffilesindir_test.cc b/test/libapt/getlistoffilesindir_test.cc index b2c95e840..df125fc83 100644 --- a/test/libapt/getlistoffilesindir_test.cc +++ b/test/libapt/getlistoffilesindir_test.cc @@ -1,12 +1,13 @@ +#include + #include -#include "assert.h" #include #include - -#include #include +#include "assert.h" + #define P(x) std::string(argv[1]).append("/").append(x) int main(int argc,char *argv[]) diff --git a/test/libapt/globalerror_test.cc b/test/libapt/globalerror_test.cc index 742fa53bd..e913fdc12 100644 --- a/test/libapt/globalerror_test.cc +++ b/test/libapt/globalerror_test.cc @@ -1,10 +1,14 @@ +#include + #include -#include "assert.h" +#include #include #include #include +#include "assert.h" + int main() { std::string const textOfErrnoZero(strerror(0)); diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc index 410e2c44d..d743faec6 100644 --- a/test/libapt/hashsums_test.cc +++ b/test/libapt/hashsums_test.cc @@ -1,12 +1,15 @@ +#include + #include #include #include #include #include #include -#include -#include +#include +#include +#include #include "assert.h" @@ -50,22 +53,22 @@ int main(int argc, char** argv) // test HashSumValue which doesn't calculate but just stores sums { - string md5sum = argv[2]; + std::string md5sum = argv[2]; MD5SumValue md5(md5sum); equals(md5.Value(), md5sum); } { - string sha1sum = argv[3]; + std::string sha1sum = argv[3]; SHA1SumValue sha1(sha1sum); equals(sha1.Value(), sha1sum); } { - string sha2sum = argv[4]; + std::string sha2sum = argv[4]; SHA256SumValue sha2(sha2sum); equals(sha2.Value(), sha2sum); } { - string sha2sum = argv[5]; + std::string sha2sum = argv[5]; SHA512SumValue sha2(sha2sum); equals(sha2.Value(), sha2sum); } diff --git a/test/libapt/indexcopytosourcelist_test.cc b/test/libapt/indexcopytosourcelist_test.cc index 69d8fae86..e04ab261b 100644 --- a/test/libapt/indexcopytosourcelist_test.cc +++ b/test/libapt/indexcopytosourcelist_test.cc @@ -1,8 +1,11 @@ +#include + #include #include #include #include +#include #include "assert.h" @@ -12,14 +15,14 @@ public: IndexCopy::ConvertToSourceList(CD, Path); return Path; } - bool GetFile(std::string &Filename,unsigned long long &Size) { return false; } - bool RewriteEntry(FILE *Target,std::string File) { return false; } + bool GetFile(std::string &/*Filename*/, unsigned long long &/*Size*/) { return false; } + bool RewriteEntry(FILE * /*Target*/, std::string /*File*/) { return false; } const char *GetFileName() { return NULL; } const char *Type() { return NULL; } }; -int main(int argc, char const *argv[]) { +int main() { NoCopy ic; std::string const CD("/media/cdrom/"); diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index 5a2c65573..5564e2bc0 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -1,5 +1,11 @@ +#include + #include #include +#include + +#include +#include #include "assert.h" diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 0637df03b..71aa54f1e 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -1,11 +1,16 @@ +#include + +#include #include -#include +#include -#include "assert.h" +#include #include #include #include +#include "assert.h" + char *tempfile = NULL; int tempfile_fd = -1; diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc index a4516e7a1..618f4daba 100644 --- a/test/libapt/strutil_test.cc +++ b/test/libapt/strutil_test.cc @@ -1,5 +1,10 @@ +#include + #include +#include +#include + #include "assert.h" int main() @@ -44,7 +49,7 @@ int main() // Split input = "status: libnet1:amd64: unpacked"; - vector result = StringSplit(input, ": "); + std::vector result = StringSplit(input, ": "); equals(result[0], "status"); equals(result[1], "libnet1:amd64"); equals(result[2], "unpacked"); diff --git a/test/libapt/tagfile_test.cc b/test/libapt/tagfile_test.cc index 24f258275..aaf46e3e9 100644 --- a/test/libapt/tagfile_test.cc +++ b/test/libapt/tagfile_test.cc @@ -1,11 +1,15 @@ +#include + #include #include -#include "assert.h" +#include #include #include #include +#include "assert.h" + char *tempfile = NULL; int tempfile_fd = -1; diff --git a/test/libapt/uri_test.cc b/test/libapt/uri_test.cc index 8216ade71..6559f1390 100644 --- a/test/libapt/uri_test.cc +++ b/test/libapt/uri_test.cc @@ -1,5 +1,9 @@ +#include + #include +#include + #include "assert.h" int main() { -- cgit v1.2.3 From a02db58fd50ef7fc2f0284852c6b3f98e458a232 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 Mar 2014 00:33:10 +0100 Subject: follow method attribute suggestions by gcc Git-Dch: Ignore Reported-By: gcc -Wsuggest-attribute={pure,const,noreturn} --- test/libapt/assert.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/libapt/assert.h b/test/libapt/assert.h index cde6a6351..357801592 100644 --- a/test/libapt/assert.h +++ b/test/libapt/assert.h @@ -1,6 +1,8 @@ #include #include +#include + #if __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-declarations" @@ -10,7 +12,7 @@ #define equalsNot(x,y) assertEqualsNot(y, x, __LINE__) template < typename X, typename Y > -void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) { +APT_NORETURN void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) { std::cerr << "Test FAILED: »" << expect << "« " << compare << " »" << get << "« at line " << line << std::endl; std::exit(EXIT_FAILURE); } -- cgit v1.2.3 From 0caa5a4c6472d1b74444c4f38ced6c3b89fa50fe Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 8 Mar 2014 17:29:46 +0100 Subject: do not configure already unpacked packages needlessly The unpack of a M-A:same package will force the unpack of all its siblings directly to prevent that they could be separated by later immediate actions. In commit 634985f8 a call to SmartConfigure was introduced to configure these packages at the time the installation order encounters them. Usually, the unpack order is already okay, so that this 'earlier' unpack was not needed and if it wouldn't have been done, the package would now only be unpacked, but by configuring the package now we impose new requirements which must be satisfied. The code is clever enough to handle this most of the time (it worked for 2 years!), but it isn't needed and in very coupled cases this can fail. Removing this call again removes this extra burden and so simplifies the ordering as can be seen in the modified tests. Famous last words, but I don't see a reason for this extra burden to exist hence the remove. Closes: 740843 --- test/integration/framework | 14 ++++-- .../test-bug-740843-versioned-up-down-breaks | 55 ++++++++++++++++++++++ test/integration/test-bug-multiarch-upgrade | 4 +- .../test-ignore-provides-if-versioned-breaks | 4 +- .../test-ignore-provides-if-versioned-conflicts | 4 +- ...prevent-markinstall-multiarch-same-versionscrew | 8 ++-- ...ight-loop-configure-with-unpacking-new-packages | 4 +- 7 files changed, 76 insertions(+), 17 deletions(-) create mode 100755 test/integration/test-bug-740843-versioned-up-down-breaks (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 83deafe88..d66171783 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -1010,11 +1010,15 @@ testequalor2() { shift 2 msgtest "Test for equality OR of" "$*" $* >$COMPAREAGAINST 2>&1 || true - (checkdiff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null || - checkdiff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass || - ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(checkdiff $COMPAREFILE1 $COMPAREAGAINST)" \ - "\n${CINFO}Diff against OR 2${CNORMAL}" "$(checkdiff $COMPAREFILE2 $COMPAREAGAINST)" && - msgfail ) + if checkdiff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null || checkdiff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null; then + msgpass + else + echo -n "\n${CINFO}Diff against OR 1${CNORMAL}" + checkdiff $COMPAREFILE1 $COMPAREAGAINST || true + echo -n "${CINFO}Diff against OR 2${CNORMAL}" + checkdiff $COMPAREFILE2 $COMPAREAGAINST || true + msgfail + fi } testshowvirtual() { diff --git a/test/integration/test-bug-740843-versioned-up-down-breaks b/test/integration/test-bug-740843-versioned-up-down-breaks new file mode 100755 index 000000000..cb035a71f --- /dev/null +++ b/test/integration/test-bug-740843-versioned-up-down-breaks @@ -0,0 +1,55 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'i386' + +insertinstalledpackage 'foo-driver' 'amd64' '1' 'Depends: libfoo (= 1) +Recommends: libgl1-foo-glx (= 1) +Breaks: libgl1-foo-glx (<< 1), libgl1-foo-glx (>> 1)' +insertinstalledpackage 'libgl1-foo-glx' 'amd64,i386' '1' 'Depends: libfoo (= 1) +Multi-Arch: same' +insertinstalledpackage 'libfoo' 'amd64,i386' '1' 'Multi-Arch: same' + +buildsimplenativepackage 'foo-driver' 'amd64' '2' 'stable' 'Depends: libfoo (= 2) +Recommends: libgl1-foo-glx (= 2) +Breaks: libgl1-foo-glx (<< 2), libgl1-foo-glx (>> 2)' +buildsimplenativepackage 'libgl1-foo-glx' 'amd64,i386' '2' 'stable' 'Depends: libfoo (= 2) +Multi-Arch: same' +buildsimplenativepackage 'libfoo' 'amd64,i386' '2' 'stable' 'Multi-Arch: same' + +setupaptarchive + +testequalor2 'Reading package lists... +Building dependency tree... +The following packages will be upgraded: + foo-driver libfoo libfoo:i386 libgl1-foo-glx libgl1-foo-glx:i386 +5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +Inst libgl1-foo-glx [1] (2 stable [amd64]) [libgl1-foo-glx:amd64 on libgl1-foo-glx:i386] [libgl1-foo-glx:i386 on libgl1-foo-glx:amd64] [foo-driver:amd64 on libgl1-foo-glx:amd64] [libgl1-foo-glx:i386 foo-driver:amd64 ] +Inst libgl1-foo-glx:i386 [1] (2 stable [i386]) [foo-driver:amd64 on libgl1-foo-glx:amd64] [foo-driver:amd64 on libgl1-foo-glx:i386] [foo-driver:amd64 ] +Inst foo-driver [1] (2 stable [amd64]) [] +Inst libfoo:i386 [1] (2 stable [i386]) [libfoo:amd64 on libfoo:i386] [libfoo:i386 on libfoo:amd64] [libfoo:amd64 ] +Inst libfoo [1] (2 stable [amd64]) +Conf libfoo:i386 (2 stable [i386]) +Conf libfoo (2 stable [amd64]) +Conf libgl1-foo-glx:i386 (2 stable [i386]) +Conf libgl1-foo-glx (2 stable [amd64]) +Conf foo-driver (2 stable [amd64])' 'Reading package lists... +Building dependency tree... +The following packages will be upgraded: + foo-driver libfoo libfoo:i386 libgl1-foo-glx libgl1-foo-glx:i386 +5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +Inst libgl1-foo-glx [1] (2 stable [amd64]) [foo-driver:amd64 on libgl1-foo-glx:amd64] [libgl1-foo-glx:amd64 on libgl1-foo-glx:i386] [libgl1-foo-glx:i386 on libgl1-foo-glx:amd64] [foo-driver:amd64 libgl1-foo-glx:i386 ] +Inst libgl1-foo-glx:i386 [1] (2 stable [i386]) [foo-driver:amd64 on libgl1-foo-glx:amd64] [foo-driver:amd64 on libgl1-foo-glx:i386] [foo-driver:amd64 ] +Inst foo-driver [1] (2 stable [amd64]) [] +Inst libfoo:i386 [1] (2 stable [i386]) [libfoo:amd64 on libfoo:i386] [libfoo:i386 on libfoo:amd64] [libfoo:amd64 ] +Inst libfoo [1] (2 stable [amd64]) +Conf libfoo:i386 (2 stable [i386]) +Conf libfoo (2 stable [amd64]) +Conf libgl1-foo-glx:i386 (2 stable [i386]) +Conf libgl1-foo-glx (2 stable [amd64]) +Conf foo-driver (2 stable [amd64])' aptget dist-upgrade -s + +testsuccess aptget dist-upgrade -y -o Debug::pkgPackageManager=1 -o Debug::pkgOrderList=1 diff --git a/test/integration/test-bug-multiarch-upgrade b/test/integration/test-bug-multiarch-upgrade index dc3725df1..c29e1f903 100755 --- a/test/integration/test-bug-multiarch-upgrade +++ b/test/integration/test-bug-multiarch-upgrade @@ -25,5 +25,5 @@ The following packages will be upgraded: 2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Inst libcups2 [1] (2 unstable [amd64]) [libcups2:amd64 on libcups2:i386] [libcups2:i386 on libcups2:amd64] [libcups2:i386 ] Inst libcups2:i386 [1] (2 unstable [i386]) -Conf libcups2 (2 unstable [amd64]) -Conf libcups2:i386 (2 unstable [i386])' aptget install -s libcups2:i386 +Conf libcups2:i386 (2 unstable [i386]) +Conf libcups2 (2 unstable [amd64])' aptget install -s libcups2:i386 diff --git a/test/integration/test-ignore-provides-if-versioned-breaks b/test/integration/test-ignore-provides-if-versioned-breaks index f8b4544a0..745f7d206 100755 --- a/test/integration/test-ignore-provides-if-versioned-breaks +++ b/test/integration/test-ignore-provides-if-versioned-breaks @@ -142,9 +142,9 @@ The following packages will be upgraded: 2 upgraded, 2 newly installed, 0 to remove and 2 not upgraded. Inst foo-same:amd64 [2.0] (4.0 unstable [amd64]) [foo-same:amd64 on foo-same:i386] [foo-same:i386 on foo-same:amd64] [foo-same:i386 ] Inst foo-same [2.0] (4.0 unstable [i386]) -Conf foo-same:amd64 (4.0 unstable [amd64]) -Conf foo-same (4.0 unstable [i386]) Inst foo-same-breaker-3 (1.0 unstable [i386]) Inst foo-same-provider (1.0 unstable [i386]) +Conf foo-same (4.0 unstable [i386]) +Conf foo-same:amd64 (4.0 unstable [amd64]) Conf foo-same-breaker-3 (1.0 unstable [i386]) Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-3 -s diff --git a/test/integration/test-ignore-provides-if-versioned-conflicts b/test/integration/test-ignore-provides-if-versioned-conflicts index 44eafcff1..a07252768 100755 --- a/test/integration/test-ignore-provides-if-versioned-conflicts +++ b/test/integration/test-ignore-provides-if-versioned-conflicts @@ -142,9 +142,9 @@ The following packages will be upgraded: 2 upgraded, 2 newly installed, 0 to remove and 2 not upgraded. Inst foo-same:amd64 [2.0] (4.0 unstable [amd64]) [foo-same:amd64 on foo-same:i386] [foo-same:i386 on foo-same:amd64] [foo-same:i386 ] Inst foo-same [2.0] (4.0 unstable [i386]) -Conf foo-same:amd64 (4.0 unstable [amd64]) -Conf foo-same (4.0 unstable [i386]) Inst foo-same-breaker-3 (1.0 unstable [i386]) Inst foo-same-provider (1.0 unstable [i386]) +Conf foo-same (4.0 unstable [i386]) +Conf foo-same:amd64 (4.0 unstable [amd64]) Conf foo-same-breaker-3 (1.0 unstable [i386]) Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-3 -s diff --git a/test/integration/test-prevent-markinstall-multiarch-same-versionscrew b/test/integration/test-prevent-markinstall-multiarch-same-versionscrew index fed12dad0..d647856cb 100755 --- a/test/integration/test-prevent-markinstall-multiarch-same-versionscrew +++ b/test/integration/test-prevent-markinstall-multiarch-same-versionscrew @@ -55,14 +55,14 @@ Remv out-of-sync-gone-foreign:i386 [1] Remv out-of-sync-gone-native [1] Inst fine [1] (2 unstable [amd64]) [fine:amd64 on fine:i386] [fine:i386 on fine:amd64] [fine:i386 ] Inst fine:i386 [1] (2 unstable [i386]) -Conf fine (2 unstable [amd64]) -Conf fine:i386 (2 unstable [i386]) Inst fine-installed [1] (2 unstable [amd64]) [fine-installed:amd64 on fine-installed:i386] [fine-installed:i386 on fine-installed:amd64] [fine-installed:i386 ] Inst fine-installed:i386 [1] (2 unstable [i386]) -Conf fine-installed (2 unstable [amd64]) -Conf fine-installed:i386 (2 unstable [i386]) Inst out-of-sync-gone-foreign [1] (2 unstable [amd64]) Inst out-of-sync-gone-native:i386 [1] (2 unstable [i386]) +Conf fine:i386 (2 unstable [i386]) +Conf fine (2 unstable [amd64]) +Conf fine-installed:i386 (2 unstable [i386]) +Conf fine-installed (2 unstable [amd64]) Conf out-of-sync-gone-foreign (2 unstable [amd64]) Conf out-of-sync-gone-native:i386 (2 unstable [i386])' aptget dist-upgrade -s #-o Debug::pkgDepCache::Marker=1 diff --git a/test/integration/test-very-tight-loop-configure-with-unpacking-new-packages b/test/integration/test-very-tight-loop-configure-with-unpacking-new-packages index 5856cd744..c1d454f88 100755 --- a/test/integration/test-very-tight-loop-configure-with-unpacking-new-packages +++ b/test/integration/test-very-tight-loop-configure-with-unpacking-new-packages @@ -39,9 +39,9 @@ Inst libreoffice-core [3] (4 sid [amd64]) [libreoffice-core:amd64 on libreoffice Inst libreoffice-common [3] (4 sid [all]) [] Inst ure (4 sid [amd64]) Conf ure (4 sid [amd64]) -Conf libreoffice-style-galaxy (4 sid [amd64]) Conf libreoffice-common (4 sid [all]) Conf libreoffice-core (4 sid [amd64]) +Conf libreoffice-style-galaxy (4 sid [amd64]) Conf libreoffice (4 sid [amd64])' 'Reading package lists... Building dependency tree... The following NEW packages will be installed: @@ -55,7 +55,7 @@ Inst libreoffice-core [3] (4 sid [amd64]) [libreoffice-common:amd64 on libreoffi Inst libreoffice-common [3] (4 sid [all]) [] Inst ure (4 sid [amd64]) Conf ure (4 sid [amd64]) -Conf libreoffice-style-galaxy (4 sid [amd64]) Conf libreoffice-common (4 sid [all]) Conf libreoffice-core (4 sid [amd64]) +Conf libreoffice-style-galaxy (4 sid [amd64]) Conf libreoffice (4 sid [amd64])' aptget dist-upgrade -s -- cgit v1.2.3 From 1e071c30340ef6b0f8279440a9fd369f27e9b34b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 8 Mar 2014 17:42:11 +0100 Subject: simplify apt-cdrom testcode Git-Dch: Ignore --- test/integration/test-apt-cdrom | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'test') diff --git a/test/integration/test-apt-cdrom b/test/integration/test-apt-cdrom index cc3483f9b..caaa351c0 100755 --- a/test/integration/test-apt-cdrom +++ b/test/integration/test-apt-cdrom @@ -24,9 +24,13 @@ cd - > /dev/null addtrap 'prefix' "chmod -R +w $PWD/rootdir/media/cdrom/dists/;" chmod -R -w rootdir/media/cdrom/dists -aptcdrom add -m -o quiet=1 > apt-cdrom.log 2>&1 -sed -i -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' apt-cdrom.log -testfileequal apt-cdrom.log "Scanning disc for index files.. +aptcdromlog() { + rm -f rootdir/tmp/apt-cdrom.log + aptcdrom "$@" -o quiet=1 >rootdir/tmp/apt-cdrom.log 2>&1 + sed -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' rootdir/tmp/apt-cdrom.log +} + +testequal "Scanning disc for index files.. Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures Found label 'Debian APT Testdisk 0.8.15' This disc is called: @@ -35,7 +39,9 @@ Writing new source list Source list entries for this disc are: deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main -Repeat this process for the rest of the CDs in your set." +Repeat this process for the rest of the CDs in your set." aptcdromlog add -m + +testequal 'Stored label: Debian APT Testdisk 0.8.15' aptcdromlog ident -m testequal 'Reading package lists... Building dependency tree... @@ -54,9 +60,7 @@ Inst testing:i386 (0.8.15 stable [i386]) Conf testing:i386 (0.8.15 stable [i386])' aptget install testing:i386 -s # check Idempotence of apt-cdrom (and disabling of Translation dropping) -aptcdrom add -m -o quiet=1 -o APT::CDROM::DropTranslation=0 > apt-cdrom.log 2>&1 -sed -i -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' apt-cdrom.log -testfileequal apt-cdrom.log "Scanning disc for index files.. +testequal "Scanning disc for index files.. Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures This disc is called: 'Debian APT Testdisk 0.8.15' @@ -64,12 +68,10 @@ Writing new source list Source list entries for this disc are: deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main -Repeat this process for the rest of the CDs in your set." +Repeat this process for the rest of the CDs in your set." aptcdromlog add -m -o APT::CDROM::DropTranslation=0 # take Translations from previous runs as needed -aptcdrom add -m -o quiet=1 > apt-cdrom.log 2>&1 -sed -i -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' apt-cdrom.log -testfileequal apt-cdrom.log "Scanning disc for index files.. +testequal "Scanning disc for index files.. Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures This disc is called: 'Debian APT Testdisk 0.8.15' @@ -77,14 +79,12 @@ Writing new source list Source list entries for this disc are: deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main -Repeat this process for the rest of the CDs in your set." +Repeat this process for the rest of the CDs in your set." aptcdromlog add -m msgtest 'Test for the german description translation of' 'testing' aptcache show testing -o Acquire::Languages=de | grep -q '^Description-de: ' && msgpass || msgfail rm -rf rootdir/var/lib/apt/lists mkdir -p rootdir/var/lib/apt/lists/partial -aptcdrom add -m -o quiet=1 > apt-cdrom.log 2>&1 -sed -i -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' apt-cdrom.log -testfileequal apt-cdrom.log "Scanning disc for index files.. +testequal "Scanning disc for index files.. Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures This disc is called: 'Debian APT Testdisk 0.8.15' @@ -92,7 +92,7 @@ Writing new source list Source list entries for this disc are: deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main -Repeat this process for the rest of the CDs in your set." +Repeat this process for the rest of the CDs in your set." aptcdromlog add -m msgtest 'Test for the english description translation of' 'testing' aptcache show testing -o Acquire::Languages=en | grep -q '^Description-en: ' && msgpass || msgfail -- cgit v1.2.3 From a0975c8d97f06ac116c5cea9a98993817ced0e86 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 00:43:21 +0100 Subject: enable mount support for apt-cdrom in the tests Git-Dch: Ignore --- test/integration/framework | 13 +++++-- test/integration/test-apt-cdrom | 78 ++++++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 40 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index d66171783..bf6fa0218 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -932,16 +932,23 @@ connect = 8080 changetocdrom() { mkdir -p rootdir/media/cdrom/.disk local CD="$(readlink -f rootdir/media/cdrom)" - echo "acquire::cdrom::mount \"${CD}\";" > rootdir/etc/apt/apt.conf.d/00cdrom - echo 'acquire::cdrom::autodetect 0;' >> rootdir/etc/apt/apt.conf.d/00cdrom + echo "acquire::cdrom::mount \"${CD}\"; +acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\"; +acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\"; +acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom echo -n "$1" > ${CD}/.disk/info if [ ! -d aptarchive/dists ]; then msgdie 'Flat file archive cdroms can not be created currently' return 1 fi - mv aptarchive/dists $CD + mv aptarchive/dists "$CD" ln -s "$(readlink -f ./incoming)" $CD/pool find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list' -delete + # start with an unmounted disk + mv "${CD}" "${CD}-unmounted" + # we don't want the disk to be modifiable + addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;" + chmod -R -w rootdir/media/cdrom-unmounted/dists } downloadfile() { diff --git a/test/integration/test-apt-cdrom b/test/integration/test-apt-cdrom index caaa351c0..fddd26bd9 100755 --- a/test/integration/test-apt-cdrom +++ b/test/integration/test-apt-cdrom @@ -12,36 +12,59 @@ setupaptarchive --no-update changetocdrom 'Debian APT Testdisk 0.8.15' # -de is not in the Release file, but picked up anyway for compatibility -cd rootdir/media/cdrom/dists/stable/main/i18n +cd rootdir/media/cdrom-unmounted/dists/stable/main/i18n +chmod +w . sed -e '/^Description-en:/ d' -e '/^ / d' -e '/^$/ d' Translation-en > Translation-de echo 'Description-de: automatisch generiertes Testpaket testing=0.8.15/stable Diese Pakete sind nur für das testen von APT gedacht, sie erfüllen keinen Zweck auf einem normalen System… ' >> Translation-de compressfile Translation-de -rm Translation-en Translation-de +rm -f Translation-en Translation-de +chmod -R -w . cd - > /dev/null -addtrap 'prefix' "chmod -R +w $PWD/rootdir/media/cdrom/dists/;" -chmod -R -w rootdir/media/cdrom/dists aptcdromlog() { rm -f rootdir/tmp/apt-cdrom.log - aptcdrom "$@" -o quiet=1 >rootdir/tmp/apt-cdrom.log 2>&1 - sed -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' rootdir/tmp/apt-cdrom.log + test ! -e rootdir/media/cdrom || echo "CD-ROM is mounted, but shouldn't be!" + test -e rootdir/media/cdrom-unmounted || echo "Unmounted CD-ROM doesn't exist, but it should!" + aptcdrom "$@" -o quiet=1 >rootdir/tmp/apt-cdrom.log 2>&1 Date: Mon, 10 Mar 2014 01:49:37 +0100 Subject: support very long mtab entries in mountpoint discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Old code limited lines to 250 characters which is probably enough for everybody, but who knows… It also takes care of device nodes which start with the same prefix. --- test/libapt/cdromfindmountpointfordevice_test.cc | 26 ++++++++++++++++++++++++ test/libapt/makefile | 6 ++++++ test/libapt/run-tests | 8 ++++++++ 3 files changed, 40 insertions(+) create mode 100644 test/libapt/cdromfindmountpointfordevice_test.cc (limited to 'test') diff --git a/test/libapt/cdromfindmountpointfordevice_test.cc b/test/libapt/cdromfindmountpointfordevice_test.cc new file mode 100644 index 000000000..26dcd1459 --- /dev/null +++ b/test/libapt/cdromfindmountpointfordevice_test.cc @@ -0,0 +1,26 @@ +#include + +#include +#include + +#include +#include + +#include "assert.h" + +int main(int argc, char const *argv[]) { + if (argc != 2) { + std::cout << "One parameter expected - given " << argc << std::endl; + return 100; + } + + _config->Set("Dir::state::Mountpoints", argv[1]); + equals("/", FindMountPointForDevice("rootfs")); + equals("/", FindMountPointForDevice("/dev/disk/by-uuid/fadcbc52-6284-4874-aaaa-dcee1f05fe21")); + equals("/sys", FindMountPointForDevice("sysfs")); + equals("/sys0", FindMountPointForDevice("sysfs0")); + equals("/boot/efi", FindMountPointForDevice("/dev/sda1")); + equals("/tmp", FindMountPointForDevice("tmpfs")); + + return 0; +} diff --git a/test/libapt/makefile b/test/libapt/makefile index a8e053d6e..66d6ea783 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -94,6 +94,12 @@ SLIBS = -lapt-pkg SOURCE = cdromreducesourcelist_test.cc include $(PROGRAM_H) +# test cdroms FindMountPointForDevice for udev autodetection +PROGRAM = CdromFindMountPointForDevice${BASENAME} +SLIBS = -lapt-pkg +SOURCE = cdromfindmountpointfordevice_test.cc +include $(PROGRAM_H) + # test IndexCopy::ConvertToSourceList PROGRAM = IndexCopyToSourceList${BASENAME} SLIBS = -lapt-pkg diff --git a/test/libapt/run-tests b/test/libapt/run-tests index a056f31f9..0baedcf9e 100755 --- a/test/libapt/run-tests +++ b/test/libapt/run-tests @@ -108,6 +108,14 @@ do "${tmppath}/dists/unstable/InRelease" \ "${tmppath}/dists/broken/Release.gpg" ln -s "${tmppath}/dists/unstable" "${tmppath}/dists/sid" + elif [ $name = "CdromFindMountPointForDevice${EXT}" ]; then + tmppath=$(mktemp) + echo 'rootfs / rootfs rw 0 0 +sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 +sysfs0 /sys0 sysfs rw,nosuid,nodev,noexec,relatime 0 0 +/dev/disk/by-uuid/fadcbc52-6284-4874-aaaa-dcee1f05fe21 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0 +/dev/sda1 /boot/efi vfat rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro 0 0 +tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0' > $tmppath fi echo -n "Testing with ${NAME} " -- cgit v1.2.3 From 1166ea79889ecd6c88380f7988182647cf787f8f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 02:54:33 +0100 Subject: msgstr with elipses need three dots fixes some messages and their translation so that all of them have three dots for messages with an elipse. Many translations already had this. --- test/integration/test-apt-cdrom | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/integration/test-apt-cdrom b/test/integration/test-apt-cdrom index fddd26bd9..8d8fdf167 100755 --- a/test/integration/test-apt-cdrom +++ b/test/integration/test-apt-cdrom @@ -35,11 +35,11 @@ aptcdromlog() { } CDROM_PRE="Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/ -Unmounting CD-ROM +Unmounting CD-ROM... Waiting for disc... Please insert a Disc in the drive and press enter Mounting CD-ROM... -Scanning disc for index files.." +Scanning disc for index files..." CDROM_POST="This disc is called: 'Debian APT Testdisk 0.8.15' Writing new source list -- cgit v1.2.3 From 0d58c26ad7b2308f08f4e6002cbf218605c1c7cf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 14:15:45 +0100 Subject: improve debug output in case downloadfile fails Git-Dch: Ignore --- test/integration/framework | 83 ++++++++++++++++++----------- test/integration/test-apt-https-no-redirect | 20 ++++--- test/integration/test-partial-file-support | 43 +++++---------- 3 files changed, 79 insertions(+), 67 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index bf6fa0218..c623e6231 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -863,18 +863,16 @@ signreleasefiles() { webserverconfig() { msgtest "Set webserver config option '${1}' to" "$2" - downloadfile "http://localhost:8080/_config/set/${1}/${2}" '/dev/null' >/dev/null - local DOWNLOG='download-testfile.log' - rm -f "$DOWNLOG" - local STATUS="${TMPWORKINGDIRECTORY}/rootdir/tmp/webserverconfig.status" - downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" - if [ "$(cat "$STATUS")" = '200' ]; then + local DOWNLOG='rootdir/tmp/download-testfile.log' + local STATUS='rootdir/tmp/webserverconfig.status' + rm -f "$STATUS" "$DOWNLOG" + if downloadfile "http://localhost:8080/_config/set/${1}/${2}" "$STATUS" > "$DOWNLOG"; then msgpass else - cat >&2 "$DOWNLOG" - msgfail "Statuscode was $(cat "$STATUS")" + cat "$DOWNLOG" "$STATUS" + msgfail fi - rm "$STATUS" + testwebserverlaststatuscode '200' } rewritesourceslist() { @@ -952,10 +950,10 @@ acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom } downloadfile() { - PROTO="$(echo "$1" | cut -d':' -f 1)" - apthelper -o Acquire::https::CaInfo=${TESTDIR}/apt.pem \ - -o Debug::Acquire::${PROTO}=1 \ - download-file "$1" "$2" 2>&1 + local PROTO="$(echo "$1" | cut -d':' -f 1 )" + apthelper -o Acquire::https::CaInfo=${TESTDIR}/apt.pem \ + -o Debug::Acquire::${PROTO}=1 \ + download-file "$1" "$2" 2>&1 || true # only if the file exists the download was successful if [ -e "$2" ]; then return 0 @@ -967,8 +965,8 @@ downloadfile() { checkdiff() { local DIFFTEXT="$(command diff -u "$@" | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')" if [ -n "$DIFFTEXT" ]; then - echo - echo "$DIFFTEXT" + echo >&2 + echo >&2 "$DIFFTEXT" return 1 else return 0 @@ -1017,7 +1015,9 @@ testequalor2() { shift 2 msgtest "Test for equality OR of" "$*" $* >$COMPAREAGAINST 2>&1 || true - if checkdiff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null || checkdiff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null; then + if checkdiff $COMPAREFILE1 $COMPAREAGAINST >/dev/null 2>&1 || \ + checkdiff $COMPAREFILE2 $COMPAREAGAINST >/dev/null 2>&1 + then msgpass else echo -n "\n${CINFO}Diff against OR 1${CNORMAL}" @@ -1051,24 +1051,24 @@ testnopackage() { msgtest "Test for non-existent packages" "apt-cache show $*" local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')" if [ -n "$SHOWPKG" ]; then - echo - echo "$SHOWPKG" + echo >&2 + echo >&2 "$SHOWPKG" msgfail - return 1 + else + msgpass fi - msgpass } testdpkginstalled() { msgtest "Test for correctly installed package(s) with" "dpkg -l $*" local PKGS="$(dpkg -l "$@" 2>/dev/null | grep '^i' | wc -l)" if [ "$PKGS" != $# ]; then - echo $PKGS - dpkg -l "$@" | grep '^[a-z]' + echo >&2 $PKGS + dpkg -l "$@" | grep '^[a-z]' >&2 msgfail - return 1 + else + msgpass fi - msgpass } testdpkgnotinstalled() { @@ -1076,11 +1076,11 @@ testdpkgnotinstalled() { local PKGS="$(dpkg -l "$@" 2> /dev/null | grep '^i' | wc -l)" if [ "$PKGS" != 0 ]; then echo - dpkg -l "$@" | grep '^[a-z]' + dpkg -l "$@" | grep '^[a-z]' >&2 msgfail - return 1 + else + msgpass fi - msgpass } testmarkedauto() { @@ -1105,8 +1105,8 @@ testsuccess() { if $@ >${OUTPUT} 2>&1; then msgpass else - echo - cat $OUTPUT + echo >&2 + cat >&2 $OUTPUT msgfail fi } @@ -1119,14 +1119,35 @@ testfailure() { fi local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" if $@ >${OUTPUT} 2>&1; then - echo - cat $OUTPUT + echo >&2 + cat >&2 $OUTPUT msgfail else msgpass fi } +testwebserverlaststatuscode() { + local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log' + local STATUS='rootdir/tmp/webserverstatus-statusfile.log' + rm -f "$DOWNLOG" "$STATUS" + msgtest 'Test last status code from the webserver was' "$1" + downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" + if [ "$(cat "$STATUS")" = "$1" ]; then + msgpass + else + echo >&2 + if [ -n "$2" ]; then + shift + echo >&2 '#### Additionally provided output files contain:' + cat >&2 "$@" + fi + echo >&2 '#### Download log of the status code:' + cat >&2 "$DOWNLOG" + msgfail "Status was $(cat "$STATUS")" + fi +} + pause() { echo "STOPPED execution. Press enter to continue" local IGNORE diff --git a/test/integration/test-apt-https-no-redirect b/test/integration/test-apt-https-no-redirect index 0408c6832..73352a28c 100755 --- a/test/integration/test-apt-https-no-redirect +++ b/test/integration/test-apt-https-no-redirect @@ -7,18 +7,24 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture "i386" -buildsimplenativepackage 'apt' 'all' '1.0' 'stable' +insertpackage 'stable' 'apt' 'all' '1' setupaptarchive --no-update +echo 'alright' > aptarchive/working changetohttpswebserver -o 'aptwebserver::redirect::replace::/redirectme/=http://localhost:8080/' -msgtest 'normal http download works' -downloadfile 'http://localhost:8080/pool/apt_1.0/changelog' changelog2 >/dev/null 2>/dev/null && msgpass || msgfail +msgtest 'download of a file works via' 'http' +downloadfile 'http://localhost:8080/working' httpfile >/dev/null 2>&1 && msgpass || msgfail +testfileequal httpfile 'alright' -msgtest 'normal https download works' -downloadfile 'https://localhost:4433/pool/apt_1.0/changelog' changelog >/dev/null 2>/dev/null && msgpass || msgfail +msgtest 'download of a file works via' 'https' +downloadfile 'https://localhost:4433/working' httpsfile >/dev/null 2>&1 && msgpass || msgfail +testfileequal httpsfile 'alright' -msgtest 'redirecting https to http does not work' -downloadfile 'https://localhost:4433/redirectme/pool/apt_1.0/changelog' changelog3 2>&1 | grep "Protocol http not supported or disabled in libcurl" > /dev/null && msgpass || msgfail +msgtest 'download of a file does not work if' 'https redirected to http' +downloadfile 'https://localhost:4433/redirectme/working' redirectfile >curloutput 2>&1 && msgfail || msgpass + +msgtest 'libcurl has forbidden access in last request to' 'http resource' +grep -q -- 'Protocol http not supported or disabled in libcurl' curloutput && msgpass || msgfail diff --git a/test/integration/test-partial-file-support b/test/integration/test-partial-file-support index 382789e68..5ab326def 100755 --- a/test/integration/test-partial-file-support +++ b/test/integration/test-partial-file-support @@ -13,17 +13,18 @@ copysource() { touch -d "$(stat --format '%y' "${TESTFILE}")" "$3" } +DOWNLOADLOG='rootdir/tmp/testdownloadfile.log' + testdownloadfile() { - local DOWNLOG='download-testfile.log' - rm -f "$DOWNLOG" + rm -f "$DOWNLOADLOG" msgtest "Testing download of file $2 with" "$1" - if ! downloadfile "$2" "$3" > "$DOWNLOG"; then - cat >&2 "$DOWNLOG" + if ! downloadfile "$2" "$3" > "$DOWNLOADLOG"; then + cat >&2 "$DOWNLOADLOG" msgfail else msgpass fi - cat "$DOWNLOG" | while read field hash; do + cat "$DOWNLOADLOG" | while read field hash; do local EXPECTED case "$field" in 'MD5Sum-Hash:') EXPECTED="$(md5sum "$TESTFILE" | cut -d' ' -f 1)";; @@ -40,28 +41,12 @@ testdownloadfile() { if [ "$EXPECTED" "$4" "$hash" ]; then msgpass else - cat >&2 "$DOWNLOG" + cat >&2 "$DOWNLOADLOG" msgfail "expected: $EXPECTED ; got: $hash" fi done } -testwebserverlaststatuscode() { - local DOWNLOG='download-testfile.log' - rm -f "$DOWNLOG" - local STATUS="$(mktemp)" - addtrap "rm $STATUS;" - msgtest 'Test last status code from the webserver was' "$1" - downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" - if [ "$(cat "$STATUS")" = "$1" ]; then - msgpass - else - cat >&2 "$DOWNLOG" - msgfail "Status was $(cat "$STATUS")" - fi -} - - TESTFILE='aptarchive/testfile' cp -a ${TESTDIR}/framework $TESTFILE @@ -70,34 +55,34 @@ testrun() { copysource $TESTFILE 0 ./testfile testdownloadfile 'no data' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '200' + testwebserverlaststatuscode '200' "$DOWNLOADLOG" copysource $TESTFILE 20 ./testfile testdownloadfile 'valid partial data' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '206' + testwebserverlaststatuscode '206' "$DOWNLOADLOG" copysource /dev/zero 20 ./testfile testdownloadfile 'invalid partial data' "${1}/testfile" './testfile' '!=' - testwebserverlaststatuscode '206' + testwebserverlaststatuscode '206' "$DOWNLOADLOG" copysource $TESTFILE 1M ./testfile testdownloadfile 'completely downloaded file' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '416' + testwebserverlaststatuscode '416' "$DOWNLOADLOG" copysource /dev/zero 1M ./testfile testdownloadfile 'too-big partial file' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '200' + testwebserverlaststatuscode '200' "$DOWNLOADLOG" copysource /dev/zero 20 ./testfile touch ./testfile testdownloadfile 'old data' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '200' + testwebserverlaststatuscode '200' "$DOWNLOADLOG" webserverconfig 'aptwebserver::support::range' 'false' copysource $TESTFILE 20 ./testfile testdownloadfile 'no server support' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '200' + testwebserverlaststatuscode '200' "$DOWNLOADLOG" } testrun 'http://localhost:8080' -- cgit v1.2.3 From b9b0f6222c489db78331cc8be3c093538d22c70b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 17:53:22 +0100 Subject: use a configurable list of versioned kernel packages With APT::VersionedKernelPackages users have the option of adding packages like pre-build out-of-tree modules to the list of automatically protected from being autoremoved. --- test/integration/framework | 10 ++- .../test-bug-1078697-missing-source-hashes | 35 --------- test/integration/test-kernel-helper-autoremove | 91 ++++++++++++---------- .../test-kernel-helper-autoremove.fake-dpkg | 13 ---- .../test-ubuntu-bug-1078697-missing-source-hashes | 35 +++++++++ 5 files changed, 93 insertions(+), 91 deletions(-) delete mode 100755 test/integration/test-bug-1078697-missing-source-hashes delete mode 100644 test/integration/test-kernel-helper-autoremove.fake-dpkg create mode 100755 test/integration/test-ubuntu-bug-1078697-missing-source-hashes (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index c623e6231..dad8c99f0 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -93,14 +93,15 @@ msgdone() { runapt() { msgdebug "Executing: ${CCMD}$*${CDEBUG} " - local CMD="$1" + local CMD="${BUILDDIRECTORY}/$1" + if [ "$1" = 'sh' ]; then CMD='sh'; fi shift if [ -f ./aptconfig.conf ]; then - MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@" + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@" elif [ -f ../aptconfig.conf ]; then - MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@" + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@" else - MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@" + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@" fi } aptconfig() { runapt apt-config "$@"; } @@ -198,6 +199,7 @@ setupenvironment() { touch var/lib/dpkg/available mkdir -p usr/lib/apt ln -s ${METHODSDIR} usr/lib/apt/methods + ln -s ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove etc/apt/apt.conf.d/01autoremove cd .. local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/') if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then diff --git a/test/integration/test-bug-1078697-missing-source-hashes b/test/integration/test-bug-1078697-missing-source-hashes deleted file mode 100755 index 6fcb856b5..000000000 --- a/test/integration/test-bug-1078697-missing-source-hashes +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -set -e - -TESTDIR=$(readlink -f $(dirname $0)) -. $TESTDIR/framework -setupenvironment -configarchitecture "i386" - -msgtest 'Test apt-ftparchive source with missing hashes in .dsc' - -touch aptarchive/foo_1.0.tar.gz -cat > aptarchive/foo_1.0.dsc << EOF -Format: 3.0 (native) -Source: foo -Binary: foo -Architecture: all -Version: 1.0 -Package-List: - foo deb admin extra -Files: - d41d8cd98f00b204e9800998ecf8427e 0 foo_1.0.tar.gz -EOF - -# check for the SHA hashes -aptftparchive sources aptarchive/ > aptarchive/Sources 2>/dev/null || msgfail -test -n "$(grep Checksums-Sha512 aptarchive/Sources)" && msgpass || msgfail - -for hash in sha512sum sha256sum sha1sum; do - for f in foo_1.0.tar.gz foo_1.0.dsc; do - SUM=$($hash aptarchive/$f | cut -d' ' -f1) - msgtest "Test $hash hash matches for $f" - NEEDLE="$SUM $(stat -c%s aptarchive/$f) $f" - test -n "$SUM" && test -n "$(grep "$NEEDLE" aptarchive/Sources)" && msgpass || msgfail - done -done diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index 2b165d100..be30c6f6e 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -1,55 +1,68 @@ #!/bin/sh - set -e -# setup testdir TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework +setupenvironment +configarchitecture 'native' -TMPDIR=$(mktemp -d) -cd $TMPDIR -addtrap "cd /; rm -rf $TMPDIR" +# the executed script would use the installed apt-config, +# which is outside of our control +msgtest 'Check that the installed apt-config supports' '--no-empty' +if apt-config dump --no-empty >/dev/null 2>&1; then + msgpass +else + msgskip + exit 0 +fi -# create mock environment -mkdir apt.conf.d -cat > aptconfig.conf < ./fake-dpkg < rootdir/etc/apt/apt.conf.d/99fakedpkg -# install fake-dpkg into it -install -m755 $TESTDIR/test-kernel-helper-autoremove.fake-dpkg $TMPDIR/fake-dpkg +catfail() { + echo >&2 + echo >&2 '### List of protected kernels:' + cat >&2 protected.list + msgfail +} -# run the helper -sh ${TESTDIR}/../../debian/apt.auto-removal.sh +testprotected() { + rm -f rootdir/etc/apt/apt.conf.d/01autoremove-kernels protected.list -msgtest 'Check that kernel autoremoval list is correctly created' -# and ensure its there, valid and version 10.0.0-1 is there too -test -e $TMPDIR/apt.conf.d/01autoremove-kernels && msgpass || msgfail + testsuccess runapt sh ${TESTDIR}/../../debian/apt.auto-removal.sh "$@" -msgtest 'Check that most recent kernel is saved from autoremoval' -apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" && msgpass || msgfail + msgtest 'Check kernel autoremoval protection list' 'is created' + test -e rootdir/etc/apt/apt.conf.d/01autoremove-kernels && msgpass || msgfail -# ... and also that the running kernel is excluded -msgtest 'Check that running kernel is saved from autoremoval' -apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" && msgpass || msgfail + msgtest 'Check kernel autoremoval protection list' 'can be dumped' + aptconfig dump --no-empty --format '%v%n' 'APT::NeverAutoRemove' >protected.list 2>&1 && msgpass || catfail -# and that the old kernel is *not* excluded from autoremoval -msgtest 'Check that older kernels are not excluded from autoremoval' -apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic" && msgfail || msgpass + msgtest 'Check kernel autoremoval protection list' 'can be parsed' + grep -q '^[A-Z]: ' protected.list && catfail || msgpass -msgtest "Check that the older kernel is retained when it's being installed" -sh ${TESTDIR}/../../debian/apt.auto-removal.sh 1.0.01-2-generic -test -e $TMPDIR/apt.conf.d/01autoremove-kernels -if ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" \ - || ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" \ - || ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic" -then - msgfail -else - msgpass -fi + msgtest 'Check kernel autoremoval protection list includes' 'most recent kernel' + grep -q '^\^linux-image-100\.0\.0-1-generic\$$' protected.list && msgpass || catfail + + msgtest 'Check kernel autoremoval protection list includes' 'running kernel' + grep -q "^\\^linux-image-$(uname -r)\\\$\$" protected.list && msgpass || catfail +} + +testprotected +msgtest 'Check kernel autoremoval protection list does not include' 'old kernel' +grep -q '^\^linux-image-1\.0\.0-2-generic\$$' protected.list && catfail || msgpass -# done +testprotected 1.0.0-2-generic +msgtest 'Check kernel autoremoval protection list includes' 'installed kernel' +grep -q '^\^linux-image-1\.0\.0-2-generic\$$' protected.list && msgpass || catfail diff --git a/test/integration/test-kernel-helper-autoremove.fake-dpkg b/test/integration/test-kernel-helper-autoremove.fake-dpkg deleted file mode 100644 index a365c5370..000000000 --- a/test/integration/test-kernel-helper-autoremove.fake-dpkg +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -set -e - -if [ "$1" = "-l" ]; then - echo "ii linux-image-1.0.0-2-generic 1.0.01-2 amd64" - echo "ii linux-image-$(uname -r) not-used amd64" - echo "ii linux-image-10.0.0-1-generic 10.0.0.1-1 amd64" -elif [ "$1" = "--compare-versions" ]; then - dpkg "$1" "$2" "$3" "$4" -else - dpkg $@ -fi - diff --git a/test/integration/test-ubuntu-bug-1078697-missing-source-hashes b/test/integration/test-ubuntu-bug-1078697-missing-source-hashes new file mode 100755 index 000000000..6fcb856b5 --- /dev/null +++ b/test/integration/test-ubuntu-bug-1078697-missing-source-hashes @@ -0,0 +1,35 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture "i386" + +msgtest 'Test apt-ftparchive source with missing hashes in .dsc' + +touch aptarchive/foo_1.0.tar.gz +cat > aptarchive/foo_1.0.dsc << EOF +Format: 3.0 (native) +Source: foo +Binary: foo +Architecture: all +Version: 1.0 +Package-List: + foo deb admin extra +Files: + d41d8cd98f00b204e9800998ecf8427e 0 foo_1.0.tar.gz +EOF + +# check for the SHA hashes +aptftparchive sources aptarchive/ > aptarchive/Sources 2>/dev/null || msgfail +test -n "$(grep Checksums-Sha512 aptarchive/Sources)" && msgpass || msgfail + +for hash in sha512sum sha256sum sha1sum; do + for f in foo_1.0.tar.gz foo_1.0.dsc; do + SUM=$($hash aptarchive/$f | cut -d' ' -f1) + msgtest "Test $hash hash matches for $f" + NEEDLE="$SUM $(stat -c%s aptarchive/$f) $f" + test -n "$SUM" && test -n "$(grep "$NEEDLE" aptarchive/Sources)" && msgpass || msgfail + done +done -- cgit v1.2.3 From 33677a0cddd552f96963eac6dc74d8ffe9c1f2f6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 20:57:07 +0100 Subject: support kfreebsd and hurd in the kernel hook kfreebsd as well as hurd kernel packages call the postinst script as well so we just need to enable the correct parsing for installed packages and disable the "protect every version" hammer for them. --- test/integration/framework | 2 +- test/integration/test-kernel-helper-autoremove | 44 ++++++++++++++++++++------ 2 files changed, 35 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index dad8c99f0..6502dbad1 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -194,7 +194,7 @@ setupenvironment() { mkdir rootdir aptarchive keys cd rootdir mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d - mkdir -p var/cache var/lib var/log tmp + mkdir -p var/cache var/lib/apt var/log tmp mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers touch var/lib/dpkg/available mkdir -p usr/lib/apt diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index be30c6f6e..cb1c54e81 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -4,7 +4,7 @@ set -e TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment -configarchitecture 'native' +configarchitecture 'amd64' # the executed script would use the installed apt-config, # which is outside of our control @@ -16,21 +16,21 @@ else exit 0 fi -# install fake-dpkg into it +CURRENTKERNEL="linux-image-$(uname -r)" +insertinstalledpackage "$CURRENTKERNEL" 'amd64' '1' +insertinstalledpackage 'linux-image-1.0.0-2-generic' 'amd64' '1.0.0-2' +insertinstalledpackage 'linux-image-100.0.0-1-generic' 'amd64' '100.0.0-1' + +testsuccess aptmark auto "$CURRENTKERNEL" 'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' + cat > ./fake-dpkg < rootdir/etc/apt/apt.conf.d/99fakedpkg +# install fake-dpkg into it catfail() { echo >&2 echo >&2 '### List of protected kernels:' @@ -59,10 +59,34 @@ testprotected() { grep -q "^\\^linux-image-$(uname -r)\\\$\$" protected.list && msgpass || catfail } +testequal "Reading package lists... +Building dependency tree... +Reading state information... +The following packages will be REMOVED: + linux-image-1.0.0-2-generic (1.0.0-2) + linux-image-100.0.0-1-generic (100.0.0-1) + $CURRENTKERNEL (1) +0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded. +Remv linux-image-1.0.0-2-generic [1.0.0-2] +Remv linux-image-100.0.0-1-generic [100.0.0-1] +Remv $CURRENTKERNEL [1]" aptget autoremove -sV + testprotected msgtest 'Check kernel autoremoval protection list does not include' 'old kernel' grep -q '^\^linux-image-1\.0\.0-2-generic\$$' protected.list && catfail || msgpass +testequal 'Reading package lists... +Building dependency tree... +Reading state information... +The following packages will be REMOVED: + linux-image-1.0.0-2-generic +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv linux-image-1.0.0-2-generic [1.0.0-2]' aptget autoremove -s + testprotected 1.0.0-2-generic msgtest 'Check kernel autoremoval protection list includes' 'installed kernel' grep -q '^\^linux-image-1\.0\.0-2-generic\$$' protected.list && msgpass || catfail +testequal 'Reading package lists... +Building dependency tree... +Reading state information... +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget autoremove -s -- cgit v1.2.3 From 7ce1ac857d914f98069078b1ea70995e7b6cf764 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 21:31:35 +0100 Subject: ensure that a dot is a dot in the hook As we deal with regex matchers here the dots are treated as wildcards if we don't take care of escaping them. Not very likely that this could be a real-world problem, but just to be sure. --- test/integration/test-kernel-helper-autoremove | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index cb1c54e81..7713c0875 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -20,8 +20,10 @@ CURRENTKERNEL="linux-image-$(uname -r)" insertinstalledpackage "$CURRENTKERNEL" 'amd64' '1' insertinstalledpackage 'linux-image-1.0.0-2-generic' 'amd64' '1.0.0-2' insertinstalledpackage 'linux-image-100.0.0-1-generic' 'amd64' '100.0.0-1' +# ensure that the '.' is really a dot and not a wildcard +insertinstalledpackage 'linux-headers-1000000-1-generic' 'amd64' '100.0.0-1' -testsuccess aptmark auto "$CURRENTKERNEL" 'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' +testsuccess aptmark auto "$CURRENTKERNEL" 'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' 'linux-headers-1000000-1-generic' cat > ./fake-dpkg < Date: Mon, 10 Mar 2014 22:31:00 +0100 Subject: correct LD_LIBRARY_PATH and config loading for apt-helper Mostly ensures that we use the build methods and not the system provided methods in the tests (if we don't want it that way). Git-Dch: Ignore --- test/integration/framework | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 6502dbad1..1ab421c4c 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -93,15 +93,18 @@ msgdone() { runapt() { msgdebug "Executing: ${CCMD}$*${CDEBUG} " - local CMD="${BUILDDIRECTORY}/$1" - if [ "$1" = 'sh' ]; then CMD='sh'; fi + local CMD="$1" shift + case $CMD in + sh|aptitude|*/*) ;; + *) CMD="${BUILDDIRECTORY}/$CMD";; + esac if [ -f ./aptconfig.conf ]; then - MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@" + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${LIBRARYPATH} $CMD "$@" elif [ -f ../aptconfig.conf ]; then - MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@" + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${LIBRARYPATH} $CMD "$@" else - MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@" + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${LIBRARYPATH} $CMD "$@" fi } aptconfig() { runapt apt-config "$@"; } @@ -112,33 +115,19 @@ aptftparchive() { runapt apt-ftparchive "$@"; } aptkey() { runapt apt-key "$@"; } aptmark() { runapt apt-mark "$@"; } apt() { runapt apt "$@"; } -apthelper() { - LD_LIBRARY_PATH=${APTHELPERBINDIR} ${APTHELPERBINDIR}/apt-helper "$@"; -} -aptwebserver() { - LD_LIBRARY_PATH=${APTWEBSERVERBINDIR} ${APTWEBSERVERBINDIR}/aptwebserver "$@"; -} +apthelper() { runapt "${APTHELPERBINDIR}/apt-helper" "$@"; } +aptwebserver() { runapt "${APTWEBSERVERBINDIR}/aptwebserver" "$@"; } +aptitude() { runapt aptitude "$@"; } + dpkg() { command dpkg --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log "$@" } dpkgcheckbuilddeps() { command dpkg-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg "$@" } -aptitude() { - if [ -f ./aptconfig.conf ]; then - APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} command aptitude "$@" - elif [ -f ../aptconfig.conf ]; then - APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} command aptitude "$@" - else - LD_LIBRARY_PATH=${BUILDDIRECTORY} command aptitude "$@" - fi -} gdb() { echo "gdb: run »$*«" - APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} command gdb ${BUILDDIRECTORY}/$1 --args "$@" -} -http() { - LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/methods/http + APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${LIBRARYPATH} command gdb ${BUILDDIRECTORY}/$1 --args "$@" } gpg() { # see apt-key for the whole trickery. Setup is done in setupenvironment @@ -183,6 +172,7 @@ setupenvironment() { # allow overriding the default BUILDDIR location BUILDDIRECTORY=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"} + LIBRARYPATH=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"} METHODSDIR=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"} APTHELPERBINDIR=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"} APTWEBSERVERBINDIR=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"} @@ -246,7 +236,7 @@ setupenvironment() { # cleanup the environment a bit export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin" export LC_ALL=C.UTF-8 - unset LANGUAGE + unset LANGUAGE APT_CONFIG unset GREP_OPTIONS DEB_BUILD_PROFILES msgdone "info" -- cgit v1.2.3 From 3dcdc1f91a5646f882940ff055b972d6b31a0ba5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Mar 2014 13:31:41 +0100 Subject: factor out getting list of architectures from comma list Beside fixing this minor code duplication it also resolves the problem of messing up vim syntax-highlighting. Git-Dch: Ignore --- test/integration/framework | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 1ab421c4c..00c8f3abc 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -259,6 +259,10 @@ getarchitectures() { echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')" } +getarchitecturesfromcommalist() { + echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/" +} + configarchitecture() { { echo "APT::Architecture \"$(getarchitecture $1)\";" @@ -432,7 +436,7 @@ Package: $NAME" >> ${BUILDDIR}/debian/control # fi done - for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do + for arch in $(getarchitecturesfromcommalist "$ARCH"); do rm -rf ${BUILDDIR}/debian/tmp mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} @@ -587,7 +591,7 @@ insertpackage() { something went horribly wrong! They are autogenerated und used only by testcases and surf no other propose…"}" local ARCHS="" - for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do + for arch in $(getarchitecturesfromcommalist "$ARCH"); do if [ "$arch" = 'all' -o "$arch" = 'none' ]; then ARCHS="$(getarchitectures)" else @@ -649,7 +653,7 @@ insertinstalledpackage() { local FILE='rootdir/var/lib/dpkg/status' local INFO='rootdir/var/lib/dpkg/info' - for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do + for arch in $(getarchitecturesfromcommalist "$ARCH"); do echo "Package: $NAME Status: $STATUS Priority: $PRIORITY @@ -943,8 +947,7 @@ acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom downloadfile() { local PROTO="$(echo "$1" | cut -d':' -f 1 )" - apthelper -o Acquire::https::CaInfo=${TESTDIR}/apt.pem \ - -o Debug::Acquire::${PROTO}=1 \ + apthelper -o Debug::Acquire::${PROTO}=1 \ download-file "$1" "$2" 2>&1 || true # only if the file exists the download was successful if [ -e "$2" ]; then -- cgit v1.2.3 From 36e7727f70cde14b95f72029a9e2663672ef4da8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Mar 2014 13:36:08 +0100 Subject: ensure that gz compression test is run with gz The framework can be configured to use different compression algorithms to test different ones, but a testcase testing for gz support should always be run with gz, regardless of what compressions are configured otherwise. Git-Dch: Ignore --- test/integration/test-compressed-indexes | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/integration/test-compressed-indexes b/test/integration/test-compressed-indexes index c6f5ab49e..67ca0ba27 100755 --- a/test/integration/test-compressed-indexes +++ b/test/integration/test-compressed-indexes @@ -5,6 +5,7 @@ TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment +configcompression '.' 'gz' # only gz is supported for this, so ensure it is used configarchitecture "i386" buildsimplenativepackage "testpkg" "i386" "1.0" -- cgit v1.2.3