summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework27
-rwxr-xr-xtest/integration/skip-aptwebserver25
-rwxr-xr-xtest/integration/test-apt-cli-search7
-rwxr-xr-xtest/integration/test-apt-get-changelog3
-rwxr-xr-xtest/integration/test-bug-666772-multiarch-arch-all-build-deps118
-rwxr-xr-xtest/integration/test-bug-683786-build-dep-on-virtual-packages10
-rwxr-xr-xtest/integration/test-failing-maintainer-scripts2
-rw-r--r--test/libapt/fileutl_test.cc31
-rw-r--r--test/libapt/install_progress_test.cc30
-rw-r--r--test/libapt/makefile6
10 files changed, 252 insertions, 7 deletions
diff --git a/test/integration/framework b/test/integration/framework
index fae21eac4..eda3cebad 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -193,7 +193,13 @@ 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
+ # use the autoremove from the BUILDDIRECTORY if its there, otherwise
+ # system
+ if [ -e ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove ]; then
+ ln -s ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove etc/apt/apt.conf.d/01autoremove
+ else
+ ln -s /etc/apt/apt.conf.d/01autoremove etc/apt/apt.conf.d/01autoremove
+ fi
cd ..
local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
@@ -882,6 +888,20 @@ rewritesourceslist() {
done
}
+# wait for up to 10s for a pid file to appear to avoid possible race
+# when a helper is started and dosn't write the PID quick enough
+waitforpidfile() {
+ local PIDFILE="$1"
+ for i in $(seq 10); do
+ if test -s "$PIDFILE"; then
+ return 0
+ fi
+ sleep 1
+ done
+ msgdie "waiting for $PIDFILE failed"
+ return 1
+}
+
changetowebserver() {
if [ "$1" != '--no-rewrite' ]; then
rewritesourceslist 'http://localhost:8080/'
@@ -895,6 +915,7 @@ changetowebserver() {
cat $LOG
false
fi
+ waitforpidfile aptwebserver.pid
local PID="$(cat aptwebserver.pid)"
if [ -z "$PID" ]; then
msgdie 'Could not fork aptwebserver successfully'
@@ -922,7 +943,11 @@ accept = 4433
connect = 8080
" > ${TMPWORKINGDIRECTORY}/stunnel.conf
stunnel4 "${TMPWORKINGDIRECTORY}/stunnel.conf"
+ waitforpidfile "${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
local PID="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
+ if [ -z "$PID" ]; then
+ msgdie 'Could not fork stunnel4 successfully'
+ fi
addtrap 'prefix' "kill ${PID};"
rewritesourceslist 'https://localhost:4433/'
}
diff --git a/test/integration/skip-aptwebserver b/test/integration/skip-aptwebserver
new file mode 100755
index 000000000..0622941ce
--- /dev/null
+++ b/test/integration/skip-aptwebserver
@@ -0,0 +1,25 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64'
+
+buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
+
+setupaptarchive
+changetowebserver
+
+rm -rf rootdir/var/lib/apt/lists
+aptget update -qq
+testequal 'Hit http://localhost stable InRelease
+Hit http://localhost stable/main Sources
+Hit http://localhost stable/main amd64 Packages
+Hit http://localhost stable/main Translation-en
+Reading package lists...' aptget update
+
+mv rootdir/var/lib/apt/lists/localhost* rootdir/var/lib/apt/lists/partial
+aptget update
+
diff --git a/test/integration/test-apt-cli-search b/test/integration/test-apt-cli-search
index 84650b366..58613717b 100755
--- a/test/integration/test-apt-cli-search
+++ b/test/integration/test-apt-cli-search
@@ -13,7 +13,7 @@ if [ ! -x ${BUILDDIRECTORY}/apt ]; then
exit 0
fi
-DESCR='Some description that has a unusual word xxyyzz and aabbcc'
+DESCR='Some description that has a unusual word xxyyzz and aabbcc and a UPPERCASE'
DESCR2='Some other description with the unusual aabbcc only'
insertpackage 'unstable' 'foo' 'all' '1.0' '' '' "$DESCR"
insertpackage 'testing' 'bar' 'i386' '2.0' '' '' "$DESCR2"
@@ -39,6 +39,11 @@ testequal "foo/unstable 1.0 all
$DESCR
" apt search -qq aabbcc xxyyzz
+# search is not case-sensitive by default
+testequal "foo/unstable 1.0 all
+ $DESCR
+" apt search -qq uppercase
+
# output is sorted and search word finds both package
testequal "bar/testing 2.0 i386
$DESCR2
diff --git a/test/integration/test-apt-get-changelog b/test/integration/test-apt-get-changelog
index a73c3e249..d64a09bd6 100755
--- a/test/integration/test-apt-get-changelog
+++ b/test/integration/test-apt-get-changelog
@@ -36,4 +36,5 @@ testsuccess aptget changelog apt -d
testfileequal 'apt.changelog' "$(cat aptarchive/pool/apt_1.0.changelog)"
rm apt.changelog aptarchive/pool/apt_1.0.changelog
-testequal 'E: changelog download failed' aptget changelog apt -qq -o APT::Changelogs::Server='http://not-on-the-main-server:8080/'
+# note that this output is different on ubuntu and debian
+testequal 'E: changelog for this version is not (yet) available; try https://launchpad.net/ubuntu/+source/apt/+changelog' aptget changelog apt -qq -o APT::Changelogs::Server='http://not-on-the-main-server:8080/'
diff --git a/test/integration/test-bug-666772-multiarch-arch-all-build-deps b/test/integration/test-bug-666772-multiarch-arch-all-build-deps
new file mode 100755
index 000000000..cfae1fef3
--- /dev/null
+++ b/test/integration/test-bug-666772-multiarch-arch-all-build-deps
@@ -0,0 +1,118 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'armhf'
+
+insertinstalledpackage 'build-essential' 'all' '11.5'
+
+insertpackage 'unstable' 'doxygen' 'all' '1.0' 'Depends: language-support, language-tool'
+insertpackage 'unstable' 'libc6' 'amd64,armhf' '1.0' 'Multi-Arch: same'
+insertpackage 'unstable' 'libc6-dev' 'amd64,armhf' '1.0' 'Depends: libc6
+Multi-Arch: same'
+insertpackage 'unstable' 'language-support' 'amd64,armhf' '1.0' 'Multi-Arch: foreign'
+insertpackage 'unstable' 'language-tool' 'amd64,armhf' '1.0'
+
+insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ doxygen language-support language-tool libc6 libc6-dev
+0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
+Inst language-support (1.0 unstable [amd64])
+Inst language-tool (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [all])
+Inst libc6 (1.0 unstable [amd64])
+Inst libc6-dev (1.0 unstable [amd64])
+Conf language-support (1.0 unstable [amd64])
+Conf language-tool (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [all])
+Conf libc6 (1.0 unstable [amd64])
+Conf libc6-dev (1.0 unstable [amd64])' aptget build-dep apt -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ doxygen language-support language-tool libc6:armhf libc6-dev:armhf
+0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
+Inst language-support (1.0 unstable [amd64])
+Inst language-tool (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [all])
+Inst libc6:armhf (1.0 unstable [armhf])
+Inst libc6-dev:armhf (1.0 unstable [armhf])
+Conf language-support (1.0 unstable [amd64])
+Conf language-tool (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [all])
+Conf libc6:armhf (1.0 unstable [armhf])
+Conf libc6-dev:armhf (1.0 unstable [armhf])' aptget build-dep apt -s -a armhf
+
+configarchitecture 'armhf' 'amd64'
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ doxygen language-support language-tool libc6 libc6-dev
+0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
+Inst language-support (1.0 unstable [armhf])
+Inst language-tool (1.0 unstable [armhf])
+Inst doxygen (1.0 unstable [all])
+Inst libc6 (1.0 unstable [armhf])
+Inst libc6-dev (1.0 unstable [armhf])
+Conf language-support (1.0 unstable [armhf])
+Conf language-tool (1.0 unstable [armhf])
+Conf doxygen (1.0 unstable [all])
+Conf libc6 (1.0 unstable [armhf])
+Conf libc6-dev (1.0 unstable [armhf])' aptget build-dep apt -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ doxygen language-support language-tool libc6:amd64 libc6-dev:amd64
+0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
+Inst language-support (1.0 unstable [armhf])
+Inst language-tool (1.0 unstable [armhf])
+Inst doxygen (1.0 unstable [all])
+Inst libc6:amd64 (1.0 unstable [amd64])
+Inst libc6-dev:amd64 (1.0 unstable [amd64])
+Conf language-support (1.0 unstable [armhf])
+Conf language-tool (1.0 unstable [armhf])
+Conf doxygen (1.0 unstable [all])
+Conf libc6:amd64 (1.0 unstable [amd64])
+Conf libc6-dev:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64
+
+configarchitecture 'amd64' 'armhf'
+
+insertinstalledpackage 'language-support' 'armhf' '0.5' 'Multi-Arch: foreign'
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ doxygen language-tool libc6 libc6-dev
+0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
+Inst language-tool (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [all])
+Inst libc6 (1.0 unstable [amd64])
+Inst libc6-dev (1.0 unstable [amd64])
+Conf language-tool (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [all])
+Conf libc6 (1.0 unstable [amd64])
+Conf libc6-dev (1.0 unstable [amd64])' aptget build-dep apt -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ doxygen language-tool libc6:armhf libc6-dev:armhf
+0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
+Inst language-tool (1.0 unstable [amd64])
+Inst doxygen (1.0 unstable [all])
+Inst libc6:armhf (1.0 unstable [armhf])
+Inst libc6-dev:armhf (1.0 unstable [armhf])
+Conf language-tool (1.0 unstable [amd64])
+Conf doxygen (1.0 unstable [all])
+Conf libc6:armhf (1.0 unstable [armhf])
+Conf libc6-dev:armhf (1.0 unstable [armhf])' aptget build-dep apt -s -a armhf
diff --git a/test/integration/test-bug-683786-build-dep-on-virtual-packages b/test/integration/test-bug-683786-build-dep-on-virtual-packages
index 879d6a3bc..c839a0fe6 100755
--- a/test/integration/test-bug-683786-build-dep-on-virtual-packages
+++ b/test/integration/test-bug-683786-build-dep-on-virtual-packages
@@ -41,9 +41,13 @@ The following NEW packages will be installed:
Inst po-debconf (1 unstable, unstable [all])
Conf po-debconf (1 unstable, unstable [all])' aptget build-dep dash -s
-testequal 'Reading package lists...
-Building dependency tree...
-E: Build-Depends dependency for dash cannot be satisfied because the package po-debconf cannot be found' aptget build-dep -aarmel dash -s
+# ubuntu has the patch from
+# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666772
+# applied so the following test works in the ubuntu/master branch
+#
+#testequal 'Reading package lists...
+#Building dependency tree...
+#E: Build-Depends dependency for dash cannot be satisfied because the package po-debconf cannot be found' aptget build-dep -aarmel dash -s
testequal 'Reading package lists...
Building dependency tree...
diff --git a/test/integration/test-failing-maintainer-scripts b/test/integration/test-failing-maintainer-scripts
index cb82ebc7a..3dd7d643e 100755
--- a/test/integration/test-failing-maintainer-scripts
+++ b/test/integration/test-failing-maintainer-scripts
@@ -86,7 +86,7 @@ testmyfailure() {
testfailure "$@" -o APT::Status-Fd=3
msgtest 'Test for failure message of maintainerscript in' 'console log'
local TEST='rootdir/tmp/testfailure.output'
- if grep -q 'exit status 29$' "$TEST"; then
+ if grep -q 'exit status 29' "$TEST"; then
msgpass
else
cat $TEST
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc
index 8da832ba9..1d1a1a1b8 100644
--- a/test/libapt/fileutl_test.cc
+++ b/test/libapt/fileutl_test.cc
@@ -6,13 +6,44 @@
#include <string>
#include <vector>
#include <stdlib.h>
+#include <sys/stat.h>
#include "assert.h"
+// regression test for permission bug LP: #1304657
+static bool
+TestFileFdOpenPermissions(mode_t a_umask, mode_t ExpectedFilePermission)
+{
+ FileFd f;
+ struct stat buf;
+ static const char* fname = "test.txt";
+
+ umask(a_umask);
+ f.Open(fname, FileFd::ReadWrite|FileFd::Atomic);
+ f.Close();
+ if (stat(fname, &buf) < 0)
+ {
+ _error->Errno("stat", "failed to stat");
+ _error->DumpErrors();
+ return false;
+ }
+ unlink(fname);
+ equals(buf.st_mode & 0777, ExpectedFilePermission);
+ return true;
+}
+
int main()
{
std::vector<std::string> files;
+ if (TestFileFdOpenPermissions(0002, 0664) == false ||
+ TestFileFdOpenPermissions(0022, 0644) == false ||
+ TestFileFdOpenPermissions(0077, 0600) == false ||
+ TestFileFdOpenPermissions(0026, 0640) == false)
+ {
+ return 1;
+ }
+
// normal match
files = Glob("*.lst");
if (files.size() != 1)
diff --git a/test/libapt/install_progress_test.cc b/test/libapt/install_progress_test.cc
new file mode 100644
index 000000000..be1a3411e
--- /dev/null
+++ b/test/libapt/install_progress_test.cc
@@ -0,0 +1,30 @@
+#include <config.h>
+
+#include <apt-pkg/install-progress.h>
+
+#include <string>
+
+#include "assert.h"
+
+int main() {
+ APT::Progress::PackageManagerFancy p;
+ std::string s;
+
+ s= p.GetTextProgressStr(0.5, 60);
+ equals(s.size(), 60);
+
+ s= p.GetTextProgressStr(0.5, 4);
+ equals(s, "[#.]");
+
+ s= p.GetTextProgressStr(0.1, 12);
+ equals(s, "[#.........]");
+
+ s= p.GetTextProgressStr(0.9, 12);
+ equals(s, "[#########.]");
+
+ // deal with incorrect inputs gracefully (or should we die instead?)
+ s= p.GetTextProgressStr(-999, 12);
+ equals(s, "");
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
index 66d6ea783..e03b5e6aa 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -123,3 +123,9 @@ SLIBS = -lapt-pkg
SOURCE = sourcelist_test.cc
include $(PROGRAM_H)
+# test install-progress
+PROGRAM = InstallProgress${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = install_progress_test.cc
+include $(PROGRAM_H)
+