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 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # Get standard environment, filters and checks.
32 # remove previous $seqres.full before test
35 # Prerequisites for the test run.
40 _require_xfs_io_command utimes
42 # Compare file timestamps obtained from stat
43 # with a given timestamp.
49 stat_timestamp=`stat -c"%X;%Y" $file`
51 prev_timestamp="$timestamp;$timestamp"
52 if [ $prev_timestamp != $stat_timestamp ]; then
53 echo "$prev_timestamp != $stat_timestamp" | tee -a $seqres.full
63 # check if the time needs update
64 if [ $update_time -eq 1 ]; then
65 echo "Updating file: $file to timestamp $timestamp" >> $seqres.full
67 $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file > $tmp.utimes 2>&1
70 cat $tmp.utimes >> $seqres.full
71 if [ "$timestamp" -ne 0 ] && grep -q "Bad value" "$tmp.utimes"; then
72 echo "xfs_io could not interpret time value \"$timestamp\", skipping \"$file\" test." >> $seqres.full
73 rm -f $file $tmp.utimes
78 if [ $res -ne 0 ]; then
79 echo "Failed to update times on $file" | tee -a $seqres.full
82 if [ ! -f "$file" ]; then
83 echo "xfs_io did not create file for time value \"$timestamp\", skipping test." >> $seqres.full
88 tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
89 echo "Checking file: $file Updated timestamp is $tsclamp" >> $seqres.full
90 check_stat $file $tsclamp
99 for TIME in "${TIMESTAMPS[@]}"; do
100 run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time
105 _scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
106 _scratch_mount || _fail "scratch mount failed"
108 _require_timestamp_range $SCRATCH_DEV
110 read tsmin tsmax <<<$(_filesystem_timestamp_range $SCRATCH_DEV)
111 echo min supported timestamp $tsmin >> $seqres.full
112 echo max supported timestamp $tsmax >> $seqres.full
114 # Test timestamps array
116 declare -a TIMESTAMPS=(
127 echo "In memory timestamps update test start" >> $seqres.full
129 # update time on the file
132 run_test $update_time
134 echo "In memory timestamps update complete" >> $seqres.full
136 echo "Unmounting and mounting scratch $SCRATCH_MNT" >> $seqres.full
138 # unmount and remount $SCRATCH_DEV
145 # Do not update time on the file this time, just read from disk
148 echo "On disk timestamps update test start" >> $seqres.full
151 run_test $update_time
153 echo "On disk timestamps update test complete" >> $seqres.full
155 echo Silence is golden