logo

utils-std

Collection of commonly available Unix tools
commit: 144e99acf1f6b3fe17940ab40bc392432e2d9c81
parent b7f450b3063afcb8fb6470566e9ac8466ebd0a30
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 26 Jul 2024 10:16:02 +0200

test-cmd/touch: Add sync(1), drop sleeps on -d and -t tests

Diffstat:

Mtest-cmd/touch63++++++++++++++++++++-------------------------------------------
1 file changed, 20 insertions(+), 43 deletions(-)

diff --git a/test-cmd/touch b/test-cmd/touch @@ -136,75 +136,52 @@ dir_body() { atf_test_case optd optd_body() { - atf_check touch -a ./foo - maybe_sleep - atf_check touch -m ./foo - maybe_sleep - atime="$(./stat_atime ./foo)" - mtime="$(./stat_mtime ./foo)" - export TZ=UTC - atf_check ../cmd/touch -d 2003-06-02T13:37:42Z ./foo - atf_check -o "not-inline:${atime}\n" ./stat_atime ./foo - atf_check -o "not-inline:${mtime}\n" ./stat_mtime ./foo - atf_check -o 'match:^2003-06-02[T ]13:37:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo - atf_check -o 'match:^2003-06-02[T ]13:37:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo + atf_check ../cmd/touch -d 2003-06-02T13:37:42Z ./foo_d + sync + atf_check -o 'match:^2003-06-02[T ]13:37:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo_d + atf_check -o 'match:^2003-06-02[T ]13:37:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo_d } atf_test_case optd_tz optd_tz_body() { export TZ=UTC - atf_check ../cmd/touch -d 2003-04-20T13:37:42+0000 ./foo - atf_check -o 'match:^2003-04-20[T ]13:37:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo - atf_check -o 'match:^2003-04-20[T ]13:37:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo + atf_check ../cmd/touch -d 2003-04-20T13:37:42+0000 ./foo_tz1 + sync + atf_check -o 'match:^2003-04-20[T ]13:37:42(\.[0-9]+)? ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo_tz1 + atf_check -o 'match:^2003-04-20[T ]13:37:42(\.[0-9]+)? ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo_tz1 - atf_check ../cmd/touch -d 2003-04-20T13:37:42+0666 ./foo - atf_check -o 'match:^2003-04-20[T ]06:31:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo - atf_check -o 'match:^2003-04-20[T ]06:31:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo + atf_check ../cmd/touch -d 2003-04-20T13:37:42.0+0666 ./foo_tz2 + atf_check -o 'match:^2003-04-20[T ]06:31:42(\.[0-9]+)? ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo_tz2 + atf_check -o 'match:^2003-04-20[T ]06:31:42(\.[0-9]+)? ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo_tz2 } atf_test_case optd_frac optd_frac_body() { - atf_check touch -a ./foo - maybe_sleep - atf_check touch -m ./foo - maybe_sleep - atime="$(./stat_atime ./foo)" - mtime="$(./stat_mtime ./foo)" - export TZ=UTC - atf_check ../cmd/touch -d 2003-06-02T13:37:42.713Z ./foo - atf_check -o "not-inline:${atime}\n" ./stat_atime ./foo - atf_check -o "not-inline:${mtime}\n" ./stat_mtime ./foo - atf_check -o 'match:^2003-06-02[T ]13:37:42.7130+ ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo - atf_check -o 'match:^2003-06-02[T ]13:37:42.7130+ ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo + atf_check ../cmd/touch -d 2003-06-02T13:37:42.713Z ./foo_frac1 + sync + atf_check -o 'match:^2003-06-02[T ]13:37:42.7130+ ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo_frac1 + atf_check -o 'match:^2003-06-02[T ]13:37:42.7130+ ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo_frac1 - atf_check ../cmd/touch -d 2003-06-02T13:37:42.123456789Z ./foo - atf_check -o 'match:^2003-06-02[T ]13:37:42.123456789 ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo - atf_check -o 'match:^2003-06-02[T ]13:37:42.123456789 ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo + atf_check ../cmd/touch -d 2003-06-02T13:37:42.123456789Z ./foo_frac2 + sync + atf_check -o 'match:^2003-06-02[T ]13:37:42.123456789 ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo_frac2 + atf_check -o 'match:^2003-06-02[T ]13:37:42.123456789 ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo_frac2 atf_check -s 'exit:1' \ -e 'inline:touch: iso_parse("2003-06-02T13:37:42.1234567890Z", …): Too many digits (> 10) for fractional seconds\n' \ - ../cmd/touch -d 2003-06-02T13:37:42.1234567890Z ./foo + ../cmd/touch -d 2003-06-02T13:37:42.1234567890Z ./foo_frac_big } atf_test_case optt optt_body() { - atf_check touch -a ./foo - maybe_sleep - atf_check touch -m ./foo - maybe_sleep - atime="$(./stat_atime ./foo)" - mtime="$(./stat_mtime ./foo)" - export TZ=UTC atf_check ../cmd/touch -t 200306021337.42 ./foo - atf_check -o "not-inline:${atime}\n" ./stat_atime ./foo - atf_check -o "not-inline:${mtime}\n" ./stat_mtime ./foo atf_check -o 'match:^2003-06-02[T ]13:37:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_atime ./foo atf_check -o 'match:^2003-06-02[T ]13:37:42(\.0+)? ?(Z|[\+\-]00:?00)$' ./stat_mtime ./foo }