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 _begin_fstest auto quick
13 testfile=$TEST_DIR/$seq.txt
15 # Override the default cleanup function.
19 rm -f $tmp.* $testfile
22 # Import common functions.
26 # real QA test starts here
29 _require_xfs_io_command "statx" "-r"
34 # Create a file and the time we created it
38 # Make sure the reported btime is within 5 seconds of the time we recorded
39 # just prior to creating the file.
40 btime=$(date +%s -d "$($XFS_IO_PROG -c "statx -v -m $STATX_BTIME" $testfile | \
41 grep 'stat.btime =' | cut -d '=' -f 2)")
42 test -n "$btime" || echo "error: did not see btime in output??"
44 _within_tolerance "btime" "$btime" "$now" 0 5 -v