From 7df0d6f642785f9372c87eb6153eff4134afd0b7 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 25 Dec 2018 14:20:33 -0800 Subject: [PATCH 1/5] create appveyor test branch which will execute same tests as `master` branch hence including older Visual version --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 2b674ce3c..5404558c0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,7 @@ branches: only: - master + - appveyorTest environment: matrix: - COMPILER: "gcc" From ecd4df414361401544206d33e44120d982a91af9 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 25 Dec 2018 14:55:45 -0800 Subject: [PATCH 2/5] added *visual* branches to long tests on Appveyor --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 5404558c0..35f019dd6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,7 @@ only: - master - appveyorTest + - /visual*/ environment: matrix: - COMPILER: "gcc" From 1fdba696ca1cabfe218815e2b000d444ed0408f2 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 25 Dec 2018 15:04:49 -0800 Subject: [PATCH 3/5] fixed VS2008 project bench.c => benchfn.c + benchzstd.c wrong util.c from prior patch and warnings : C4127 --- build/VS2008/fullbench/fullbench.vcproj | 4 ++-- build/VS2008/zstd/zstd.vcproj | 6 +++++- programs/platform.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build/VS2008/fullbench/fullbench.vcproj b/build/VS2008/fullbench/fullbench.vcproj index 55f784977..996ee26a9 100644 --- a/build/VS2008/fullbench/fullbench.vcproj +++ b/build/VS2008/fullbench/fullbench.vcproj @@ -397,7 +397,7 @@ > + + and */ # define snprintf sprintf_s /* snprintf unsupported by Visual <= 2013 */ # endif +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ #endif From ae1d6bd48ec3d7ae81de336c2bc6fc1abac74f5e Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 26 Dec 2018 15:19:09 -0800 Subject: [PATCH 4/5] fixed playTests.sh for minGW On Windows, the equivalent of `/dev/null` is `NUL`. When tests are run under msys2/minGW, the environment identifies itself as Windows, hence the script uses `NUL` instead of `/dev/null` but the environment will consider `NUL` to be a regular file name. Consequently, `NUL` will be overwritten during tests, triggering an error. This patch uses flag `-f` to force such overwrite passing the test. --- programs/windres/zstd32.res | Bin 1044 -> 1044 bytes programs/windres/zstd64.res | Bin 1044 -> 1044 bytes tests/playTests.sh | 12 ++++++------ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/programs/windres/zstd32.res b/programs/windres/zstd32.res index 2c2b9b01e53c7bbb4fa4e845fb51edd30b84475e..843499254924c1c45ed155677538d8856721f527 100644 GIT binary patch delta 33 ncmbQjF@ tmpCompressed $ZSTD tmp --stdout > tmpCompressed # long command format @@ -192,8 +192,8 @@ chmod 400 tmpro.zst $ZSTD -q tmpro && die "should have refused to overwrite read-only file" $ZSTD -q -f tmpro $ECHO "test: --no-progress flag" -$ZSTD tmpro -c --no-progress | $ZSTD -d -o "$INTOVOID" --no-progress -$ZSTD tmpro -cv --no-progress | $ZSTD -dv -o "$INTOVOID" --no-progress +$ZSTD tmpro -c --no-progress | $ZSTD -d -f -o "$INTOVOID" --no-progress +$ZSTD tmpro -cv --no-progress | $ZSTD -dv -f -o "$INTOVOID" --no-progress rm -f tmpro tmpro.zst $ECHO "test: overwrite input file (must fail)" $ZSTD tmp -fo tmp && die "zstd compression overwrote the input file" @@ -232,7 +232,7 @@ rm tmp* $ECHO "test : compress multiple files" $ECHO hello > tmp1 $ECHO world > tmp2 -$ZSTD tmp1 tmp2 -o "$INTOVOID" +$ZSTD tmp1 tmp2 -o "$INTOVOID" -f $ZSTD tmp1 tmp2 -c | $ZSTD -t $ZSTD tmp1 tmp2 -o tmp.zst test ! -f tmp1.zst @@ -240,7 +240,7 @@ test ! -f tmp2.zst $ZSTD tmp1 tmp2 $ZSTD -t tmp1.zst tmp2.zst $ZSTD -dc tmp1.zst tmp2.zst -$ZSTD tmp1.zst tmp2.zst -o "$INTOVOID" +$ZSTD tmp1.zst tmp2.zst -o "$INTOVOID" -f $ZSTD -d tmp1.zst tmp2.zst -o tmp touch tmpexists $ZSTD tmp1 tmp2 -f -o tmpexists From 6b7a1d6127a0306731d4f98a0da2b9e91c078242 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 26 Dec 2018 15:51:34 -0800 Subject: [PATCH 5/5] fixed detection of input==output on Visual due to bad support of inode identifiers. On Visual, option is limited to same file name, which is imperfect, but way better than disabling the feature entirely. It's enough to pass associated tests. --- programs/fileio.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index a5460ba2d..9fb795ed3 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -423,16 +423,29 @@ static FILE* FIO_openDstFile(const char* srcFileName, const char* dstFileName) return stdout; } + /* ensure dst is not the same file as src */ if (srcFileName != NULL) { +#ifdef _MSC_VER + /* note : Visual does not support file identification by inode. + * The following work-around is limited to detecting exact name repetition only, + * aka `filename` is considered different from `subdir/../filename` */ + if (!strcmp(srcFileName, dstFileName)) { + DISPLAYLEVEL(1, "zstd: Refusing to open a output file which will overwrite the input file \n"); + return NULL; + } +#else stat_t srcStat; stat_t dstStat; - if ( UTIL_getFileStat(srcFileName, &srcStat) - && UTIL_getFileStat(dstFileName, &dstStat) ) { - if ( srcStat.st_dev == dstStat.st_dev - && srcStat.st_ino == dstStat.st_ino ) { + if (UTIL_getFileStat(srcFileName, &srcStat) + && UTIL_getFileStat(dstFileName, &dstStat)) { + if (srcStat.st_dev == dstStat.st_dev + && srcStat.st_ino == dstStat.st_ino) { DISPLAYLEVEL(1, "zstd: Refusing to open a output file which will overwrite the input file \n"); return NULL; - } } } + } + } +#endif + } if (g_sparseFileSupport == 1) { g_sparseFileSupport = ZSTD_SPARSE_DEFAULT;