generic: convert tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 277
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test No. 277
6 #
7 # Check if ctime update caused by chattr is written to disk
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 status=1        # failure is the default!
14
15 _cleanup()
16 {
17     rm -f $SCRATCH_MNT/tmp*
18 }
19
20 trap "_cleanup ; exit \$status" 0 1 2 3 15
21
22 # get standard environment, filters and checks
23 . ./common/rc
24 . ./common/filter
25 . ./common/attr
26
27 # real QA test starts here
28 _supported_fs generic
29 _supported_os Linux
30 _require_scratch
31 _require_chattr A
32
33 _scratch_mkfs > /dev/null 2>&1
34 _scratch_mount
35
36 touch $SCRATCH_MNT/tmp
37 _scratch_cycle_mount
38 ctime1=`stat -c %z $SCRATCH_MNT/tmp`
39
40 sleep 1
41 $CHATTR_PROG +A $SCRATCH_MNT/tmp
42 $CHATTR_PROG -A $SCRATCH_MNT/tmp
43 ctime2=`stat -c %z $SCRATCH_MNT/tmp`
44
45 _scratch_cycle_mount
46 ctime3=`stat -c %z $SCRATCH_MNT/tmp`
47
48 if [ "$ctime1" == "$ctime2" ]; then
49         echo "error: ctime not updated after chattr"
50 elif [ "$ctime1" == "$ctime3" ]; then
51         echo "error: on disk ctime not updated"
52 else
53         status=0
54 fi
55
56 exit