scripts/gzip_tests.sh: work around broken timestamps in Travis CI

This commit is contained in:
Eric Biggers 2020-10-18 14:21:25 -07:00
parent b6f9462708
commit 455e9c2c3e

View File

@ -93,6 +93,9 @@ assert_equals() {
fi fi
} }
# Get the filesystem type.
FSTYPE=$(df -T . | tail -1 | awk '{print $2}')
begin_test 'Basic compression and decompression works' begin_test 'Basic compression and decompression works'
cp file orig cp file orig
gzip file gzip file
@ -393,12 +396,20 @@ assert_error '\<invalid suffix\>' gunzip -S '""' file
begin_test 'Timestamps and mode are preserved' 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 chmod 777 file
orig_stat="$(stat -c '%a;%x;%y' file)" orig_stat="$(stat -c "$format" file)"
gzip file gzip file
sleep 1 sleep 1
gunzip file.gz 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' begin_test 'Decompressing multi-member gzip file'