generic: test for non-zero used blocks while writing into a file
[xfstests-dev.git] / tests / generic / 097
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
4 # Copyright (c) 2017 Google, Inc.  All Rights Reserved.
5 #
6 # FS QA Test No. 097. Modifed from UDFQA test 033.
7 #
8 # simple attr tests for EAs:
9 #  - set
10 #  - get
11 #  - list
12 #  - remove
13 # Basic testing.
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 file=$TEST_DIR/foo
25
26 _cleanup()
27 {
28         rm -f $tmp.* $file
29 }
30
31 getfattr()
32 {
33         _getfattr --absolute-names "$@" |& _filter_test_dir
34 }
35
36 setfattr()
37 {
38         $SETFATTR_PROG "$@" |& _filter_test_dir
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/attr
44 . ./common/filter
45
46 # real QA test starts here
47 _supported_fs generic
48
49 _require_test
50 _require_attrs user trusted
51
52 echo -e "\ncreate file foo"
53 rm -f $file
54 touch $file
55
56 echo -e "\n*** Test out the trusted namespace ***"
57
58 echo -e "\nset EA <trusted:colour,marone>:"
59 setfattr -n trusted.colour -v marone $file
60
61 echo -e "\nset EA <user:colour,beige>:"
62 setfattr -n user.colour -v beige $file
63
64 echo -e "\nset EA <user:vomit,pizza>:"
65 setfattr -n user.vomit -v pizza $file
66
67 echo -e "\nset EA <trusted:noise,whack>:"
68 setfattr -n trusted.noise -v whack $file
69
70 echo -e "\nlist trusted EAs: <trusted:colour,noise>:"
71 getfattr -d -m '^trusted\.' $file
72
73 echo -e "\nlist user EAs: <user:colour,vomit>:"
74 getfattr -d $file
75
76 echo -e "\nget trusted EA colour: marone"
77 getfattr -n trusted.colour $file
78
79 echo -e "\nget trusted EA noise: whack"
80 getfattr -n trusted.noise $file
81
82 echo -e "\nget trusted EA vomit which is a user EA => find nothing"
83 getfattr -n trusted.vomit $file
84
85 echo -e "\nunmount the FS and see if EAs are persistent"
86 _test_cycle_mount
87
88 echo -e "\nget trusted EA colour: marone"
89 getfattr -n trusted.colour $file
90
91 echo -e "\nget trusted EA noise: whack"
92 getfattr -n trusted.noise $file
93
94 echo -e "\nget user EA vomit: pizza"
95 getfattr -n user.vomit $file
96
97 echo -e "\nremove the trusted colour EA"
98 setfattr -x trusted.colour $file
99
100 echo -e "\nlist trusted EAs: <trusted:noise>:"
101 getfattr -d -m '^trusted\.' $file
102
103 echo -e "\nlist user EAs: <user:colour,vomit>:"
104 getfattr -d $file
105
106 echo -e "\nremove the final trusted EA noise"
107 setfattr -x trusted.noise $file
108
109 echo -e "\nlist trusted EAs: none"
110 getfattr -d -m '^trusted\.' $file
111
112 # success, all done
113 status=0
114 exit