summaryrefslogtreecommitdiff
path: root/tests/generic/097
blob: 613aabaaecce78f2bda5d8f25cfafed78bff5c01 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
# Copyright (c) 2017 Google, Inc.  All Rights Reserved.
#
# FS QA Test No. 097. Modifed from UDFQA test 033.
#
# simple attr tests for EAs:
#  - set
#  - get
#  - list
#  - remove
# Basic testing.
#
. ./common/preamble
_begin_fstest attr auto quick

file=$TEST_DIR/foo

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

getfattr()
{
	_getfattr --absolute-names "$@" |& _filter_test_dir
}

setfattr()
{
	$SETFATTR_PROG "$@" |& _filter_test_dir
}

# Import common functions.
. ./common/attr
. ./common/filter

# real QA test starts here
_supported_fs generic

_require_test
_require_attrs user trusted

echo -e "\ncreate file foo"
rm -f $file
touch $file

echo -e "\n*** Test out the trusted namespace ***"

echo -e "\nset EA <trusted:colour,marone>:"
setfattr -n trusted.colour -v marone $file

echo -e "\nset EA <user:colour,beige>:"
setfattr -n user.colour -v beige $file

echo -e "\nset EA <user:vomit,pizza>:"
setfattr -n user.vomit -v pizza $file

echo -e "\nset EA <trusted:noise,whack>:"
setfattr -n trusted.noise -v whack $file

echo -e "\nlist trusted EAs: <trusted:colour,noise>:"
getfattr -d -m '^trusted\.' $file

echo -e "\nlist user EAs: <user:colour,vomit>:"
getfattr -d $file

echo -e "\nget trusted EA colour: marone"
getfattr -n trusted.colour $file

echo -e "\nget trusted EA noise: whack"
getfattr -n trusted.noise $file

echo -e "\nget trusted EA vomit which is a user EA => find nothing"
getfattr -n trusted.vomit $file

echo -e "\nunmount the FS and see if EAs are persistent"
_test_cycle_mount

echo -e "\nget trusted EA colour: marone"
getfattr -n trusted.colour $file

echo -e "\nget trusted EA noise: whack"
getfattr -n trusted.noise $file

echo -e "\nget user EA vomit: pizza"
getfattr -n user.vomit $file

echo -e "\nremove the trusted colour EA"
setfattr -x trusted.colour $file

echo -e "\nlist trusted EAs: <trusted:noise>:"
getfattr -d -m '^trusted\.' $file

echo -e "\nlist user EAs: <user:colour,vomit>:"
getfattr -d $file

echo -e "\nremove the final trusted EA noise"
setfattr -x trusted.noise $file

echo -e "\nlist trusted EAs: none"
getfattr -d -m '^trusted\.' $file

# success, all done
status=0
exit