generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / overlay / 013
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 013
6 #
7 # Test truncate running executable binaries from lower and upper dirs.
8 # truncate(2) should return ETXTBSY, not other errno nor segfault
9 #
10 # Commit 03bea6040932 ("ovl: get_write_access() in truncate") fixed this issue.
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 rm -f $seqres.full
31
32 # real QA test starts here
33 _supported_fs overlay
34 _require_scratch
35 _require_test_program "t_truncate_self"
36
37 # remove all files from previous runs
38 _scratch_mkfs
39
40 # copy test program to lower and upper dir
41 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
42 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
43 mkdir -p $lowerdir
44 mkdir -p $upperdir
45 cp $here/src/t_truncate_self $lowerdir/test_lower
46 cp $here/src/t_truncate_self $upperdir/test_upper
47
48 _scratch_mount
49
50 # run test program from lower and upper dir
51 # test programs truncate themselfs, all should fail with ETXTBSY
52 $SCRATCH_MNT/test_lower --may-succeed
53 $SCRATCH_MNT/test_upper
54
55 # success, all done
56 echo "Silence is golden"
57 status=0
58 exit