summaryrefslogtreecommitdiff
path: root/tests/generic/513
blob: dc082787ae4e776964d802b72565fda7b0ce0fb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
#
# FS QA Test No. 513
#
# Ensure that ctime is updated and capabilities are cleared when reflinking.
#
. ./common/preamble
_begin_fstest auto quick clone

# Import common functions.
. ./common/filter
. ./common/reflink

# real QA test starts here
_supported_fs generic
_require_scratch_reflink
_require_command "$GETCAP_PROG" getcap
_require_command "$SETCAP_PROG" setcap

_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount

$XFS_IO_PROG -f -c "pwrite -S 0x18 0 1m" $SCRATCH_MNT/foo >>$seqres.full
$XFS_IO_PROG -f -c "pwrite -S 0x20 0 1m" $SCRATCH_MNT/bar >>$seqres.full

$SETCAP_PROG cap_setgid,cap_setuid+ep $SCRATCH_MNT/bar

before_cap="$(_getcap -v $SCRATCH_MNT/bar)"
before_ctime="$(stat -c '%z' $SCRATCH_MNT/bar)"

sleep 1

$XFS_IO_PROG -c "reflink $SCRATCH_MNT/foo" $SCRATCH_MNT/bar >> $seqres.full 2>&1

after_cap="$(_getcap -v $SCRATCH_MNT/bar)"
after_ctime="$(stat -c '%z' $SCRATCH_MNT/bar)"

echo "$before_cap $before_ctime" >> $seqres.full
echo "$after_cap $after_ctime" >> $seqres.full

test "$before_cap" != "$after_cap" || echo "Expected capabilities to drop."
test "$before_ctime" != "$after_ctime" || echo "Expected ctime to change."

echo Silence is golden.
status=0
exit