From 26e3ec10db15409256bf773ad93c944156697e9e Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 20 Aug 2022 14:38:49 +0200 Subject: Overhaul tar compression test script, add to corpora test set - Make the script faster by unpacking everything at once instead of file-by-file - Also compare symlinks and directories - More verbose output Signed-off-by: David Oberhollenzer --- tests/Makemodule.am | 6 ++++-- tests/tarcompress.sh.in | 39 +++++++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/tests/Makemodule.am b/tests/Makemodule.am index 0ae3f8b..39db3ba 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -6,8 +6,10 @@ include tests/libsqfs/Makemodule.am if BUILD_TOOLS if CORPORA_TESTS -check_SCRIPTS += tests/cantrbry.sh tests/test_tar_sqfs.sh tests/pack_dir_root.sh -TESTS += tests/cantrbry.sh tests/test_tar_sqfs.sh tests/pack_dir_root.sh +check_SCRIPTS += tests/cantrbry.sh tests/test_tar_sqfs.sh \ + tests/pack_dir_root.sh tests/tarcompress.sh +TESTS += tests/cantrbry.sh tests/test_tar_sqfs.sh \ + tests/pack_dir_root.sh tests/tarcompress.sh endif endif diff --git a/tests/tarcompress.sh.in b/tests/tarcompress.sh.in index 99075a2..726f4e8 100644 --- a/tests/tarcompress.sh.in +++ b/tests/tarcompress.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e @@ -31,18 +31,41 @@ rm "$DIR/out2.sqfs" "$DIR/out3.sqfs" rm "$DIR/linux-3.11.tar.bz2" rm "$DIR/linux-3.11.tar.gz" -# every file that exists in the tar ball MUST exist in the squashfs image -# and they MUST be identical +# unpack tarball and squashfs image tar -C "$DIR" -xf "$DIR/linux-3.11.tar.xz" +rm "$DIR/linux-3.11.tar.xz" + +"$RDSQFS" -DSF -u / -p "$DIR/sqfs/" "$DIR/out1.sqfs" +rm "$DIR/out1.sqfs" +# every file that exists in the tar ball MUST exist in the squashfs image +# and they MUST be identical find "$DIR/linux-3.11" -type f | sed "s#$DIR/##" | \ while read fname; do - "$RDSQFS" -c "$fname" "$DIR/out1.sqfs" > "$DIR/temp" + set -e + diff "$DIR/$fname" "$DIR/sqfs/$fname" + rm "$DIR/sqfs/$fname" "$DIR/$fname" + echo "match $DIR/$fname" +done - diff "$DIR/$fname" "$DIR/temp" +find "$DIR/linux-3.11" -type l | sed "s#$DIR/##" | \ +while read fname; do + set -e + a=$(readlink "$DIR/$fname") + b=$(readlink "$DIR/sqfs/$fname") + [ "x$a" = "x$b" ] || exit 1 + unlink "$DIR/sqfs/$fname" + unlink "$DIR/$fname" + echo "match $DIR/$fname" +done + +# match directories and cleanup at the same time +find "$DIR/linux-3.11" -type d | sed "s#$DIR/##" | sort -ur | \ +while read fname; do + set -e + rmdir "$DIR/$fname" "$DIR/sqfs/$fname" done -# cleanup -rm "$DIR/temp" "$DIR/out1.sqfs" "$DIR/linux-3.11.tar.xz" -rm --one-file-system -rf "$DIR/linux-3.11" +rmdir "$DIR/sqfs" rmdir "$DIR" +echo "DONE!" -- cgit v1.2.3