2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Deepa Dinamani. All Rights Reserved.
7 # Test to verify filesystem timestamps for supported ranges.
9 # Exit status 1: test failed.
10 # Exit status 0: test passed.
13 _begin_fstest auto quick rw bigtime
15 # Get standard environment, filters and checks.
19 # Prerequisites for the test run.
23 _require_xfs_io_command utimes
25 # Compare file timestamps obtained from stat
26 # with a given timestamp.
32 stat_timestamp=`stat -c"%X;%Y" $file`
34 prev_timestamp="$timestamp;$timestamp"
35 if [ $prev_timestamp != $stat_timestamp ]; then
36 echo "$prev_timestamp != $stat_timestamp" | tee -a $seqres.full
46 # check if the time needs update
47 if [ $update_time -eq 1 ]; then
48 echo "Updating file: $file to timestamp $timestamp" >> $seqres.full
50 $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file > $tmp.utimes 2>&1
53 cat $tmp.utimes >> $seqres.full
54 if [ "$timestamp" -ne 0 ] && grep -q "Bad value" "$tmp.utimes"; then
55 echo "xfs_io could not interpret time value \"$timestamp\", skipping \"$file\" test." >> $seqres.full
56 rm -f $file $tmp.utimes
61 if [ $res -ne 0 ]; then
62 echo "Failed to update times on $file" | tee -a $seqres.full
65 if [ ! -f "$file" ]; then
66 echo "xfs_io did not create file for time value \"$timestamp\", skipping test." >> $seqres.full
71 tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
72 echo "Checking file: $file Updated timestamp is $tsclamp" >> $seqres.full
73 check_stat $file $tsclamp
82 for TIME in "${TIMESTAMPS[@]}"; do
83 run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time
88 _scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
91 _require_timestamp_range $SCRATCH_DEV
93 read tsmin tsmax <<<$(_filesystem_timestamp_range $SCRATCH_DEV)
94 echo min supported timestamp $tsmin >> $seqres.full
95 echo max supported timestamp $tsmax >> $seqres.full
97 # Test timestamps array
99 declare -a TIMESTAMPS=(
110 echo "In memory timestamps update test start" >> $seqres.full
112 # update time on the file
115 run_test $update_time
117 echo "In memory timestamps update complete" >> $seqres.full
119 echo "Unmounting and mounting scratch $SCRATCH_MNT" >> $seqres.full
121 # unmount and remount $SCRATCH_DEV
128 # Do not update time on the file this time, just read from disk
131 echo "On disk timestamps update test start" >> $seqres.full
134 run_test $update_time
136 echo "On disk timestamps update test complete" >> $seqres.full
138 echo Silence is golden