Add GPL license plate to SGI's test files.
[xfstests-dev.git] / 094
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 #
19 #-----------------------------------------------------------------------
20 #
21 # FS QA Test No. 094
22 #
23 # Exercising the inheritable realtime inode bit.
24 #
25 # creator
26 owner=nathans@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38     cd /
39     rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45
46 # real QA test starts here
47 _supported_fs xfs
48 _supported_os IRIX Linux
49 _require_realtime
50 _require_scratch
51 _require_command /usr/sbin/xfs_io
52
53 _filter_realtime_flag()
54 {
55         _test_inode_flag realtime $SCRATCH_MNT/testdir/$1
56         if [ $? -eq 0 ]; then
57                 echo "--r-- SCRATCH_MNT/testdir/$1"
58         else
59                 echo "----- SCRATCH_MNT/testdir/$1"
60         fi
61 }
62
63 _filter_rtinherit_flag()
64 {
65         _test_inode_flag rt-inherit $SCRATCH_MNT/testdir
66         if [ $? -eq 0 ]; then
67                 echo "--t-- SCRATCH_MNT/testdir"
68         else
69                 echo "----- SCRATCH_MNT/testdir"
70         fi
71 }
72
73 _create_scratch()
74 {
75         echo "*** mkfs"
76         if ! _scratch_mkfs_xfs >$tmp.out 2>&1
77         then
78                 cat $tmp.out
79                 echo "failed to mkfs $SCRATCH_DEV"
80                 exit 1
81         fi
82
83         echo "*** mount"
84         if ! _scratch_mount
85         then
86                 echo "failed to mount $SCRATCH_DEV"
87                 exit 1
88         fi
89 }
90
91 _create_scratch
92 mkdir $SCRATCH_MNT/testdir
93
94 # set inode attribute, create files below and check they're marked realtime
95 # unset inode attribute, create files below and check they're not realtime
96
97 echo "*** create directory with rtinherit"
98 $XFS_IO_PROG -r -c 'chattr +t' $SCRATCH_MNT/testdir
99 _filter_rtinherit_flag
100
101 echo "*** create child with inherited realtime"
102 touch $SCRATCH_MNT/testdir/real
103 _filter_realtime_flag real
104
105 echo "*** remove rtinherit from directory"
106 $XFS_IO_PROG -r -c 'chattr -t' $SCRATCH_MNT/testdir
107 _filter_rtinherit_flag
108
109 echo "*** create child without inherited realtime"
110 touch $SCRATCH_MNT/testdir/unreal
111 _filter_realtime_flag unreal
112
113 echo "*** done"
114
115 # success, all done
116 status=0
117 exit