From 5f468941848a661d6adaa6dc54da04b54e5c5ea1 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Thu, 5 Dec 2019 17:14:29 -0500 Subject: [PATCH 1/5] Fix playTests.sh Under QEMU --- tests/Makefile | 2 +- tests/playTests.sh | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 3917a7cf8..e50edbc83 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -330,7 +330,7 @@ test-zstd-nolegacy: zstd-nolegacy test-zstd test-zstd32 test-zstd-nolegacy: datagen file $(ZSTD) - ZSTD="$(QEMU_SYS) $(ZSTD)" ./playTests.sh $(ZSTDRTTEST) + EXE_PREFIX="$(QEMU_SYS)" ZSTD_BIN="$(ZSTD)" ./playTests.sh $(ZSTDRTTEST) test-gzstd: gzstd diff --git a/tests/playTests.sh b/tests/playTests.sh index 9e0d75d6c..d0943e1bb 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -102,9 +102,11 @@ case "$UNAME" in SunOS) DIFF="gdiff" ;; esac -println "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'" +println "\nStarting playTests.sh isWindows=$isWindows EXE_PREFIX='$EXE_PREFIX' ZSTD_BIN='$ZSTD_BIN'" -[ -n "$ZSTD" ] || die "ZSTD variable must be defined!" +[ -n "$ZSTD_BIN" ] || die "ZSTD_BIN variable must be defined!" + +ZSTD="$EXE_PREFIX $ZSTD_BIN" if echo hello | $ZSTD -v -T2 2>&1 > $INTOVOID | grep -q 'multi-threading is disabled' then @@ -493,19 +495,19 @@ cat hello.zstd world.zstd > helloworld.zstd $ZSTD -dc helloworld.zstd > result.tmp $DIFF helloworld.tmp result.tmp println "testing zstdcat symlink" -ln -sf $ZSTD zstdcat -./zstdcat helloworld.zstd > result.tmp +ln -sf $ZSTD_BIN zstdcat +$EXE_PREFIX ./zstdcat helloworld.zstd > result.tmp $DIFF helloworld.tmp result.tmp ln -s helloworld.zstd helloworld.link.zstd -./zstdcat helloworld.link.zstd > result.tmp +$EXE_PREFIX ./zstdcat helloworld.link.zstd > result.tmp $DIFF helloworld.tmp result.tmp rm zstdcat rm result.tmp println "testing zcat symlink" -ln -sf $ZSTD zcat -./zcat helloworld.zstd > result.tmp +ln -sf $ZSTD_BIN zcat +$EXE_PREFIX ./zcat helloworld.zstd > result.tmp $DIFF helloworld.tmp result.tmp -./zcat helloworld.link.zstd > result.tmp +$EXE_PREFIX ./zcat helloworld.link.zstd > result.tmp $DIFF helloworld.tmp result.tmp rm zcat rm ./*.tmp ./*.zstd From 976c055a9ab12cda4b3d258ec6be376887070a6e Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Thu, 5 Dec 2019 17:14:57 -0500 Subject: [PATCH 2/5] Add Travis Test that Builds ARM on Trusty --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index a87c604aa..297dcdd62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -137,6 +137,13 @@ matrix: - make arminstall - make armfuzz + # Introduced to check compat with old toolchains, to prevent e.g. #1872 + - name: ARM Build Test (on Trusty) + dist: trusty + script: + - make arminstall + - make armbuild + - name: Qemu PPC + Fuzz Test # ~13mn dist: trusty # it seems ppc cross-compilation fails on "current" script: From 5af8cb7aea8d890b4801e50e5274371510f2cf33 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Wed, 4 Dec 2019 10:25:07 -0500 Subject: [PATCH 3/5] Use statbuf->st_mtim Again --- programs/util.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/programs/util.c b/programs/util.c index 0fc95512e..0751bf3ca 100644 --- a/programs/util.c +++ b/programs/util.c @@ -145,20 +145,20 @@ int UTIL_setFileStat(const char *filename, stat_t *statbuf) return -1; /* set access and modification times */ -#if defined(_WIN32) || (PLATFORM_POSIX_VERSION < 200809L) +#if (PLATFORM_POSIX_VERSION >= 200809L) && defined(st_mtime) + { + /* (atime, mtime) */ + struct timespec timebuf[2] = { {0, UTIME_NOW} }; + timebuf[1] = statbuf->st_mtim; + res += utimensat(AT_FDCWD, filename, timebuf, 0); + } +#else { struct utimbuf timebuf; timebuf.actime = time(NULL); timebuf.modtime = statbuf->st_mtime; res += utime(filename, &timebuf); } -#else - { - /* (atime, mtime) */ - struct timespec timebuf[2] = { {0, UTIME_NOW} }; - timebuf[1].tv_sec = statbuf->st_mtime; - res += utimensat(AT_FDCWD, filename, timebuf, 0); - } #endif #if !defined(_WIN32) From 5666835ea7e0bb3a3b7931d71484d6f7980c0404 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Wed, 4 Dec 2019 16:59:16 -0500 Subject: [PATCH 4/5] Add Comment --- programs/util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/programs/util.c b/programs/util.c index 0751bf3ca..51d848018 100644 --- a/programs/util.c +++ b/programs/util.c @@ -145,6 +145,10 @@ int UTIL_setFileStat(const char *filename, stat_t *statbuf) return -1; /* set access and modification times */ + /* We check that st_mtime is a macro here in order to give us confidence + * that struct stat has a struct timespec st_mtim member. We need this + * check because there are some platforms that claim to be POSIX 2008 + * compliant but which do not have st_mtim... */ #if (PLATFORM_POSIX_VERSION >= 200809L) && defined(st_mtime) { /* (atime, mtime) */ From e2a99db2dd151e951ad7f31cc94d2f9b8e08ddc0 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Thu, 5 Dec 2019 12:02:35 -0500 Subject: [PATCH 5/5] Also Define _ATFILE_SOURCE --- programs/platform.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/programs/platform.h b/programs/platform.h index 5934e59cf..64ecd21fc 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -109,6 +109,15 @@ extern "C" { #endif /* PLATFORM_POSIX_VERSION */ +#if PLATFORM_POSIX_VERSION > 1 + /* glibc < 2.26 may not expose struct timespec def without this. + * See issue #1920. */ +# ifndef _ATFILE_SOURCE +# define _ATFILE_SOURCE +# endif +#endif + + /*-********************************************* * Detect if isatty() and fileno() are available ************************************************/