generic: convert tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 236
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 FUJITSU LIMITED. All Rights Reserved.
4 #
5 # FS QA Test No. 236
6 #
7 # Check ctime updated or not if file linked
8 # See also http://marc.info/?l=linux-btrfs&m=127434439020230&w=2
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 _cleanup()
15 {
16         rm -f $TEST_DIR/ouch*
17 }
18
19 here=`pwd`
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 # get standard environment, filters and checks
24 . ./common/rc
25
26 # real QA test starts here
27 _supported_fs generic
28 # only Linux supports fallocate
29 _supported_os Linux
30 _require_test
31
32 rm -f $TEST_DIR/ouch*
33
34 # create a file and get its ctime
35 touch $TEST_DIR/ouch
36 ctime=`stat -c %Z $TEST_DIR/ouch`
37 sleep 1
38
39 # create a link to a file and get existing file's ctime
40 link $TEST_DIR/ouch $TEST_DIR/ouch2
41 ctime2=`stat -c %Z $TEST_DIR/ouch`
42
43 # check ctime updated
44 if [ $ctime2 -le $ctime ]; then
45         echo "ctime: $ctime -> $ctime2 "
46         echo "Fatal error: ctime not updated after link"
47         _cleanup
48         exit 1
49 fi
50
51 echo "Test over."
52 # success, all done
53 status=0
54 exit