add tests - set-mtime-on-output-files

This commit is contained in:
zhangxiao 2021-11-03 16:33:36 +08:00
parent ddd22f3747
commit de236637ee
3 changed files with 41 additions and 2 deletions

View File

@ -13,7 +13,7 @@ diff -Nur zstd-1.5.0/programs/fileio.c new-zstd-1.5.0/programs/fileio.c
&& UTIL_stat(srcFileName, &statbuf)
&& UTIL_isRegularFileStat(&statbuf) ) {
dstFilePermissions = statbuf.st_mode;
+ transferMTime = 0;
+ transferMTime = 1;
}
closeDstFile = 1;

View File

@ -0,0 +1,35 @@
diff -Nur zstd-1.5.0/tests/playTests.sh new-zstd-1.5.0/tests/playTests.sh
--- zstd-1.5.0/tests/playTests.sh 2021-05-14 22:59:34.000000000 +0800
+++ new-zstd-1.5.0/tests/playTests.sh 2021-11-03 11:22:19.974962223 +0800
@@ -124,6 +124,13 @@
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" ;;
@@ -583,6 +590,17 @@
rm -f tmp.img tmp.img.zst tmp.img.copy
fi
+println "\n==> zstd created file timestamp tests"
+datagen > tmp
+touch -m -t 200001010000.00 tmp
+println "test: copy mtime in file -> file compression"
+zstd -f tmp -o tmp.zst
+assertSameMTime tmp tmp.zst
+println "test: copy mtime in file -> file decopmresssion"
+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

View File

@ -2,13 +2,14 @@
Name: zstd
Version: 1.5.0
Release: 2
Release: 3
Summary: A fast lossless compression algorithm
License: BSD and GPLv2
URL: https://github.com/facebook/zstd
Source0: https://github.com/facebook/zstd/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch1: backport-zstd-1.5.0-patch-1-set-mtime-on-output-files.patch
Patch2: backport-zstd-1.5.0-patch-2-add-tests-set-mtime-on-output-files.patch
BuildRequires: gtest-devel gcc-c++ pkg-config
Provides: libzstd
@ -88,6 +89,9 @@ install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1
%{_mandir}/man1/*.1*
%changelog
* Wed Nov 03 2021 zhangxiao <zhangxiao131@huawei.com> - 1.5.0-3
* add tests - solve the modification time is set to the compression time
* Mon Oct 25 2021 zhangxiao <zhangxiao131@huawei.com> - 1.5.0-2
* solve the modification time is set to the compression time