generic: test for non-zero used blocks while writing into a file
[xfstests-dev.git] / tests / overlay / 006
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 006
6 #
7 # Test visible whiteout issue after renaming file from lowerdir to a dir in
8 # upperdir.
9 #
10 # Upstream commit 45d117389696 ("ovl: ignore lower entries when checking purity
11 # of non-directory entries") fixed the issue
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs overlay
36 _require_scratch
37
38 echo "Silence is golden"
39
40 # Remove all files from previous tests
41 _scratch_mkfs
42
43 # Create test file/dir before mount
44 mkdir -p $OVL_BASE_SCRATCH_MNT/$OVL_LOWER
45 mkdir -p $OVL_BASE_SCRATCH_MNT/$OVL_UPPER
46 touch $OVL_BASE_SCRATCH_MNT/$OVL_LOWER/lowertestfile
47 mkdir $OVL_BASE_SCRATCH_MNT/$OVL_UPPER/uppertestdir
48
49 _scratch_mount
50
51 # rename lowertestfile to uppertestdir, this triggers copyup and creates
52 # whiteout in $OVL_UPPER
53 mv $SCRATCH_MNT/lowertestfile $SCRATCH_MNT/uppertestdir
54 # the lowertestfile can be removed
55 rm $SCRATCH_MNT/uppertestdir/lowertestfile
56 # no file no whiteout file in upptestdir
57 ls $SCRATCH_MNT/uppertestdir
58
59 # success, all done
60 status=0
61 exit