overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / overlay / 001
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
4 #
5 # FS QA Test 001
6 #
7 # Test copy up files from lower dir that are <, =, > 4G in size.
8 #
9 # Kernel commit 0480334fa604 ("ovl: use O_LARGEFILE in ovl_copy_up()")
10 # fixed bug when copying up large file from lower dir.
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 -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs overlay
36 _supported_os Linux
37 _require_scratch
38
39 # Remove all files from previous tests
40 _scratch_mkfs
41
42 # overlay copy_up doesn't deal with sparse file well, holes will be filled by
43 # zeros, so at least (4G + 4G + 8k) free space is needed on scratch base fs
44 _require_fs_space $OVL_BASE_SCRATCH_MNT $((4*1024*1024*2 + 8))
45
46 # Create test files with different sizes in lower dir
47 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
48 mkdir -p $lowerdir
49 touch $lowerdir/zero_size
50 $XFS_IO_PROG -fc "pwrite 0 4k" $lowerdir/less_than_4g >>$seqres.full
51 $XFS_IO_PROG -fc "pwrite 4294963200 4k" $lowerdir/4gfile >>$seqres.full
52 $XFS_IO_PROG -fc "pwrite 4g 4k" $lowerdir/larger_than_4g >>$seqres.full
53
54 _scratch_mount
55
56 echo "Silence is golden"
57
58 # Open the files should succeed, no errors are expected (e.g. EFBIG)
59 for f in $SCRATCH_MNT/*; do
60         $XFS_IO_PROG -c "open" $f >>$seqres.full
61 done
62
63 # success, all done
64 status=0
65 exit