summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework8
-rwxr-xr-xtest/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch94
-rw-r--r--test/libapt/configuration_test.cc4
-rw-r--r--test/libapt/fileutl_test.cc42
-rw-r--r--test/libapt/makefile5
-rwxr-xr-xtest/libapt/run-tests20
6 files changed, 122 insertions, 51 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 72c899e32..54d35fef8 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -88,11 +88,11 @@ msgdone() {
runapt() {
msgdebug "Executing: ${CCMD}$*${CDEBUG} "
if [ -f ./aptconfig.conf ]; then
- APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
- elif [ -f ../aptconfig.conf ]; then
- APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+ elif [ -f ../aptconfig.conf ]; then
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
else
- LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
fi
}
aptconfig() { runapt apt-config $*; }
diff --git a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
index af65397ea..62355a6b5 100755
--- a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
+++ b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
@@ -26,95 +26,111 @@ hook='pre-install-pkgs'
enablehookversion() {
echo "#!/bin/sh
-while read line; do
+FD=0
+echo -n > ${hook}-v${1}.list
+if [ -n \"${2}\" ]; then
+ FD=\$APT_HOOK_INFO_FD
+ if [ "\$FD" != \"${2}\" ]; then echo \"ERROR: Information is not on requested FD: \$FD != ${2}\" >> ${hook}-v${1}.list; fi
+fi
+while read </proc/\$\$/fd/\$FD line; do
if echo \"\$line\" | grep -Fq '**'; then
echo \"\$line\"
fi
-done > ${hook}-v${1}.list" > ${hook}-v${1}.sh
+done >> ${hook}-v${1}.list" > ${hook}-v${1}.sh
chmod +x ${hook}-v${1}.sh
echo "dpkg::${hook}:: \"./${hook}-v${1}.sh --foo -bar\";
DPkg::Tools::options::\"./${hook}-v${1}.sh\"::Version \"$1\";" > rootdir/etc/apt/apt.conf.d/hook-v$1
+ if [ -n "$2" ]; then
+ echo "DPkg::Tools::options::\"./${hook}-v${1}.sh\"::InfoFD \"${2}\";" >> rootdir/etc/apt/apt.conf.d/hook-v$1
+ fi
}
-enablehookversion 2
-enablehookversion 3
-
observehook() {
rm -f ${hook}-v2.list ${hook}-v3.list
msgtest 'Observe hooks while' "$*"
testsuccess --nomsg aptget "$@" -y --force-yes
}
-observehook install stuff -t stable
-testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE**
+testrun() {
+ observehook install stuff -t stable
+ testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE**
toolkit - < 1 **CONFIGURE**
stuff - < 1 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE**
+ testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE**
toolkit - - none < 1 all foreign **CONFIGURE**
stuff - - none < 1 amd64 none **CONFIGURE**'
-observehook install stuff -t unstable
-testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
+ observehook install stuff -t unstable
+ testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
toolkit 1 < 2 **CONFIGURE**
stuff 1 < 2 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE**
+ testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE**
toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**
stuff 1 amd64 none < 2 amd64 none **CONFIGURE**'
-observehook install stuff:i386 -t unstable
-testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE**
+ observehook install stuff:i386 -t unstable
+ testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE**
libsame - < 2 **CONFIGURE**
stuff - < 2 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE**
+ testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE**
libsame - - none < 2 i386 same **CONFIGURE**
stuff - - none < 2 i386 none **CONFIGURE**'
-observehook remove libsame
-testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**'
-testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**'
+ observehook remove libsame
+ testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**'
+ testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**'
-observehook install stuff:i386/stable libsame:i386/stable toolkit/stable
-testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE**
+ observehook install stuff:i386/stable libsame:i386/stable toolkit/stable
+ testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE**
toolkit 2 > 1 **CONFIGURE**
stuff 2 > 1 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE**
+ testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE**
toolkit 2 amd64 foreign > 1 all foreign **CONFIGURE**
stuff 2 i386 none > 1 i386 none **CONFIGURE**'
-observehook install 'libsame:*'
-testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
+ observehook install 'libsame:*'
+ testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
libsame - < 2 **CONFIGURE**
toolkit 1 < 2 **CONFIGURE**
stuff 1 < 2 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE**
+ testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE**
libsame - - none < 2 amd64 same **CONFIGURE**
toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**
stuff 1 i386 none < 2 i386 none **CONFIGURE**'
-observehook purge stuff:i386 'libsame:*' toolkit
-testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**
+ observehook purge stuff:i386 'libsame:*' toolkit
+ testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**
stuff 2 > - **REMOVE**
libsame 2 > - **REMOVE**
toolkit 2 > - **REMOVE**'
-testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**
+ testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**
stuff 2 i386 none > - - none **REMOVE**
libsame 2 i386 same > - - none **REMOVE**
toolkit 2 amd64 foreign > - - none **REMOVE**'
-observehook install confpkg
-testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**'
+ observehook install confpkg
+ testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**'
+ testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**'
+
+ observehook remove confpkg
+ testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
+ testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
-observehook remove confpkg
-testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
-testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
+ msgtest 'Conffiles of package remained after remove' 'confpkg'
+ dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail
-msgtest 'Conffiles of package remained after remove' 'confpkg'
-dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail
+ observehook purge confpkg
+ testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
+ testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
-observehook purge confpkg
-testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
-testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
+ msgtest 'Conffiles are gone after purge' 'confpkg'
+ dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass
+}
+
+enablehookversion 2
+enablehookversion 3
+testrun
-msgtest 'Conffiles are gone after purge' 'confpkg'
-dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass
+enablehookversion 2 13
+enablehookversion 3 13
+testrun
diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc
index 87d5699ef..2c974ee0a 100644
--- a/test/libapt/configuration_test.cc
+++ b/test/libapt/configuration_test.cc
@@ -98,6 +98,10 @@ 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"), "");
+
//FIXME: Test for configuration file parsing;
// currently only integration/ tests test them implicitly
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc
new file mode 100644
index 000000000..b6b8ac579
--- /dev/null
+++ b/test/libapt/fileutl_test.cc
@@ -0,0 +1,42 @@
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+
+#include "assert.h"
+#include <string>
+#include <vector>
+
+#include <stdio.h>
+#include <iostream>
+#include <stdlib.h>
+
+
+int main(int argc,char *argv[])
+{
+ std::vector<std::string> files;
+
+ // normal match
+ files = Glob("*.lst");
+ if (files.size() != 1)
+ {
+ _error->DumpErrors();
+ return 1;
+ }
+
+ // not there
+ files = Glob("xxxyyyzzz");
+ if (files.size() != 0 || _error->PendingError())
+ {
+ _error->DumpErrors();
+ return 1;
+ }
+
+ // many matches (number is a bit random)
+ files = Glob("*.cc");
+ if (files.size() < 10)
+ {
+ _error->DumpErrors();
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
index 1b67cba9d..73403b24c 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -98,6 +98,11 @@ include $(PROGRAM_H)
PROGRAM = IndexCopyToSourceList${BASENAME}
SLIBS = -lapt-pkg
SOURCE = indexcopytosourcelist_test.cc
+
+# test fileutls
+PROGRAM = FileUtl${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = fileutl_test.cc
include $(PROGRAM_H)
# test tagfile
diff --git a/test/libapt/run-tests b/test/libapt/run-tests
index f18be6d2b..a056f31f9 100755
--- a/test/libapt/run-tests
+++ b/test/libapt/run-tests
@@ -2,9 +2,11 @@
set -e
DIR=$(readlink -f $(dirname $0))
-echo "Compiling the tests …"
-(cd $DIR && make)
-echo "Running all testcases …"
+if [ -z "$MAKELEVEL" ]; then
+ echo 'Compiling the tests …'
+ (cd $DIR && make)
+ echo 'Running all testcases …'
+fi
LDPATH="$DIR/../../build/bin"
EXT="_libapt_test"
EXIT_CODE=0
@@ -70,9 +72,11 @@ do
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tlh%5fDE"
elif [ $name = "HashSums${EXT}" ]; then
TMP="$(readlink -f "./${0}")"
- echo -n "Testing with ${NAME} "
- LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "$TESTOKAY" || echo "$TESTFAIL"
- continue
+ tmppath="$TMP"
+ tmppath="${tmppath} $(md5sum $TMP | cut -d' ' -f 1)"
+ tmppath="${tmppath} $(sha1sum $TMP | cut -d' ' -f 1)"
+ tmppath="${tmppath} $(sha256sum $TMP | cut -d' ' -f 1)"
+ tmppath="${tmppath} $(sha512sum $TMP | cut -d' ' -f 1)"
elif [ $name = "CompareVersion${EXT}" ]; then
tmppath="${DIR}/versions.lst"
elif [ $name = "CdromFindPackages${EXT}" ]; then
@@ -107,8 +111,8 @@ do
fi
echo -n "Testing with ${NAME} "
- if LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then
- echo "$TESTOKAY"
+ if MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then
+ echo "$TESTOKAY"
else
echo "$TESTFAIL"
EXIT_CODE=1