fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 252
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 252
6 #
7 # Create an unwritten extent, set up dm-error, try an AIO DIO write, then
8 # make sure we can't read back old disk contents.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick prealloc rw eio
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16     cd /
17     rm -rf $tmp.* $testdir $TEST_DIR/moo
18     _dmerror_cleanup
19 }
20
21 # Import common functions.
22 . ./common/filter
23 . ./common/dmerror
24
25 # real QA test starts here
26 _require_scratch
27 _require_dm_target error
28 _require_xfs_io_command "falloc"
29 _require_aiodio "aiocp"
30 AIO_TEST="$here/src/aio-dio-regress/aiocp"
31
32 # Disable the scratch rt device to avoid test failures relating to the rt
33 # bitmap consuming all the free space in our small data device.
34 unset SCRATCH_RTDEV
35
36 fssize=$((196 * 1048576))
37 echo "Format and mount"
38 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
39 _scratch_mkfs_sized $fssize > $seqres.full 2>&1
40 _dmerror_init
41 _dmerror_mount >> $seqres.full 2>&1
42 _dmerror_unmount
43 _dmerror_mount
44
45 testdir=$SCRATCH_MNT/test-$seq
46 mkdir $testdir
47
48 blksz=65536
49 nr=640
50 bufnr=128
51 filesize=$((blksz * nr))
52 bufsize=$((blksz * bufnr))
53 alignment=`_min_dio_alignment $TEST_DEV`
54
55 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 5 / 4))
56
57 echo "Create the original files"
58 $XFS_IO_PROG -f -c "falloc 0 $filesize" $testdir/file2 >> $seqres.full
59 _dmerror_unmount
60 _dmerror_mount
61
62 echo "Compare files"
63 md5sum $testdir/file2 | _filter_scratch
64
65 echo "CoW and unmount"
66 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
67 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
68 sync
69 _dmerror_load_error_table
70 $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
71 _dmerror_load_working_table
72 _dmerror_unmount
73 _dmerror_mount
74
75 echo "Compare files"
76 md5sum $testdir/file2 | _filter_scratch
77
78 echo "Check for damage"
79 _dmerror_unmount
80 _dmerror_cleanup
81 _repair_scratch_fs >> $seqres.full
82
83 # success, all done
84 status=0
85 exit