summaryrefslogtreecommitdiff
path: root/tests/generic/532
blob: d356b0da22c3c88a5b4326990f469a21185548c3 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2019 Oracle, Inc.  All Rights Reserved.
#
# FS QA Test No. 532
#
# Regression test for a bug where XFS fails to set statx attributes_mask but
# sets attribute flags anyway, which is fixed by commit 1b9598c8fb99 ("xfs: fix
# reporting supported extra file attributes for statx()")
#
. ./common/preamble
_begin_fstest auto quick

# Override the default cleanup function.
_cleanup()
{
	cd /
	rm -f $tmp.* $testfile
}

# Import common functions.

# real QA test starts here
_supported_fs generic
_require_test

get_attributes() {
	$XFS_IO_PROG -r -c "statx -r" $1 | grep 'stat.attributes =' | cut -d ' ' -f 3
}

get_attributes_mask() {
	$XFS_IO_PROG -r -c "statx -r" $1 | grep 'stat.attributes_mask =' | cut -d ' ' -f 3
}

check_statx_attributes()
{
	local attrs=$(get_attributes $testfile)
	local mask=$(get_attributes_mask $testfile)

	echo "MASK:$mask:ATTRS:$attrs:" >> $seqres.full

	test -z "$mask" && _notrun "xfs_io statx command does not support attributes_mask"
	test $(( attrs & ~(mask) )) -ne 0 && echo "attributes $attrs do not appear in mask $mask"
}

echo "Silence is golden"

# Create file, check for incorrect mask
testfile=$TEST_DIR/$seq.$$.test
touch $testfile
check_statx_attributes

# Do it again, but this time try to turn on one of the attributes.
if $CHATTR_PROG +i $testfile > /dev/null 2>&1; then
	check_statx_attributes
	$CHATTR_PROG -i $testfile
fi
if $CHATTR_PROG +a $testfile > /dev/null 2>&1; then
	check_statx_attributes
	$CHATTR_PROG -a $testfile
fi

status=0
exit