xfstests: introduce a common directory
[xfstests-dev.git] / tests / generic / 123
1 #! /bin/bash
2 # FSQA Test No. 123
3 #
4 # Make sure user cannot overwrite, append, delete or move a file created by 
5 # root. Modified CXFSQA test 940960 and 940558.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=0        # success is the default!
35
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 _cleanup()
39 {
40     cd $testdir
41     rm -rf $my_test_subdir
42     cd /
43     _cleanup_testdir
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # real QA test starts here
51 _supported_fs generic
52 _supported_os Linux IRIX
53
54 _require_user
55
56 _setup_testdir
57 my_test_subdir=$testdir/123subdir
58
59 # create subdir with required permissions
60 mkdir -m 755 $my_test_subdir
61
62 echo foo > $my_test_subdir/data_coherency.txt
63 # check basic appending to a file
64 echo bar >> $my_test_subdir/data_coherency.txt
65
66 # try append
67 _user_do "echo goo >> $my_test_subdir/data_coherency.txt" 
68
69 # try overwrite 
70 _user_do "echo goo > $my_test_subdir/data_coherency.txt" 
71
72 # try delete
73 _user_do "rm $my_test_subdir/data_coherency.txt" 
74
75 # try move
76 _user_do "mv $my_test_subdir/data_coherency.txt $my_test_subdir/data_coherency2.txt" 
77
78 cat $my_test_subdir/data_coherency.txt
79
80
81 exit