Sfoglia il codice sorgente

configurable compression for testcases

Compressing files in 4 different styles eats test-time for no practical
gain if we don't test them explicitly, so default to just building 'gz'
compressed files as it is the simplest compression algorithm supported

Git-Dch: Ignore
David Kalnischkies 13 anni fa
parent
commit
276e51dd70

+ 37 - 11
test/integration/framework

@@ -194,6 +194,7 @@ setupenvironment() {
 	echo 'quiet::NoUpdate "true";' >> aptconfig.conf
 	echo 'quiet::NoUpdate "true";' >> aptconfig.conf
 	export LC_ALL=C
 	export LC_ALL=C
 	export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
 	export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
+	configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
 	msgdone "info"
 	msgdone "info"
 }
 }
 
 
@@ -257,6 +258,20 @@ configdpkg() {
 	fi
 	fi
 }
 }
 
 
+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";;
+		esac
+		shift
+	done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
+}
+
 setupsimplenativepackage() {
 setupsimplenativepackage() {
 	local NAME="$1"
 	local NAME="$1"
 	local ARCH="$2"
 	local ARCH="$2"
@@ -427,6 +442,8 @@ buildaptarchive() {
 }
 }
 
 
 createaptftparchiveconfig() {
 createaptftparchiveconfig() {
+	local COMPRESSORS="$(cut -d'	' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
+	COMPRESSORS="${COMPRESSORS%* }"
 	local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')"
 	local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')"
 	if [ -z "$ARCHS" ]; then
 	if [ -z "$ARCHS" ]; then
 		# the pool is empty, so we will operate on faked packages - let us use the configured archs
 		# the pool is empty, so we will operate on faked packages - let us use the configured archs
@@ -444,10 +461,10 @@ createaptftparchiveconfig() {
 	echo -n '";
 	echo -n '";
 };
 };
 Default {
 Default {
-	Packages::Compress ". gzip bzip2 lzma xz";
-	Sources::Compress ". gzip bzip2 lzma xz";
-	Contents::Compress ". gzip bzip2 lzma xz";
-	Translation::Compress ". gzip bzip2 lzma xz";
+	Packages::Compress "'"$COMPRESSORS"'";
+	Sources::Compress "'"$COMPRESSORS"'";
+	Contents::Compress "'"$COMPRESSORS"'";
+	Translation::Compress "'"$COMPRESSORS"'";
 	LongDescription "false";
 	LongDescription "false";
 };
 };
 TreeDefault {
 TreeDefault {
@@ -617,18 +634,27 @@ buildaptarchivefromfiles() {
 	msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
 	msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
 	find aptarchive -name 'Packages' -o -name 'Sources' | while read line; do
 	find aptarchive -name 'Packages' -o -name 'Sources' | while read line; do
 		msgninfo "\t${line} file… "
 		msgninfo "\t${line} file… "
-		cat ${line} | gzip > ${line}.gz
-		cat ${line} | bzip2 > ${line}.bz2
-		cat ${line} | xz --format=lzma > ${line}.lzma
-		cat ${line} | xz > ${line}.xz
-		if [ -n "$1" ]; then
-			touch -d "$1" ${line}.gz ${line}.bz2 ${line}.lzma ${line}.xz
-		fi
+		compressfile "$line" "$1"
 		msgdone "info"
 		msgdone "info"
 	done
 	done
 	generatereleasefiles "$@"
 	generatereleasefiles "$@"
 }
 }
 
 
+compressfile() {
+	cat ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | while read compressor extension command; do
+		if [ "$compressor" = '.' ]; then
+			if [ -n "$2" ]; then
+				touch -d "$2" "$1"
+			fi
+			continue
+		fi
+		cat "$1" | $command > "${1}.${extension}"
+		if [ -n "$2" ]; then
+			touch -d "$2" "${1}.${extension}"
+		fi
+	done
+}
+
 # can be overridden by testcases for their pleasure
 # can be overridden by testcases for their pleasure
 getcodenamefromsuite() { echo -n "$1"; }
 getcodenamefromsuite() { echo -n "$1"; }
 getreleaseversionfromsuite() { true; }
 getreleaseversionfromsuite() { true; }

+ 1 - 4
test/integration/test-apt-cdrom

@@ -18,10 +18,7 @@ echo 'Description-de: automatisch generiertes Testpaket testing=0.8.15/stable
  Diese Pakete sind nur für das testen von APT gedacht,
  Diese Pakete sind nur für das testen von APT gedacht,
  sie erfüllen keinen Zweck auf einem normalen System…
  sie erfüllen keinen Zweck auf einem normalen System…
 ' >> Translation-de
 ' >> Translation-de
-cat Translation-de | gzip > Translation-de.gz
-cat Translation-de | bzip2 > Translation-de.bz2
-cat Translation-de | xz --format=lzma > Translation-de.lzma
-cat Translation-de | xz > Translation-de.xz
+compressfile Translation-de
 rm Translation-en Translation-de
 rm Translation-en Translation-de
 cd - > /dev/null
 cd - > /dev/null
 addtrap 'prefix' "chmod -R +w $PWD/rootdir/media/cdrom/dists/;"
 addtrap 'prefix' "chmod -R +w $PWD/rootdir/media/cdrom/dists/;"

+ 1 - 3
test/integration/test-hashsum-verification

@@ -21,9 +21,7 @@ prepare() {
 	done
 	done
 	cp $1 aptarchive/Packages
 	cp $1 aptarchive/Packages
 	find aptarchive -name 'Release' -delete
 	find aptarchive -name 'Release' -delete
-	cat aptarchive/Packages | gzip > aptarchive/Packages.gz
-	cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2
-	cat aptarchive/Packages | xz --format=lzma > aptarchive/Packages.lzma
+	compressfile aptarchive/Packages
         # create Release file with incorret checksums
         # create Release file with incorret checksums
 	cat > aptarchive/Release <<EOF
 	cat > aptarchive/Release <<EOF
 Date: Fri, 05 Aug 2011 09:22:08 UTC
 Date: Fri, 05 Aug 2011 09:22:08 UTC

+ 1 - 3
test/integration/test-pdiff-usage

@@ -19,9 +19,7 @@ testequal "$(cat ${PKGFILE})
 " aptcache show apt oldstuff
 " aptcache show apt oldstuff
 
 
 cp ${PKGFILE}-new aptarchive/Packages
 cp ${PKGFILE}-new aptarchive/Packages
-cat aptarchive/Packages | gzip > aptarchive/Packages.gz
-cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2
-cat aptarchive/Packages | xz --format=lzma > aptarchive/Packages.lzma
+compressfile 'aptarchive/Packages'
 rm -rf aptarchive/Packages.diff
 rm -rf aptarchive/Packages.diff
 mkdir -p aptarchive/Packages.diff
 mkdir -p aptarchive/Packages.diff
 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"

+ 1 - 3
test/integration/test-releasefile-verification

@@ -22,9 +22,7 @@ prepare() {
 	aptget clean
 	aptget clean
 	cp $1 aptarchive/Packages
 	cp $1 aptarchive/Packages
 	find aptarchive -name 'Release' -delete
 	find aptarchive -name 'Release' -delete
-	cat aptarchive/Packages | gzip > aptarchive/Packages.gz
-	cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2
-	cat aptarchive/Packages | xz --format=lzma > aptarchive/Packages.lzma
+	compressfile 'aptarchive/Packages'
 	generatereleasefiles "$DATE"
 	generatereleasefiles "$DATE"
 }
 }