diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 2 | ||||
-rw-r--r-- | test/integration/framework | 60 | ||||
-rwxr-xr-x | test/integration/run-tests | 4 | ||||
-rwxr-xr-x | test/integration/test-apt-ftparchive-cachedb-lp1274466 | 2 | ||||
-rwxr-xr-x | test/integration/test-dpkg-assert-multi-arch | 26 | ||||
-rwxr-xr-x | test/integration/test-external-dependency-solver-protocol | 8 | ||||
-rw-r--r-- | test/libapt/parsedepends_test.cc | 4 | ||||
-rw-r--r-- | test/libapt/strutil_test.cc | 35 |
8 files changed, 95 insertions, 46 deletions
diff --git a/test/Makefile b/test/Makefile index 74bffccb7..35a0a51e3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -7,7 +7,7 @@ ifndef NOISY endif .PHONY: startup headers library clean veryclean all binary program doc test update-po -startup all clean veryclean binary program dirs test update-po manpages debiandoc: +startup all clean veryclean binary program dirs test update-po manpages docbook: $(MAKE) -C libapt $@ $(MAKE) -C interactive-helper $@ diff --git a/test/integration/framework b/test/integration/framework index 7959699fd..3bbf440c8 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -23,30 +23,30 @@ if [ "$MSGCOLOR" != 'NO' ]; then CCMD="\033[1;35m" # pink fi -msgdie() { echo "${CERROR}E: $1${CNORMAL}" >&2; exit 1; } -msgwarn() { echo "${CWARNING}W: $1${CNORMAL}" >&2; } -msgmsg() { echo "${CMSG}$1${CNORMAL}"; } -msginfo() { echo "${CINFO}I: $1${CNORMAL}"; } -msgdebug() { echo "${CDEBUG}D: $1${CNORMAL}"; } -msgdone() { echo "${CDONE}DONE${CNORMAL}"; } -msgnwarn() { echo -n "${CWARNING}W: $1${CNORMAL}" >&2; } -msgnmsg() { echo -n "${CMSG}$1${CNORMAL}"; } -msgninfo() { echo -n "${CINFO}I: $1${CNORMAL}"; } -msgndebug() { echo -n "${CDEBUG}D: $1${CNORMAL}"; } +msgdie() { printf "${CERROR}E: $1${CNORMAL}\n" >&2; exit 1; } +msgwarn() { printf "${CWARNING}W: $1${CNORMAL}\n" >&2; } +msgmsg() { printf "${CMSG}$1${CNORMAL}\n"; } +msginfo() { printf "${CINFO}I: $1${CNORMAL}\n"; } +msgdebug() { printf "${CDEBUG}D: $1${CNORMAL}\n"; } +msgdone() { printf "${CDONE}DONE${CNORMAL}\n"; } +msgnwarn() { printf "${CWARNING}W: $1${CNORMAL}" >&2; } +msgnmsg() { printf "${CMSG}$1${CNORMAL}"; } +msgninfo() { printf "${CINFO}I: $1${CNORMAL}"; } +msgndebug() { printf "${CDEBUG}D: $1${CNORMAL}"; } msgtest() { while [ -n "$1" ]; do - echo -n "${CINFO}$1${CCMD} " - echo -n "$(echo "$2" | sed -e 's#^apt\([cgfs]\)#apt-\1#')${CINFO} " + printf "${CINFO}$1${CCMD} " + printf -- "$(echo "$2" | sed -e 's#^apt\([cgfs]\)#apt-\1#')${CINFO} " shift if [ -n "$1" ]; then shift; else break; fi done - echo -n "…${CNORMAL} " + printf "…${CNORMAL} " } -msgpass() { echo "${CPASS}PASS${CNORMAL}"; } -msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; } +msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; } +msgskip() { printf "${CWARNING}SKIP${CNORMAL}\n" >&2; } msgfail() { - if [ $# -gt 0 ]; then echo "${CFAIL}FAIL: $*${CNORMAL}" >&2; - else echo "${CFAIL}FAIL${CNORMAL}" >&2; fi + if [ $# -gt 0 ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2; + else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi EXIT_CODE=$((EXIT_CODE+1)); } @@ -63,12 +63,12 @@ if [ $MSGLEVEL -le 2 ]; then msgmsg() { true; } msgnmsg() { true; } msgtest() { true; } - msgpass() { echo -n " ${CPASS}P${CNORMAL}"; } - msgskip() { echo -n " ${CWARNING}S${CNORMAL}" >&2; } + msgpass() { printf " ${CPASS}P${CNORMAL}"; } + msgskip() { printf " ${CWARNING}S${CNORMAL}" >&2; } if [ -n "$CFAIL" ]; then - msgfail() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); } + msgfail() { printf " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); } else - msgfail() { echo -n " ###FAILED###" >&2; EXIT_CODE=$((EXIT_CODE+1)); } + msgfail() { printf " ###FAILED###" >&2; EXIT_CODE=$((EXIT_CODE+1)); } fi fi if [ $MSGLEVEL -le 3 ]; then @@ -87,7 +87,7 @@ msgdone() { [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then true; else - echo "${CDONE}DONE${CNORMAL}"; + printf "${CDONE}DONE${CNORMAL}\n"; fi } getaptconfig() { @@ -120,6 +120,7 @@ apthelper() { runapt "${APTHELPERBINDIR}/apt-helper" "$@"; } aptwebserver() { runapt "${APTWEBSERVERBINDIR}/aptwebserver" "$@"; } aptitude() { runapt aptitude "$@"; } aptextracttemplates() { runapt apt-extracttemplates "$@"; } +aptinternalsolver() { runapt "${APTINTERNALSOLVER}" "$@"; } dpkg() { command dpkg --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log "$@" @@ -154,7 +155,7 @@ exitwithstatus() { shellsetedetector() { local exit_status=$? if [ "$exit_status" != '0' ]; then - echo >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}" + printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n" if [ "$EXIT_CODE" = '0' ]; then EXIT_CODE="$exit_status" fi @@ -181,6 +182,7 @@ setupenvironment() { METHODSDIR=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"} APTHELPERBINDIR=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"} APTWEBSERVERBINDIR=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"} + APTINTERNALSOLVER=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"} test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" # ----- @@ -326,12 +328,12 @@ configdpkg() { configcompression() { while [ -n "$1" ]; do case "$1" in - '.') echo ".\t.\tcat";; - 'gz') echo "gzip\tgz\tgzip";; - 'bz2') echo "bzip2\tbz2\tbzip2";; - 'lzma') echo "lzma\tlzma\txz --format=lzma";; - 'xz') echo "xz\txz\txz";; - *) echo "$1\t$1\t$1";; + '.') printf ".\t.\tcat\n";; + 'gz') printf "gzip\tgz\tgzip\n";; + 'bz2') printf "bzip2\tbz2\tbzip2\n";; + 'lzma') printf "lzma\tlzma\txz --format=lzma\n";; + 'xz') printf "xz\txz\txz\n";; + *) printf "$1\t$1\t$1\n";; esac shift done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf diff --git a/test/integration/run-tests b/test/integration/run-tests index d39daeee5..9dd550aa2 100755 --- a/test/integration/run-tests +++ b/test/integration/run-tests @@ -39,9 +39,9 @@ fi TOTAL="$(run-parts --list $DIR | grep '/test-' | wc -l)" for testcase in $(run-parts --list $DIR | grep '/test-'); do if [ "$MSGLEVEL" -le 2 ]; then - echo -n "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: " + printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: " else - echo "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}$(basename ${testcase})${CRESET}" + printf "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}$(basename ${testcase})${CRESET}\n" fi if ! ${testcase}; then FAIL=$((FAIL+1)) diff --git a/test/integration/test-apt-ftparchive-cachedb-lp1274466 b/test/integration/test-apt-ftparchive-cachedb-lp1274466 index 2a28d6ef0..579ae33a6 100755 --- a/test/integration/test-apt-ftparchive-cachedb-lp1274466 +++ b/test/integration/test-apt-ftparchive-cachedb-lp1274466 @@ -46,6 +46,8 @@ Description: an autogenerated dummy foo=1/test " aptftparchive --db old-format.db packages . # ensure that the db is updated and contains the new sha512 +db_dump old-format.db > old-format.dump + testsuccess grep 7da58ff901a40ecf42a730dc33198b182e9ba9ec98799fc2c2b6fabeeee40cc12a0e7cadb4b66764235c56e1009dbfe8a9a566fb1eedf47a992d1fff2cc3332c old-format.dump diff --git a/test/integration/test-dpkg-assert-multi-arch b/test/integration/test-dpkg-assert-multi-arch index 177d7489b..b3fbbf0eb 100755 --- a/test/integration/test-dpkg-assert-multi-arch +++ b/test/integration/test-dpkg-assert-multi-arch @@ -26,15 +26,17 @@ testqualifier() { fi } -# non-multiarch or "ubuntus" old multiarchified dpkg +msgmsg 'non-multiarch or "ubuntus" old multiarchified dpkg' echo 'Dir::Bin::dpkg "./dpkg-wrapper";' > rootdir/etc/apt/apt.conf.d/99dpkgwrapper -echo '#! /bin/sh -if echo "$*" | grep -q -- "--assert-multi-arch"; then +cat > ./dpkg-wrapper <<EOF +#! /bin/sh +if echo "\$*" | grep -q -- "--assert-multi-arch"; then echo >&2 'dpkg: Fehler: unbekannte Option --assert-multi-arch' echo >&1 'dpkg: Info: unbekannte Option --assert-multi-arch' - return 2; + exit 2 fi -return $*' > ./dpkg-wrapper +exec "\$@" +EOF chmod +x ./dpkg-wrapper testqualifier 'native-pkg' 'native-pkg' @@ -61,16 +63,18 @@ testqualifier 'all-foreign-pkg-' 'all-foreign-pkg' testqualifier 'always-all-pkg-' 'always-all-pkg' testqualifier 'always-all-foreign-pkg-' 'always-all-foreign-pkg' -# multiarch dpkg (new interface version) - +msgmsg 'multiarch dpkg (new interface version)' rm rootdir/var/lib/dpkg/status touch rootdir/var/lib/dpkg/status echo 'Dir::Bin::dpkg "./dpkg-wrapper";' > rootdir/etc/apt/apt.conf.d/99dpkgwrapper -echo '#! /bin/sh -if echo "$*" | grep -q -- "--assert-multi-arch"; then - return 0; +cat > ./dpkg-wrapper <<EOF +#! /bin/sh +if echo "\$*" | grep -q -- "--assert-multi-arch"; then + exit 0 fi -return $*' > ./dpkg-wrapper +exec "\$@" +EOF +chmod +x ./dpkg-wrapper testqualifier 'native-pkg' 'native-pkg:amd64' testqualifier 'native-pkg:amd64' 'native-pkg:amd64' diff --git a/test/integration/test-external-dependency-solver-protocol b/test/integration/test-external-dependency-solver-protocol index 129565993..07d2441b6 100755 --- a/test/integration/test-external-dependency-solver-protocol +++ b/test/integration/test-external-dependency-solver-protocol @@ -51,9 +51,15 @@ rm -f /tmp/dump.edsp testfailure aptget install --solver dump awesomecoolstuff:i386 -s testsuccess test -s /tmp/dump.edsp +testsuccess aptget dist-upgrade -s +testsuccess aptget dist-upgrade -s --solver apt + +testsuccess aptget upgrade -s +testsuccess aptget upgrade -s --solver apt + configarchitecture 'armel' msgtest 'Test direct calling is okay for' 'apt-internal-solver' -cat /tmp/dump.edsp | runapt apt-internal-solver > solver.result 2>&1 || true +cat /tmp/dump.edsp | aptinternalsolver > solver.result 2>&1 || true if [ "$(tail -n2 solver.result | head -n1 )" = "Message: Done" ]; then msgpass else diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index 1e0afb66c..52eac8232 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -23,7 +23,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag "libdb-dev:any, " "gettext:native (<= 0.12), " "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), " - "debiandoc-sgml, " + "docbook-xml, " "apt (>= 0.7.25), " "not-for-me [ !amd64 ], " "only-for-me [ amd64 ], " @@ -82,7 +82,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag EXPECT_EQ(Null | pkgCache::Dep::Greater, Op); Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList); - EXPECT_EQ("debiandoc-sgml", Package); + EXPECT_EQ("docbook-xml", Package); EXPECT_EQ("", Version); EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op); diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc index bc004fd66..e9b778c6b 100644 --- a/test/libapt/strutil_test.cc +++ b/test/libapt/strutil_test.cc @@ -70,3 +70,38 @@ TEST(StrUtilTest,EndsWith) EXPECT_FALSE(Endswith("abcd", "x")); EXPECT_FALSE(Endswith("abcd", "abcndefg")); } +TEST(StrUtilTest,SubstVar) +{ + EXPECT_EQ("", SubstVar("", "fails", "passes")); + EXPECT_EQ("test ", SubstVar("test fails", "fails", "")); + EXPECT_EQ("test passes", SubstVar("test passes", "", "fails")); + + EXPECT_EQ("test passes", SubstVar("test passes", "fails", "passes")); + EXPECT_EQ("test passes", SubstVar("test fails", "fails", "passes")); + + EXPECT_EQ("starts with", SubstVar("beginnt with", "beginnt", "starts")); + EXPECT_EQ("beginnt with", SubstVar("starts with", "starts", "beginnt")); + EXPECT_EQ("is in middle", SubstVar("is in der middle", "in der", "in")); + EXPECT_EQ("is in der middle", SubstVar("is in middle", "in", "in der")); + EXPECT_EQ("does end", SubstVar("does enden", "enden", "end")); + EXPECT_EQ("does enden", SubstVar("does end", "end", "enden")); + + EXPECT_EQ("abc", SubstVar("abc", "d", "a")); + EXPECT_EQ("abc", SubstVar("abd", "d", "c")); + EXPECT_EQ("abc", SubstVar("adc", "d", "b")); + EXPECT_EQ("abc", SubstVar("dbc", "d", "a")); + + EXPECT_EQ("b", SubstVar("b", "aa", "a")); + EXPECT_EQ("bb", SubstVar("bb", "aa", "a")); + EXPECT_EQ("bbb", SubstVar("bbb", "aa", "a")); + + EXPECT_EQ("aa", SubstVar("aaaa", "aa", "a")); + EXPECT_EQ("aaaa", SubstVar("aa", "a", "aa")); + EXPECT_EQ("aaaa", SubstVar("aaaa", "a", "a")); + EXPECT_EQ("a a a a ", SubstVar("aaaa", "a", "a ")); + + EXPECT_EQ(" bb bb bb bb ", SubstVar(" a a a a ", "a", "bb")); + EXPECT_EQ(" bb bb bb bb ", SubstVar(" aaa aaa aaa aaa ", "aaa", "bb")); + EXPECT_EQ(" bb a bb a bb a bb ", SubstVar(" aaa a aaa a aaa a aaa ", "aaa", "bb")); + +} |