Add Test to Verify mtime is Copied to Destination

dev
W. Felix Handte 2021-08-03 17:20:12 -04:00
parent 6ee70bae46
commit ead41bcb4e
1 changed files with 19 additions and 0 deletions

View File

@ -124,6 +124,13 @@ case "$UNAME" in
Darwin | FreeBSD | OpenBSD | NetBSD) MTIME="stat -f %m" ;; Darwin | FreeBSD | OpenBSD | NetBSD) MTIME="stat -f %m" ;;
esac 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" GET_PERMS="stat -c %a"
case "$UNAME" in case "$UNAME" in
Darwin | FreeBSD | OpenBSD | NetBSD) GET_PERMS="stat -f %Lp" ;; 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 rm -f tmp.img tmp.img.zst tmp.img.copy
fi 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 "\n===> compress multiple files into an output directory, --output-dir-flat"
println henlo > tmp1 println henlo > tmp1
mkdir tmpInputTestDir mkdir tmpInputTestDir