fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 322
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
4 #
5 # FS QA Test No. 322
6 #
7 # Runs various rename fsync tests to cover some rename fsync corner cases.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick metadata log
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15         _cleanup_flakey
16 }
17
18 # Import common functions.
19 . ./common/filter
20 . ./common/dmflakey
21
22 # real QA test starts here
23 _supported_fs generic
24 _require_scratch_nocheck
25 _require_dm_target flakey
26
27 _clean_working_dir()
28 {
29         _mount_flakey
30         rm -rf $SCRATCH_MNT/foo $SCRATCH_MNT/bar
31         _unmount_flakey
32 }
33
34 # Btrfs wasn't making sure the new file after rename survived the fsync
35 _rename_test()
36 {
37         echo "fsync rename test"
38         _mount_flakey
39         $XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" $SCRATCH_MNT/foo \
40                 >> $seqres.full 2>&1
41         mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar
42         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
43         md5sum $SCRATCH_MNT/bar | _filter_scratch
44
45         _flakey_drop_and_remount
46
47         md5sum $SCRATCH_MNT/bar | _filter_scratch
48         _unmount_flakey
49         _check_scratch_fs $FLAKEY_DEV
50         [ $? -ne 0 ] && _fatal "fsck failed"
51 }
52
53 # Btrfs was dropping some of the modified extents in between fsyncs if we
54 # renamed.
55 _write_after_fsync_rename_test()
56 {
57         echo "fsync rename test"
58         _mount_flakey
59         $XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" -c "pwrite 2M 1M" \
60                 -c "sync_range -b 2M 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1
61         mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar
62         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
63         md5sum $SCRATCH_MNT/bar | _filter_scratch
64
65         _flakey_drop_and_remount
66
67         md5sum $SCRATCH_MNT/bar | _filter_scratch
68         _unmount_flakey
69 }
70
71 _scratch_mkfs >> $seqres.full 2>&1
72 _require_metadata_journaling $SCRATCH_DEV
73
74 # Create a basic flakey device that will never error out
75 _init_flakey
76
77 _rename_test
78 _clean_working_dir
79 _write_after_fsync_rename_test
80
81 status=0
82 exit