fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / ocfs2 / 001
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 001
6 #
7 # Ensure that reflink works correctly with inline-data files.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28
29 # real QA test starts here
30 _supported_os Linux
31 _supported_fs ocfs2
32 _require_scratch_reflink
33 _require_cp_reflink
34
35 rm -f $seqres.full
36
37 echo "Format and mount"
38 _scratch_mkfs --fs-features=local,unwritten,refcount,inline-data > $seqres.full 2>&1
39 tunefs.ocfs2 --query '%H' $SCRATCH_DEV | grep -q 'inline-data' || \
40         _notrun "Inline data is not supported."
41 _scratch_mount >> $seqres.full 2>&1
42
43 testdir=$SCRATCH_MNT/test-$seq
44 mkdir $testdir
45
46 sz=65536
47 echo "Create the original files"
48 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
49 echo x > $testdir/file2
50 echo x > $testdir/file3
51 echo y > $testdir/file4
52 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file5 >> $seqres.full
53 echo a > $testdir/file6
54 _scratch_cycle_mount
55
56 echo "reflink into the start of file2"
57 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
58
59 echo "reflink past the stuff in file3"
60 _reflink_range $testdir/file1 0 $testdir/file3 $sz $sz >> $seqres.full
61
62 echo "reflink an inline-data file to a regular one"
63 _cp_reflink $testdir/file4 $testdir/file5 >> $seqres.full
64
65 echo "reflink an inline-data file to another inline-data file"
66 _cp_reflink $testdir/file4 $testdir/file6 >> $seqres.full
67
68 echo "Verify the whole mess"
69 _scratch_cycle_mount
70 md5sum $testdir/file* | _filter_scratch
71
72 # success, all done
73 status=0
74 exit