generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 528
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 528
6 #
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.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 testfile=$TEST_DIR/$seq.txt
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.* $testfile
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/attr
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs generic
32 _supported_os Linux
33 _require_test
34 _require_xfs_io_command "statx" "-r"
35 _require_btime
36
37 rm -f $seqres.full
38 rm -f $testfile
39
40 # Create a file and the time we created it
41 now=$(date +%s)
42 touch $testfile
43
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??"
49
50 _within_tolerance "btime" "$btime" "$now" 0 5 -v
51
52 status=0
53 exit