overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / generic / 513
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 513
6 #
7 # Ensure that ctime is updated and capabilities are cleared when reflinking.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12 tmp=/tmp/$$
13 status=1        # failure is the default!
14 trap "_cleanup; exit \$status" 0 1 2 3 15
15
16 _cleanup()
17 {
18         cd /
19         rm -f $tmp.*
20 }
21
22 # get standard environment, filters and checks
23 . ./common/rc
24 . ./common/filter
25 . ./common/reflink
26
27 # real QA test starts here
28 _supported_fs generic
29 _supported_os Linux
30 _require_scratch_reflink
31 _require_command "$GETCAP_PROG" getcap
32 _require_command "$SETCAP_PROG" setcap
33
34 rm -f $seqres.full
35
36 _scratch_mkfs >>$seqres.full 2>&1
37 _scratch_mount
38
39 $XFS_IO_PROG -f -c "pwrite -S 0x18 0 1m" $SCRATCH_MNT/foo >>$seqres.full
40 $XFS_IO_PROG -f -c "pwrite -S 0x20 0 1m" $SCRATCH_MNT/bar >>$seqres.full
41
42 $SETCAP_PROG cap_setgid,cap_setuid+ep $SCRATCH_MNT/bar
43
44 before_cap="$($GETCAP_PROG -v $SCRATCH_MNT/bar)"
45 before_ctime="$(stat -c '%z' $SCRATCH_MNT/bar)"
46
47 sleep 1
48
49 $XFS_IO_PROG -c "reflink $SCRATCH_MNT/foo" $SCRATCH_MNT/bar >> $seqres.full 2>&1
50
51 after_cap="$($GETCAP_PROG -v $SCRATCH_MNT/bar)"
52 after_ctime="$(stat -c '%z' $SCRATCH_MNT/bar)"
53
54 echo "$before_cap $before_ctime" >> $seqres.full
55 echo "$after_cap $after_ctime" >> $seqres.full
56
57 test "$before_cap" != "$after_cap" || echo "Expected capabilities to drop."
58 test "$before_ctime" != "$after_ctime" || echo "Expected ctime to change."
59
60 echo Silence is golden.
61 status=0
62 exit