2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019 Oracle, Inc. All Rights Reserved.
7 # Check that statx btime (aka creation time) is plausibly close to when
8 # we created a file. A bug caught during code review of xfs patches revealed
9 # that there weren't any sanity checks of the btime values.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 testfile=$TEST_DIR/$seq.txt
17 trap "_cleanup; exit \$status" 0 1 2 3 15
22 rm -f $tmp.* $testfile
25 # get standard environment, filters and checks
30 # real QA test starts here
34 _require_xfs_io_command "statx" "-r"
40 # Create a file and the time we created it
44 # Make sure the reported btime is within 5 seconds of the time we recorded
45 # just prior to creating the file.
46 btime=$(date +%s -d "$($XFS_IO_PROG -c "statx -v -m $STATX_BTIME" $testfile | \
47 grep 'stat.btime =' | cut -d '=' -f 2)")
48 test -n "$btime" || echo "error: did not see btime in output??"
50 _within_tolerance "btime" "$btime" "$now" 0 5 -v