common: print hints for reasons of test failures
[xfstests-dev.git] / tests / overlay / 022
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
4 #
5 # FS QA Test 022
6 #
7 # Regression test for kernel commit:
8 #     76bc8e2 ovl: disallow overlayfs as upperdir
9 #
10 # This reproducer was originally written by
11 #     Miklos Szeredi <mszeredi@redhat.com>
12 #
13 . ./common/preamble
14 _begin_fstest auto quick mount nested
15
16 # Override the default cleanup function.
17 _cleanup()
18 {
19         cd /
20         $UMOUNT_PROG $tmp/mnt > /dev/null 2>&1
21         rm -rf $tmp
22         rm -f $tmp.*
23 }
24
25 # Import common functions.
26 . ./common/filter
27
28 # real QA test starts here
29
30 # Modify as appropriate.
31 _supported_fs overlay
32 _fixed_by_kernel_commit 76bc8e2843b6 "ovl: disallow overlayfs as upperdir"
33
34 _require_scratch
35
36 # Remove all files from previous tests
37 _scratch_mkfs
38
39 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
40 mkdir -p $upperdir/upper
41 mkdir -p $upperdir/work
42 # mount overlay with dirs in upper
43 _scratch_mount
44
45 mkdir -p $tmp/{lower,mnt}
46 # mount overlay using upper from another overlay upper
47 # should fail
48 _overlay_mount_dirs $tmp/lower $SCRATCH_MNT/upper \
49   $SCRATCH_MNT/work overlay $tmp/mnt > /dev/null 2>&1
50 if [ $? -ne 0 ] ; then
51         echo "Silence is golden"
52 else
53         echo "Test Fail"
54         echo "Overlay upperdir can't be another overlay upperdir"
55 fi
56
57 # success, all done
58 status=0
59 exit