e82fbb9f5b77cd0a98e6a127cb7e2a1a40d3b8b5
[xfstests-dev.git] / tests / generic / 245
1 #! /bin/bash
2 # FS QA Test No. 245
3 #
4 # Check that directory renames onto non-empty targets fail
5 #
6 # Based on a bug report and testcase from  Vlado Plaga <rechner@vlado-do.de>
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2010 Christoph Hellwig.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36
37 # get standard environment, filters and checks
38 . ./common/rc
39 . ./common/filter
40
41 # real QA test starts here
42 _supported_fs generic
43 _supported_os Linux
44
45 dir=$TEST_DIR/test-mv
46
47 _cleanup()
48 {
49         rm -rf $dir
50 }
51
52 # According to the rename(2) manpage you can get either EEXIST or ENOTEMPTY as an
53 # error for trying to rename a non-empty directory, so just catch the error for
54 # ENOTMEMPTY and replace it with the EEXIST output so that either result passes
55 _filter_directory_not_empty()
56 {
57         sed -e "s,Directory not empty,File exists,g"
58 }
59  
60 trap "_cleanup ; exit \$status" 0 1 2 3 15
61
62
63 mkdir $dir
64
65 mkdir $dir/aa
66 mkdir $dir/ab
67 touch $dir/aa/1
68 mkdir $dir/ab/aa
69 touch $dir/ab/aa/2
70
71 mv $dir/ab/aa/ $dir 2>&1 | _filter_test_dir | _filter_directory_not_empty
72
73 status=0
74 exit $status