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.
39 _require_xfs_io_command utimes
41 # Compare file timestamps obtained from stat
42 # with a given timestamp.
48 stat_timestamp=`stat -c"%X;%Y" $file`
50 prev_timestamp="$timestamp;$timestamp"
51 if [ $prev_timestamp != $stat_timestamp ]; then
52 echo "$prev_timestamp != $stat_timestamp" | tee -a $seqres.full
62 # check if the time needs update
63 if [ $update_time -eq 1 ]; then
64 echo "Updating file: $file to timestamp $timestamp" >> $seqres.full
66 $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file > $tmp.utimes 2>&1
69 cat $tmp.utimes >> $seqres.full
70 if [ "$timestamp" -ne 0 ] && grep -q "Bad value" "$tmp.utimes"; then
71 echo "xfs_io could not interpret time value \"$timestamp\", skipping \"$file\" test." >> $seqres.full
72 rm -f $file $tmp.utimes
77 if [ $res -ne 0 ]; then
78 echo "Failed to update times on $file" | tee -a $seqres.full
81 if [ ! -f "$file" ]; then
82 echo "xfs_io did not create file for time value \"$timestamp\", skipping test." >> $seqres.full
87 tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
88 echo "Checking file: $file Updated timestamp is $tsclamp" >> $seqres.full
89 check_stat $file $tsclamp
98 for TIME in "${TIMESTAMPS[@]}"; do
99 run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time
104 _scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
105 _scratch_mount || _fail "scratch mount failed"
107 _require_timestamp_range $SCRATCH_DEV
109 read tsmin tsmax <<<$(_filesystem_timestamp_range $SCRATCH_DEV)
110 echo min supported timestamp $tsmin >> $seqres.full
111 echo max supported timestamp $tsmax >> $seqres.full
113 # Test timestamps array
115 declare -a TIMESTAMPS=(
126 echo "In memory timestamps update test start" >> $seqres.full
128 # update time on the file
131 run_test $update_time
133 echo "In memory timestamps update complete" >> $seqres.full
135 echo "Unmounting and mounting scratch $SCRATCH_MNT" >> $seqres.full
137 # unmount and remount $SCRATCH_DEV
144 # Do not update time on the file this time, just read from disk
147 echo "On disk timestamps update test start" >> $seqres.full
150 run_test $update_time
152 echo "On disk timestamps update test complete" >> $seqres.full
154 echo Silence is golden