generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 242
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. 242
6 #
7 # Reflink two large files and CoW them in big chunks.
8 #
9 # This test is dependent on the system page size, so we cannot use md5 in
10 # the golden output; we can only compare to a check file.
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_scratch_reflink
34 _require_cp_reflink
35
36 rm -f $seqres.full
37
38
39 echo "Format and mount"
40 _scratch_mkfs > $seqres.full 2>&1
41 _scratch_mount >> $seqres.full 2>&1
42
43 testdir=$SCRATCH_MNT/test-$seq
44 mkdir $testdir
45
46 blksz=65536
47 nr=6400
48 filesize=$((blksz * nr))
49 bufnr=1280
50 bufsize=$((blksz * bufnr))
51
52 free_blocks=$(stat -f -c '%a' $testdir)
53 real_blksz=$(_get_block_size $testdir)
54 space_needed=$(((filesize * 3) * 5 / 4))
55 space_avail=$((free_blocks * real_blksz))
56 test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
57
58 echo "Create the original files"
59 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
60 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
61 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file2.chk >> $seqres.full
62 _scratch_cycle_mount
63
64 echo "Compare files"
65 md5sum $testdir/file1 | _filter_scratch
66 md5sum $testdir/file2 | _filter_scratch
67 md5sum $testdir/file2.chk | _filter_scratch
68
69 echo "CoW and unmount"
70 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 >> $seqres.full
71 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2.chk >> $seqres.full
72 _scratch_cycle_mount
73
74 echo "Compare files"
75 md5sum $testdir/file1 | _filter_scratch
76 md5sum $testdir/file2 | _filter_scratch
77 md5sum $testdir/file2.chk | _filter_scratch
78
79 # success, all done
80 status=0
81 exit