]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add Test to Verify mtime is Copied to Destination
authorW. Felix Handte <w@felixhandte.com>
Tue, 3 Aug 2021 21:20:12 +0000 (17:20 -0400)
committerW. Felix Handte <w@felixhandte.com>
Tue, 3 Aug 2021 21:22:58 +0000 (17:22 -0400)
tests/playTests.sh

index ce585f2261eefb74d3fe6f0402141138accefdd6..d108d5d8e96f808cd1a02312c65c56cb7e02c6ce 100755 (executable)
@@ -124,6 +124,13 @@ case "$UNAME" in
     Darwin | FreeBSD | OpenBSD | NetBSD) MTIME="stat -f %m" ;;
 esac
 
+assertSameMTime() {
+    MT1=$($MTIME "$1")
+    MT2=$($MTIME "$2")
+    echo MTIME $MT1 $MT2
+    [ "$MT1" = "$MT2" ] || die "mtime on $1 doesn't match mtime on $2 ($MT1 != $MT2)"
+}
+
 GET_PERMS="stat -c %a"
 case "$UNAME" in
     Darwin | FreeBSD | OpenBSD | NetBSD) GET_PERMS="stat -f %Lp" ;;
@@ -588,6 +595,18 @@ if [ -n "$READFROMBLOCKDEVICE" ] ; then
     rm -f tmp.img tmp.img.zst tmp.img.copy
 fi
 
+println "\n===>  zstd created file timestamp tests"
+datagen > tmp
+sleep 1 # could also use touch -t but I don't know how portable that is.
+println "test : copy mtime in file -> file compression "
+zstd -f tmp -o tmp.zst
+assertSameMTime tmp tmp.zst
+sleep 1 # could also use touch -t but I don't know how portable that is.
+println "test : copy mtime in file -> file decompression "
+zstd -f -d tmp.zst -o tmp.out
+assertSameMTime tmp.zst tmp.out
+rm -f tmp
+
 println "\n===>  compress multiple files into an output directory, --output-dir-flat"
 println henlo > tmp1
 mkdir tmpInputTestDir