summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-09-04 14:56:01 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-09-04 14:56:01 +0200
commit85909fca550d03b0e215d16cdd701190b43ff63c (patch)
treeb6767be7b1898830499b0a5fb8153460223b5649 /test
parentac5b5e826ab405935dc257c0a0984ae39b02bc23 (diff)
parent89e95aee05c7f2fde7eb11261df9697a4896b49b (diff)
merged sftp://bzr.debian.org/bzr/apt/apt/debian-sid
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework19
-rwxr-xr-xtest/integration/test-apt-cdrom104
-rwxr-xr-xtest/integration/test-unpack-different-version-unpacked121
-rw-r--r--test/libapt/cdromreducesourcelist_test.cc86
-rw-r--r--test/libapt/indexcopytosourcelist_test.cc86
-rw-r--r--test/libapt/makefile12
6 files changed, 427 insertions, 1 deletions
diff --git a/test/integration/framework b/test/integration/framework
index c656157f2..bec321240 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -91,6 +91,7 @@ runapt() {
}
aptconfig() { runapt apt-config $*; }
aptcache() { runapt apt-cache $*; }
+aptcdrom() { runapt apt-cdrom $*; }
aptget() { runapt apt-get $*; }
aptftparchive() { runapt apt-ftparchive $*; }
aptkey() { runapt apt-key $*; }
@@ -523,11 +524,12 @@ insertinstalledpackage() {
local VERSION="$3"
local DEPENDENCIES="$4"
local PRIORITY="${5:-optional}"
+ local STATUS="${6:-install ok installed}"
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
echo "Package: $NAME
-Status: install ok installed
+Status: $STATUS
Priority: $PRIORITY
Section: other
Installed-Size: 42
@@ -724,6 +726,21 @@ server.stat-cache-engine = \"disable\"" > lighttpd.conf
return 0
}
+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 -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
+ ln -s "$(readlink -f ./incoming)" $CD/pool
+ find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list' -delete
+}
+
checkdiff() {
local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
if [ -n "$DIFFTEXT" ]; then
diff --git a/test/integration/test-apt-cdrom b/test/integration/test-apt-cdrom
new file mode 100755
index 000000000..f24c99b36
--- /dev/null
+++ b/test/integration/test-apt-cdrom
@@ -0,0 +1,104 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+buildsimplenativepackage 'testing' 'amd64,i386' '0.8.15' 'stable'
+setupaptarchive
+
+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
+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
+cat Translation-de | gzip > Translation-de.gz
+cat Translation-de | bzip2 > Translation-de.bz2
+cat Translation-de | xz --format=lzma > Translation-de.lzma
+cat Translation-de | xz > Translation-de.xz
+rm Translation-en Translation-de
+cd - > /dev/null
+
+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..
+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:
+'Debian APT Testdisk 0.8.15'
+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."
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ testing
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst testing (0.8.15 stable [amd64])
+Conf testing (0.8.15 stable [amd64])' aptget install testing -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ testing:i386
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+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..
+Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
+This disc is called:
+'Debian APT Testdisk 0.8.15'
+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."
+
+# 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..
+Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
+This disc is called:
+'Debian APT Testdisk 0.8.15'
+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."
+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..
+Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
+This disc is called:
+'Debian APT Testdisk 0.8.15'
+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."
+msgtest 'Test for the english description translation of' 'testing'
+aptcache show testing -o Acquire::Languages=en | grep -q '^Description-en: ' && msgpass || msgfail
+
+
+# check that we really can install from a 'cdrom'
+testdpkgnotinstalled testing
+aptget install testing -y > /dev/null 2>&1
+testdpkginstalled testing
diff --git a/test/integration/test-unpack-different-version-unpacked b/test/integration/test-unpack-different-version-unpacked
new file mode 100755
index 000000000..952f6e6b2
--- /dev/null
+++ b/test/integration/test-unpack-different-version-unpacked
@@ -0,0 +1,121 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertpackage 'unstable' 'libqtcore4' 'i386,amd64' '2' 'Multi-Arch: same'
+setupaptarchive
+
+DPKGSTATUS='rootdir/var/lib/dpkg/status'
+cp $DPKGSTATUS dpkg.status
+
+cleanstatus() {
+ cp dpkg.status $DPKGSTATUS
+ rm rootdir/var/cache/apt/*.bin
+}
+
+#FIXME: the reported version is wrong, it should be 1, not 2
+insertinstalledpackage 'libqtcore4' 'i386,amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
+2 not fully installed or removed.
+Conf libqtcore4 (2 unstable [amd64])
+Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same' '' 'install ok unpacked'
+insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4:i386
+The following packages will be upgraded:
+ libqtcore4:i386
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+2 not fully installed or removed.
+Inst libqtcore4:i386 [1] (2 unstable [i386])
+Conf libqtcore4:i386 (2 unstable [i386])
+Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same' '' 'install ok unpacked'
+insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4
+The following packages will be upgraded:
+ libqtcore4
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+2 not fully installed or removed.
+Inst libqtcore4 [1] (2 unstable [amd64])
+Conf libqtcore4 (2 unstable [amd64])
+Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same' '' 'install ok unpacked'
+insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4:i386
+The following packages will be upgraded:
+ libqtcore4:i386
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+1 not fully installed or removed.
+Inst libqtcore4:i386 [1] (2 unstable [i386])
+Conf libqtcore4:i386 (2 unstable [i386])
+Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same' '' 'install ok unpacked'
+insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4
+The following packages will be upgraded:
+ libqtcore4
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+1 not fully installed or removed.
+Inst libqtcore4 [1] (2 unstable [amd64])
+Conf libqtcore4 (2 unstable [amd64])
+Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same'
+insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4:i386
+The following packages will be upgraded:
+ libqtcore4:i386
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+1 not fully installed or removed.
+Inst libqtcore4:i386 [1] (2 unstable [i386])
+Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same'
+insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4
+The following packages will be upgraded:
+ libqtcore4
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+1 not fully installed or removed.
+Inst libqtcore4 [1] (2 unstable [amd64])
+Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f
diff --git a/test/libapt/cdromreducesourcelist_test.cc b/test/libapt/cdromreducesourcelist_test.cc
new file mode 100644
index 000000000..729da23a6
--- /dev/null
+++ b/test/libapt/cdromreducesourcelist_test.cc
@@ -0,0 +1,86 @@
+#include <apt-pkg/cdrom.h>
+#include <apt-pkg/error.h>
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+#include "assert.h"
+
+class Cdrom : public pkgCdrom {
+public:
+ std::vector<std::string> ReduceSourcelist(std::string CD,std::vector<std::string> List) {
+ pkgCdrom::ReduceSourcelist(CD, List);
+ return List;
+ }
+};
+
+int main(int argc, char const *argv[]) {
+ Cdrom cd;
+ std::vector<std::string> List;
+ std::string CD("/media/cdrom/");
+
+ std::vector<std::string> R = cd.ReduceSourcelist(CD, List);
+ equals(R.empty(), true);
+
+ List.push_back(" wheezy main");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 1);
+ equals(R[0], " wheezy main");
+
+ List.push_back(" wheezy main");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 1);
+ equals(R[0], " wheezy main");
+
+ List.push_back(" wheezy contrib");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 1);
+ equals(R[0], " wheezy contrib main");
+
+ List.push_back(" wheezy-update contrib");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main");
+ equals(R[1], " wheezy-update contrib");
+
+ List.push_back(" wheezy-update contrib");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main");
+ equals(R[1], " wheezy-update contrib");
+
+ List.push_back(" wheezy-update non-free");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main");
+ equals(R[1], " wheezy-update contrib non-free");
+
+ List.push_back(" wheezy-update main");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main");
+ equals(R[1], " wheezy-update contrib main non-free");
+
+ List.push_back(" wheezy non-free");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main non-free");
+ equals(R[1], " wheezy-update contrib main non-free");
+
+ List.push_back(" sid main");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 3);
+ equals(R[0], " sid main");
+ equals(R[1], " wheezy contrib main non-free");
+ equals(R[2], " wheezy-update contrib main non-free");
+
+ List.push_back(" sid main-reduce");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 3);
+ equals(R[0], " sid main main-reduce");
+ equals(R[1], " wheezy contrib main non-free");
+ equals(R[2], " wheezy-update contrib main non-free");
+
+ return 0;
+}
diff --git a/test/libapt/indexcopytosourcelist_test.cc b/test/libapt/indexcopytosourcelist_test.cc
new file mode 100644
index 000000000..69d8fae86
--- /dev/null
+++ b/test/libapt/indexcopytosourcelist_test.cc
@@ -0,0 +1,86 @@
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/indexcopy.h>
+
+#include <string>
+
+#include "assert.h"
+
+class NoCopy : public IndexCopy {
+public:
+ std::string ConvertToSourceList(std::string CD,std::string Path) {
+ 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; }
+ const char *GetFileName() { return NULL; }
+ const char *Type() { return NULL; }
+
+};
+
+int main(int argc, char const *argv[]) {
+ NoCopy ic;
+ std::string const CD("/media/cdrom/");
+
+ char const * Releases[] = { "unstable", "wheezy-updates", NULL };
+ char const * Components[] = { "main", "non-free", NULL };
+
+ for (char const ** Release = Releases; *Release != NULL; ++Release) {
+ for (char const ** Component = Components; *Component != NULL; ++Component) {
+ std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/";
+ std::string const Binary = Path + "binary-";
+ std::string const A = Binary + "armel/";
+ std::string const B = Binary + "mips/";
+ std::string const C = Binary + "kfreebsd-mips/";
+ std::string const S = Path + "source/";
+ std::string const List = std::string(*Release) + " " + *Component;
+
+ _config->Clear("APT");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "mips");
+ _config->Set("APT::Architectures::", "mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "kfreebsd-mips");
+ _config->Set("APT::Architectures::", "kfreebsd-mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "armel");
+ _config->Set("APT::Architectures::", "armel");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "armel");
+ _config->Set("APT::Architectures::", "armel");
+ _config->Set("APT::Architectures::", "mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
index b2e6db2dd..5e225f240 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -86,3 +86,15 @@ PROGRAM = CdromFindPackages${BASENAME}
SLIBS = -lapt-pkg
SOURCE = cdromfindpackages_test.cc
include $(PROGRAM_H)
+
+# test cdroms index reduction for source.list
+PROGRAM = CdromReduceSourceList${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = cdromreducesourcelist_test.cc
+include $(PROGRAM_H)
+
+# text IndexCopy::ConvertToSourceList
+PROGRAM = IndexCopyToSourceList${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = indexcopytosourcelist_test.cc
+include $(PROGRAM_H)