common/rc: Add _require_{chown,chmod}()
[xfstests-dev.git] / tests / generic / 376
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 376
6 #
7 # Test that if we rename a file, without changing its parent directory, create
8 # a new file that has the old name of the file we renamed, doing an fsync
9 # against the file we renamed works correctly and after a power failure both
10 # files exists.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         _cleanup_flakey
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/dmflakey
30
31 # real QA test starts here
32 _supported_fs generic
33 _require_scratch
34 _require_dm_target flakey
35
36 rm -f $seqres.full
37
38 _scratch_mkfs >>$seqres.full 2>&1
39 _require_metadata_journaling $SCRATCH_DEV
40 _init_flakey
41 _mount_flakey
42
43 # Create our test directories and files.
44 mkdir $SCRATCH_MNT/dir
45 touch $SCRATCH_MNT/dir/foo
46 # Make sure everything is durably persisted.
47 sync
48 mv $SCRATCH_MNT/dir/foo $SCRATCH_MNT/dir/bar
49 touch $SCRATCH_MNT/dir/foo
50 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/dir/bar
51
52 _flakey_drop_and_remount
53
54 echo "Filesystem contents after log replay:"
55 ls -R $SCRATCH_MNT/dir | _filter_scratch
56
57 _unmount_flakey
58 status=0
59 exit