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 "exit \$status" 0 1 2 3 15
21 # Get standard environment, filters and checks.
26 # remove previous $seqres.full before test
29 # Prerequisites for the test run.
33 _require_xfs_io_command utimes
35 # Compare file timestamps obtained from stat
36 # with a given timestamp.
42 stat_timestamp=`stat -c"%X;%Y" $file`
44 prev_timestamp="$timestamp;$timestamp"
45 if [ $prev_timestamp != $stat_timestamp ]; then
46 echo "$prev_timestamp != $stat_timestamp" | tee -a $seqres.full
56 # check if the time needs update
57 if [ $update_time -eq 1 ]; then
58 echo "Updating file: $file to timestamp $timestamp" >> $seqres.full
59 $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file
61 echo "Failed to update times on $file" | tee -a $seqres.full
65 tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
66 echo "Checking file: $file Updated timestamp is $tsclamp" >> $seqres.full
67 check_stat $file $tsclamp
76 for TIME in "${TIMESTAMPS[@]}"; do
77 run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time
82 _scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
83 _require_timestamp_range $SCRATCH_DEV
85 read tsmin tsmax <<<$(_filesystem_timestamp_range $SCRATCH_DEV)
86 echo min supported timestamp $tsmin >> $seqres.full
87 echo max supported timestamp $tsmax >> $seqres.full
89 # Test timestamps array
91 declare -a TIMESTAMPS=(
99 _scratch_mount || _fail "scratch mount failed"
104 echo "In memory timestamps update test start" >> $seqres.full
106 # update time on the file
109 run_test $update_time
111 echo "In memory timestamps update complete" >> $seqres.full
113 echo "Unmounting and mounting scratch $SCRATCH_MNT" >> $seqres.full
115 # unmount and remount $SCRATCH_DEV
122 # Do not update time on the file this time, just read from disk
125 echo "On disk timestamps update test start" >> $seqres.full
128 run_test $update_time
130 echo "On disk timestamps update test complete" >> $seqres.full
132 echo Silence is golden