tests: add test for locale decimal processing
[coreutils.git] / tests / misc / stat-birthtime.sh
blobde133560cf42f3ccc7ac9a16b84c1fdfd8977685
1 #!/bin/sh
2 # ensure that stat attempts birthtime access
4 # Copyright (C) 2010-2019 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ stat
22 # Whether birthtime is supported or not, it better not change even when
23 # [acm]time are modified. :)
24 touch a || fail=1
25 btime=$(stat --format %W a) || fail=1
26 atime=$(stat --format %X a) || fail=1
27 mtime=$(stat --format %Y a) || fail=1
28 ctime=$(stat --format %Z a) || fail=1
30 # Wait up to 2.17s for timestamps to change.
31 # ----------------------------------------
32 # iterations file system resolution e.g.
33 # ----------------------------------------
34 # 1 nano or micro second ext4
35 # 4 1 second ext3
36 # 5 2 second FAT
37 # ----------------------------------------
38 check_timestamps_updated()
40 local delay="$1"
41 sleep $delay
42 touch a || fail=1
44 test "x$btime" = x$(stat --format %W a) &&
45 test "x$atime" != x$(stat --format %X a) &&
46 test "x$mtime" != x$(stat --format %Y a) &&
47 test "x$ctime" != x$(stat --format %Z a)
49 retry_delay_ check_timestamps_updated .07 5 || fail=1
51 Exit $fail