generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 251
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2021 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test 251
6 #
7 # Test if btrfs will crash when using compress-force mount option against
8 # incompressible data
9 #
10 . ./common/preamble
11 _begin_fstest auto quick compress dangerous
12
13 # Import common functions.
14 . ./common/filter
15
16 # real QA test starts here
17
18 # Modify as appropriate.
19 _supported_fs btrfs
20 _require_scratch
21
22 pagesize=$(get_page_size)
23
24 # Read the content from urandom to a known safe location
25 $XFS_IO_PROG -f -c "pwrite -i /dev/urandom 0 $pagesize" "$tmp.good" > /dev/null
26
27 # Make sure we didn't get short write
28 if [ $(_get_filesize "$tmp.good") != "$pagesize" ]; then
29         _fail "Got a short read from /dev/urandom"
30 fi
31
32 workload()
33 {
34         local compression=$1
35
36         echo "=== Testing compress-force=$compression ==="
37         _scratch_mkfs -s "$pagesize">> $seqres.full
38         _scratch_mount -o compress-force="$compression"
39         cp "$tmp.good" "$SCRATCH_MNT/$compression"
40
41         # When unpatched, compress-force=lzo would crash at data writeback
42         _scratch_cycle_mount
43
44         # Make sure the content matches
45         if [ "$(_md5_checksum $tmp.good)" != \
46              "$(_md5_checksum $SCRATCH_MNT/$compression)" ]; then
47                 echo "Content of '$SCRATCH_MNT/file' mismatch with known good copy"
48         else
49                 echo "OK"
50         fi
51         _scratch_unmount
52 }
53
54 workload lzo
55 workload zstd
56 workload zlib
57
58 # success, all done
59 status=0
60 exit