xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 245
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 Christoph Hellwig.  All Rights Reserved.
4 #
5 # FS QA Test No. 245
6 #
7 # Check that directory renames onto non-empty targets fail
8 #
9 # Based on a bug report and testcase from  Vlado Plaga <rechner@vlado-do.de>
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18
19 # get standard environment, filters and checks
20 . ./common/rc
21 . ./common/filter
22
23 # real QA test starts here
24 _supported_fs generic
25 _require_test
26
27 dir=$TEST_DIR/test-mv
28
29 _cleanup()
30 {
31         rm -rf $dir
32 }
33
34 # According to the rename(2) manpage you can get either EEXIST or ENOTEMPTY as an
35 # error for trying to rename a non-empty directory, so just catch the error for
36 # ENOTMEMPTY and replace it with the EEXIST output so that either result passes
37 _filter_directory_not_empty()
38 {
39         sed -e "s,Directory not empty,File exists,g"
40 }
41  
42 trap "_cleanup ; exit \$status" 0 1 2 3 15
43
44 mkdir $dir
45
46 mkdir $dir/aa
47 mkdir $dir/ab
48 touch $dir/aa/1
49 mkdir $dir/ab/aa
50 touch $dir/ab/aa/2
51
52 mv $dir/ab/aa/ $dir 2>&1 | _filter_test_dir | _filter_directory_not_empty
53
54 status=0
55 exit $status