fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 281
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. 281
6 #
7 # Test mmap CoW behavior when the write permanently fails.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick clone eio
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15     cd /
16     rm -rf $tmp.* $TEST_DIR/mwrite.out
17     _dmerror_cleanup
18 }
19
20 # Import common functions.
21 . ./common/filter
22 . ./common/reflink
23 . ./common/dmerror
24
25 # real QA test starts here
26 _require_scratch_reflink
27 _require_cp_reflink
28 _require_dm_target error
29
30 echo "Format and mount"
31 _scratch_mkfs > $seqres.full 2>&1
32 _dmerror_init
33 _dmerror_mount >> $seqres.full 2>&1
34
35 testdir=$SCRATCH_MNT/test-$seq
36 mkdir $testdir
37
38 blksz=65536
39 nr=640
40 bufnr=128
41 filesize=$((blksz * nr))
42 bufsize=$((blksz * bufnr))
43
44 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
45
46 echo "Create the original files"
47 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
48 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
49 _dmerror_unmount
50 _dmerror_mount
51
52 echo "Compare files"
53 md5sum $testdir/file1 | _filter_scratch
54 md5sum $testdir/file2 | _filter_scratch
55
56 echo "CoW and unmount"
57 sync
58 _dmerror_load_error_table
59 # Insulate ourselves against bash reporting the SIGBUS when we try to modify
60 # the metadata.
61 cat > $tmp.run << ENDL
62 ulimit -c 0
63 $XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \
64         -c "msync -s 0 $filesize" $testdir/file2 >> $seqres.full 2>&1
65 ENDL
66 bash $tmp.run 2> /dev/null
67
68 echo "Clean up the mess"
69 _dmerror_unmount
70 _dmerror_cleanup
71 _repair_scratch_fs >> $seqres.full
72 _scratch_mount >> $seqres.full 2>&1
73
74 echo "Compare files"
75 md5sum $testdir/file1 | _filter_scratch
76
77 # success, all done
78 status=0
79 exit