common/rc: add _scratch_{u}mount_idmapped() helpers
[xfstests-dev.git] / tests / generic / 180
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 180
6 #
7 # Ensure that unaligned zero-range steps around reflinked ranges:
8 #   - Create a reflink clone of a file
9 #   - Perform an unaligned zero-range in the middle of the file.
10 #   - Check that the reflinked areas are still there.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     cd /
24     rm -rf $tmp.* $testdir
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/reflink
31
32 # real QA test starts here
33 _require_test_reflink
34 _require_cp_reflink
35 _require_xfs_io_command "fzero"
36
37 rm -f $seqres.full
38
39 testdir=$TEST_DIR/test-$seq
40 rm -rf $testdir
41 mkdir $testdir
42
43 echo "Create the original files"
44 blksz=65536
45 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file1 >> $seqres.full
46
47 _cp_reflink $testdir/file1 $testdir/file2
48
49 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file2.chk >> $seqres.full
50 _pwrite_byte 0x00 $((blksz - 17)) $((blksz + 17)) $testdir/file2.chk >> $seqres.full
51 _test_cycle_mount
52
53 md5sum $testdir/file1 | _filter_test_dir
54 md5sum $testdir/file2 | _filter_test_dir
55 md5sum $testdir/file2.chk | _filter_test_dir
56
57 c1=$(_md5_checksum $testdir/file1)
58 c2=$(_md5_checksum $testdir/file2)
59
60 test ${c1} = ${c2} || echo "file1 and file2 should match"
61
62 echo "fzero files"
63 $XFS_IO_PROG -f -c "fzero $((blksz - 17)) $((blksz + 17))" $testdir/file2
64 _test_cycle_mount
65
66 echo "Compare files"
67 md5sum $testdir/file1 | _filter_test_dir
68 md5sum $testdir/file2 | _filter_test_dir
69 md5sum $testdir/file2.chk | _filter_test_dir
70
71 c1=$(_md5_checksum $testdir/file1)
72 c2=$(_md5_checksum $testdir/file2)
73
74 test ${c1} != ${c2} || echo "file1 and file2 should not match"
75
76 echo "Compare against check files"
77 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
78
79 # success, all done
80 status=0
81 exit