From de236637ee5d66e90667a865da9ed1a47d35244a Mon Sep 17 00:00:00 2001 From: zhangxiao Date: Wed, 3 Nov 2021 16:33:36 +0800 Subject: [PATCH] add tests - set-mtime-on-output-files --- ....0-patch-1-set-mtime-on-output-files.patch | 2 +- ...-add-tests-set-mtime-on-output-files.patch | 35 +++++++++++++++++++ zstd.spec | 6 +++- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 backport-zstd-1.5.0-patch-2-add-tests-set-mtime-on-output-files.patch diff --git a/backport-zstd-1.5.0-patch-1-set-mtime-on-output-files.patch b/backport-zstd-1.5.0-patch-1-set-mtime-on-output-files.patch index f40ebc2..991be69 100644 --- a/backport-zstd-1.5.0-patch-1-set-mtime-on-output-files.patch +++ b/backport-zstd-1.5.0-patch-1-set-mtime-on-output-files.patch @@ -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; diff --git a/backport-zstd-1.5.0-patch-2-add-tests-set-mtime-on-output-files.patch b/backport-zstd-1.5.0-patch-2-add-tests-set-mtime-on-output-files.patch new file mode 100644 index 0000000..eb2b4a4 --- /dev/null +++ b/backport-zstd-1.5.0-patch-2-add-tests-set-mtime-on-output-files.patch @@ -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 diff --git a/zstd.spec b/zstd.spec index 45df666..c6da437 100644 --- a/zstd.spec +++ b/zstd.spec @@ -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 - 1.5.0-3 +* add tests - solve the modification time is set to the compression time + * Mon Oct 25 2021 zhangxiao - 1.5.0-2 * solve the modification time is set to the compression time -- Gitee