summaryrefslogtreecommitdiff
path: root/test/integration/framework
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-10-27 15:57:12 +0100
committerMichael Vogt <mvo@ubuntu.com>2014-10-27 15:57:12 +0100
commite29a7a394cfd41e8bad81535e0a8c07654f34bf6 (patch)
treec317e2f45aa1c96300028fb830555f248db5771e /test/integration/framework
parentbc5095b7d708c7e376f98be6edc2ad7cceca57ed (diff)
parent28460cb27846b2437010b08adf10bde18e370974 (diff)
Merge remote-tracking branch 'upstream/debian/sid' into debian/sid
Diffstat (limited to 'test/integration/framework')
-rw-r--r--test/integration/framework98
1 files changed, 67 insertions, 31 deletions
diff --git a/test/integration/framework b/test/integration/framework
index a687dcb35..7923e23d9 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -4,7 +4,7 @@ EXIT_CODE=0
# we all like colorful messages
if [ "$MSGCOLOR" != 'NO' ]; then
- if ! expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
+ if [ ! -t 1 ]; then # but check that we output to a terminal
export MSGCOLOR='NO'
fi
fi
@@ -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() {
@@ -155,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
@@ -328,17 +328,47 @@ 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
}
+forcecompressor() {
+ COMPRESSOR="$1"
+ COMPRESSOR_CMD="$1"
+ case $COMPRESSOR in
+ gzip) COMPRESS='gz';;
+ bzip2) COMPRESS='bz2';;
+ lzma) COMPRESS='lzma';;
+ xz) COMPRESS='xz';;
+ *) msgdie "Compressor $COMPRESSOR is unknown to framework, so can't be forced by forcecompressor!";;
+ esac
+ local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
+ echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
+Dir::Bin::uncompressed \"/does/not/exist\";
+Dir::Bin::gzip \"/does/not/exist\";
+Dir::Bin::bzip2 \"/does/not/exist\";
+Dir::Bin::lzma \"/does/not/exist\";
+Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
+ if [ -e "/bin/${COMPRESSOR}" ]; then
+ echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
+ elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
+ echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
+ elif [ "${COMPRESSOR}" = 'lzma' ]; then
+ echo 'Dir::Bin::xz "/usr/bin/xz";' >> "$CONFFILE"
+ COMPRESSOR_CMD='xz --format=lzma'
+ else
+ msgtest 'Test for availability of compressor' "${COMPRESSOR}"
+ msgfail
+ fi
+}
+
setupsimplenativepackage() {
local NAME="$1"
local ARCH="$2"
@@ -1019,7 +1049,13 @@ testfileequal() {
testempty() {
msgtest "Test for no output of" "$*"
- test -z "$($* 2>&1)" && msgpass || msgfail
+ local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
+ if $* >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
+ msgpass
+ else
+ cat $COMPAREFILE
+ msgfail
+ fi
}
testequal() {