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
66 $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file
68 echo "Failed to update times on $file" | tee -a $seqres.full
72 tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
73 echo "Checking file: $file Updated timestamp is $tsclamp" >> $seqres.full
74 check_stat $file $tsclamp
83 for TIME in "${TIMESTAMPS[@]}"; do
84 run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time
89 _scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
90 _scratch_mount || _fail "scratch mount failed"
92 _require_timestamp_range $SCRATCH_DEV
94 read tsmin tsmax <<<$(_filesystem_timestamp_range $SCRATCH_DEV)
95 echo min supported timestamp $tsmin >> $seqres.full
96 echo max supported timestamp $tsmax >> $seqres.full
98 # Test timestamps array
100 declare -a TIMESTAMPS=(
111 echo "In memory timestamps update test start" >> $seqres.full
113 # update time on the file
116 run_test $update_time
118 echo "In memory timestamps update complete" >> $seqres.full
120 echo "Unmounting and mounting scratch $SCRATCH_MNT" >> $seqres.full
122 # unmount and remount $SCRATCH_DEV
129 # Do not update time on the file this time, just read from disk
132 echo "On disk timestamps update test start" >> $seqres.full
135 run_test $update_time
137 echo "On disk timestamps update test complete" >> $seqres.full
139 echo Silence is golden