generic/402: Drop useless fail message
[xfstests-dev.git] / tests / generic / 283
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. 283
6 #
7 # Test mmap CoW behavior when the write temporarily fails but the userspace
8 # program writes again.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
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     cd /
22     rm -rf $tmp.* $TEST_DIR/mwrite.out
23     _dmerror_cleanup
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/reflink
30 . ./common/dmerror
31
32 # real QA test starts here
33 _require_scratch_reflink
34 _require_cp_reflink
35 _require_dm_target error
36
37 rm -f $seqres.full
38
39
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
42 _dmerror_init
43 _dmerror_mount >> $seqres.full 2>&1
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
54 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
55
56 echo "Create the original files"
57 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
58 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
59 _dmerror_unmount
60 _dmerror_mount
61
62 echo "Compare files"
63 md5sum $testdir/file1 | _filter_scratch
64 md5sum $testdir/file2 | _filter_scratch
65
66 echo "CoW and unmount"
67 sync
68 _dmerror_load_error_table
69 # Insulate ourselves against bash reporting the SIGBUS when we try to modify
70 # the metadata.
71 cat > $tmp.run << ENDL
72 ulimit -c 0
73 $XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \
74         -c "msync -s 0 $filesize" $testdir/file2 2>&1
75 ENDL
76 bash $tmp.run > $tmp.output 2>&1
77 cat $tmp.output >> $seqres.full
78 grep -q error $tmp.output || _fail "mwrite did not fail"
79 _dmerror_load_working_table
80
81 echo "Rewrite"
82 $XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" -c "msync 0 $filesize" $testdir/file2 >> $seqres.full 2>&1
83 _dmerror_unmount
84 _dmerror_mount
85
86 echo "Compare files"
87 md5sum $testdir/file1 | _filter_scratch
88
89 echo "Check for damage"
90 _dmerror_unmount
91 _dmerror_cleanup
92 _repair_scratch_fs >> $seqres.full
93
94 # success, all done
95 status=0
96 exit