From 455e9c2c3ec4b3e7f194307b0ba2910c6be12087 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 18 Oct 2020 14:21:25 -0700 Subject: [PATCH] scripts/gzip_tests.sh: work around broken timestamps in Travis CI --- scripts/gzip_tests.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/gzip_tests.sh b/scripts/gzip_tests.sh index c8dcff7..f29dbf8 100755 --- a/scripts/gzip_tests.sh +++ b/scripts/gzip_tests.sh @@ -93,6 +93,9 @@ assert_equals() { fi } +# Get the filesystem type. +FSTYPE=$(df -T . | tail -1 | awk '{print $2}') + begin_test 'Basic compression and decompression works' cp file orig gzip file @@ -393,12 +396,20 @@ assert_error '\' gunzip -S '""' file begin_test 'Timestamps and mode are preserved' +if [ "$FSTYPE" = shiftfs ]; then + # In Travis CI, the filesystem (shiftfs) only supports seconds precision + # timestamps. Nanosecond precision still sometimes seems to work, + # probably due to caching, but it is unreliable. + format='%a;%X;%Y' +else + format='%a;%x;%y' +fi chmod 777 file -orig_stat="$(stat -c '%a;%x;%y' file)" +orig_stat="$(stat -c "$format" file)" gzip file sleep 1 gunzip file.gz -assert_equals "$orig_stat" "$(stat -c '%a;%x;%y' file)" +assert_equals "$orig_stat" "$(stat -c "$format" file)" begin_test 'Decompressing multi-member gzip file'