tests: remove udf/101
[xfstests-dev.git] / tests / generic / 335
1 #! /bin/bash
2 # FSQA Test No. 335
3 #
4 # Test that if we move one file between directories, fsync the parent directory
5 # of the old directory, power fail and remount the filesystem, the file is not
6 # lost and it's located at the destination directory.
7 #
8 #-----------------------------------------------------------------------
9 #
10 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
11 # Author: Filipe Manana <fdmanana@suse.com>
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37         _cleanup_flakey
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45 . ./common/dmflakey
46
47 # real QA test starts here
48 _supported_fs generic
49 _supported_os Linux
50 _require_scratch
51 _require_dm_target flakey
52 _require_metadata_journaling $SCRATCH_DEV
53
54 rm -f $seqres.full
55
56 _scratch_mkfs >>$seqres.full 2>&1
57 _init_flakey
58 _mount_flakey
59
60 # Create our test directories and the file we will later check if it has
61 # disappeared.
62 mkdir -p $SCRATCH_MNT/a/b
63 mkdir $SCRATCH_MNT/c
64 touch $SCRATCH_MNT/a/b/foo
65
66 # Make sure everything is durably persisted.
67 sync
68
69 # Now move our test file into a new parent directory.
70 mv $SCRATCH_MNT/a/b/foo $SCRATCH_MNT/c/
71
72 # Create a new file inside the parent directory of the directory where our test
73 # file foo was previously at. This is just to ensure the fsync we do next
74 # against that parent directory actually does something and it's not a noop.
75 touch $SCRATCH_MNT/a/bar
76 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a
77
78 echo "Filesystem content before power failure:"
79 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch
80
81 # Simulate a power failure / crash and remount the filesystem, so that the
82 # journal/log is replayed.
83 _flakey_drop_and_remount
84
85 # We expect our file foo to exist, have an entry in the new parent
86 # directory (c/) and not have anymore an entry in the old parent directory
87 # (a/b/).
88 # The new file named bar should also exist.
89 echo "Filesystem content after power failure:"
90 # Must match what we had before the power failure.
91 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch
92
93 _unmount_flakey
94
95 status=0
96 exit