aboutsummaryrefslogtreecommitdiff
path: root/tests/tarcompress.sh.in
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-08-20 14:38:49 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-08-20 14:45:16 +0200
commit26e3ec10db15409256bf773ad93c944156697e9e (patch)
treef8bc4aa1c8c7dd0bdf9405da2530d4c487dc88bd /tests/tarcompress.sh.in
parent62753ec36958c40f151fa223605aea5e6a50bd89 (diff)
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/tarcompress.sh.in')
-rw-r--r--tests/tarcompress.sh.in39
1 files changed, 31 insertions, 8 deletions
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!"