fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / ext4 / 031
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017-2018 Intel Corporation.  All Rights Reserved.
4 #
5 # FS QA Test ext4/031
6 #
7 # This is a regression test for kernel patch:
8 #   ext4: prevent data corruption with inline data + DAX
9 # created by Ross Zwisler <ross.zwisler@linux.intel.com>
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # DAX needs to be off so we can create an inode with inline data
34 SAVE_MOUNT_OPTIONS="$MOUNT_OPTIONS"
35 MOUNT_OPTIONS=""
36
37 # Modify as appropriate.
38 _supported_os Linux
39 _supported_fs ext4
40 _require_scratch_dax
41 _require_test_program "t_ext4_dax_inline_corruption"
42 _require_scratch_ext4_feature "inline_data"
43
44 # real QA test starts here
45 _scratch_mkfs_ext4 -O inline_data > $seqres.full 2>&1
46
47 TESTFILE=$SCRATCH_MNT/testfile
48
49 _scratch_mount  >> $seqres.full 2>&1
50
51 echo "Need to make some inline data..." > $TESTFILE
52
53 export MOUNT_OPTIONS="$SAVE_MOUNT_OPTIONS"
54
55 _scratch_unmount >> $seqres.full 2>&1
56 _scratch_mount "-o dax" >> $seqres.full 2>&1
57
58 if [[ $? != 0 ]]; then
59         # _require_scratch_dax already verified that we could mount with DAX.
60         # Failure here is expected because we have inline data.
61         echo "Silence is golden"
62         status=0
63         exit
64 fi
65
66 $here/src/t_ext4_dax_inline_corruption $TESTFILE
67
68 # success, all done
69 echo "Silence is golden"
70 status=0
71 exit