fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / overlay / 002
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test 002
6 #
7 # Test that calling fsync against a file using the merged directory does not
8 # result in a crash nor fails unexpectedly.
9 #
10 # This is motivated by a change in overlayfs that resulted in a crash (invalid
11 # memory access) when the lower or upper directory belonged to a btrfs file
12 # system.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs overlay
38 _supported_os Linux
39 _require_scratch
40
41 # Remove all files from previous tests
42 _scratch_mkfs
43
44 # Create our test file.
45 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
46 mkdir -p $lowerdir
47 touch $lowerdir/foobar
48
49 _scratch_mount
50
51 # Write some data to our file and fsync it, using the merged directory path.
52 # This should work and not result in a crash.
53 $XFS_IO_PROG -c "pwrite 0 64k" -c "fsync" $SCRATCH_MNT/foobar | _filter_xfs_io
54
55 # success, all done
56 status=0
57 exit