summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework3
-rwxr-xr-xtest/integration/skip-aptwebserver25
-rwxr-xr-xtest/integration/test-bug-602412-dequote-redirect5
-rwxr-xr-xtest/integration/test-bug-683786-build-dep-on-virtual-packages4
-rwxr-xr-xtest/integration/test-debsrc-hashes77
-rwxr-xr-xtest/integration/test-ubuntu-bug-346386-apt-get-update-paywall2
-rw-r--r--test/interactive-helper/makefile2
-rw-r--r--test/libapt/fileutl_test.cc58
8 files changed, 170 insertions, 6 deletions
diff --git a/test/integration/framework b/test/integration/framework
index eda3cebad..ab1274d9c 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -244,7 +244,8 @@ 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"
+ # prefer our apt binaries over the system apt binaries
+ export PATH="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
export LC_ALL=C.UTF-8
unset LANGUAGE APT_CONFIG
unset GREP_OPTIONS DEB_BUILD_PROFILES
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-bug-602412-dequote-redirect b/test/integration/test-bug-602412-dequote-redirect
index 6393f0c27..4901a32d7 100755
--- a/test/integration/test-bug-602412-dequote-redirect
+++ b/test/integration/test-bug-602412-dequote-redirect
@@ -20,11 +20,14 @@ testrun() {
testsuccess --nomsg aptget update
# check that I-M-S header is kept in redirections
+ local LOG='update.log'
+ # strip away the [ 304 B ] info
+ aptget update 2>&1 | sed -e 's/\ \[.*//' > $LOG
testequal "Hit $1 unstable InRelease
Hit $1 unstable/main Sources
Hit $1 unstable/main amd64 Packages
Hit $1 unstable/main Translation-en
-Reading package lists..." aptget update
+Reading package lists..." cat $LOG
msgtest 'Test redirection works in' 'package download'
testsuccess --nomsg aptget install unrelated --download-only -y
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..65862c572 100755
--- a/test/integration/test-bug-683786-build-dep-on-virtual-packages
+++ b/test/integration/test-bug-683786-build-dep-on-virtual-packages
@@ -38,8 +38,8 @@ Building dependency tree...
The following NEW packages will be installed:
po-debconf
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
-Inst po-debconf (1 unstable, unstable [all])
-Conf po-debconf (1 unstable, unstable [all])' aptget build-dep dash -s
+Inst po-debconf (1 unstable [all])
+Conf po-debconf (1 unstable [all])' aptget build-dep dash -s
testequal 'Reading package lists...
Building dependency tree...
diff --git a/test/integration/test-debsrc-hashes b/test/integration/test-debsrc-hashes
new file mode 100755
index 000000000..5e917232b
--- /dev/null
+++ b/test/integration/test-debsrc-hashes
@@ -0,0 +1,77 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+# pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
+# checking the best available hash (as it should), this will trigger
+# a hash mismatch.
+
+cat > aptarchive/Sources <<EOF
+Package: pkg-md5-ok
+Binary: pkg-md5-ok
+Version: 1.0
+Maintainer: Joe Sixpack <joe@example.org>
+Architecture: i386
+Files:
+ d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.tar.gz
+
+Package: pkg-sha256-ok
+Binary: pkg-sha256-ok
+Version: 1.0
+Maintainer: Joe Sixpack <joe@example.org>
+Architecture: i386
+Files:
+ d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.tar.gz
+Checksums-Sha1:
+ da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.dsc
+ da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.tar.gz
+Checksums-Sha256:
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.dsc
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.tar.gz
+
+Package: pkg-sha256-bad
+Binary: pkg-sha256-bad
+Version: 1.0
+Maintainer: Joe Sixpack <joe@example.org>
+Architecture: i386
+Files:
+ d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.tar.gz
+Checksums-Sha1:
+ da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.dsc
+ da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.tar.gz
+Checksums-Sha256:
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0 pkg-sha256-bad_1.0.dsc
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0 pkg-sha256-bad_1.0.tar.gz
+EOF
+
+# create fetchable files
+for x in "pkg-md5-ok" "pkg-sha256-ok" "pkg-sha256-bad"; do
+ touch aptarchive/${x}_1.0.dsc
+ touch aptarchive/${x}_1.0.tar.gz
+done
+
+testok() {
+ msgtest "Test for hash ok of" "$*"
+ $* 2>&1 | grep "Download complete" > /dev/null && msgpass || msgfail
+}
+
+testmismatch() {
+ msgtest "Test for hash mismatch of" "$*"
+ $* 2>&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail
+}
+
+setupaptarchive
+changetowebserver
+aptget update -qq
+
+testok aptget source -d pkg-md5-ok
+testok aptget source -d pkg-sha256-ok
+testmismatch aptget source -d pkg-sha256-bad
diff --git a/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall b/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
index 7112d2b45..1a7db0adc 100755
--- a/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
+++ b/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
@@ -22,7 +22,7 @@ Config-Item: Acquire::http::DependOnSTDIN=0
600 Acquire URI
URI: http://localhost:8080/holygrail
Filename: knights-talking
-' | ${METHODSDIR}/http >/dev/null 2>&1 && msgpass || msgfail
+' | LD_LIBRARY_PATH=${BUILDDIRECTORY} ${METHODSDIR}/http >/dev/null 2>&1 && msgpass || msgfail
testfileequal knights-talking 'ni ni ni'
ensure_n_canary_strings_in_dir() {
diff --git a/test/interactive-helper/makefile b/test/interactive-helper/makefile
index 8dc014b98..4633b78ce 100644
--- a/test/interactive-helper/makefile
+++ b/test/interactive-helper/makefile
@@ -39,7 +39,7 @@ include $(PROGRAM_H)
#SOURCE = rpmver.cc
#include $(PROGRAM_H)
-# Program for testing udevcdrom
+# very simple webserver for APT testing
PROGRAM=aptwebserver
SLIBS = -lapt-pkg -lpthread
LIB_MAKES = apt-pkg/makefile
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc
index 643c02297..cdf7ea479 100644
--- a/test/libapt/fileutl_test.cc
+++ b/test/libapt/fileutl_test.cc
@@ -224,3 +224,61 @@ TEST(FileUtlTest, GetTempDir)
if (old_tmpdir.empty() == false)
setenv("TMPDIR", old_tmpdir.c_str(), 1);
}
+TEST(FileUtlTest, Popen)
+{
+ FileFd Fd;
+ pid_t Child;
+ char buf[1024];
+ std::string s;
+ unsigned long long n = 0;
+ std::vector<std::string> OpenFds;
+
+ // count Fds to ensure we don't have a resource leak
+ if(FileExists("/proc/self/fd"))
+ OpenFds = Glob("/proc/self/fd/*");
+
+ // output something
+ const char* Args[10] = {"/bin/echo", "meepmeep", NULL};
+ bool res = Popen(Args, Fd, Child, FileFd::ReadOnly);
+ Fd.Read(buf, sizeof(buf)-1, &n);
+ buf[n] = 0;
+ EXPECT_NE(n, 0);
+ EXPECT_EQ(res, true);
+ EXPECT_STREQ(buf, "meepmeep\n");
+
+ // wait for the child to exit and cleanup
+ ExecWait(Child, "PopenRead");
+ Fd.Close();
+
+ // ensure that after a close all is good again
+ if(FileExists("/proc/self/fd"))
+ EXPECT_EQ(Glob("/proc/self/fd/*").size(), OpenFds.size());
+
+
+ // ReadWrite is not supported
+ res = Popen(Args, Fd, Child, FileFd::ReadWrite);
+ EXPECT_EQ(res, false);
+ _error->Discard();
+
+ // write something
+ Args[0] = "/bin/bash";
+ Args[1] = "-c";
+ Args[2] = "read";
+ Args[3] = NULL;
+ res = Popen(Args, Fd, Child, FileFd::WriteOnly);
+ s = "\n";
+ Fd.Write(s.c_str(), s.size());
+ Fd.Close();
+ ExecWait(Child, "PopenWrite");
+}
+TEST(FileUtlTest, flAbsPath)
+{
+ std::string cwd = SafeGetCWD();
+ int res = chdir("/bin/");
+ EXPECT_EQ(res, 0);
+ std::string p = flAbsPath("ls");
+ EXPECT_EQ(p, "/bin/ls");
+
+ res = chdir(cwd.c_str());
+ EXPECT_EQ(res, 0);
+}