generic/223: make sure all files get created on the data device
[xfstests-dev.git] / tests / generic / 454
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 454
6 #
7 # Create xattrs with multiple keys that all appear the same
8 # (in unicode, anyway) but point to different values.  In theory all
9 # Linux filesystems should allow this (filenames are a sequence of
10 # arbitrary bytes) even if the user implications are horrifying.
11 #
12 seq=`basename "$0"`
13 seqres="$RESULT_DIR/$seq"
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/attr
29
30 _require_scratch
31 _require_attrs
32
33 echo "Format and mount"
34 _scratch_mkfs > $seqres.full 2>&1
35 _scratch_mount >> $seqres.full 2>&1
36
37 testdir="${SCRATCH_MNT}/test-${seq}"
38 mkdir $testdir
39 testfile="${testdir}/attrfile"
40 touch "${testfile}"
41
42 hexbytes() {
43         echo -n "$1" | od -tx1 -w99999 | head -n1 | sed -e 's/^0* //g'
44 }
45
46 setf() {
47         key="$(echo -e "$1")"
48         value="$2"
49
50         $SETFATTR_PROG -n "user.${key}" -v "${value}" "${testfile}" > $tmp.output 2>&1
51         if [ $? -ne 0 ]; then
52                 grep -q 'No space left on device' $tmp.output && \
53                         _notrun "ran out of space"
54                 cat $tmp.output
55         fi
56         echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
57 }
58
59 testf() {
60         key="$(echo -e "$1")"
61         value="$2"
62
63         echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
64
65         actual_value="$(_getfattr --absolute-names --only-values -n "user.${key}" "${testfile}")"
66         if [ "${actual_value}" != "${value}" ]; then
67                 echo "Key ${key} has value ${actual_value}, expected ${value}."
68         fi
69 }
70
71 filter_scrub() {
72         grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
73 }
74
75 echo "Create files"
76 # These two render the same
77 setf "french_caf\xc3\xa9.txt" "NFC"
78 setf "french_cafe\xcc\x81.txt" "NFD"
79
80 # These two may have different widths
81 setf "chinese_\xef\xbd\xb6.txt" "NFKC1"
82 setf "chinese_\xe3\x82\xab.txt" "NFKC2"
83
84 # Same point, different byte representations in NFC/NFD/NFKC/NFKD
85 setf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
86 setf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
87 setf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
88 setf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
89
90 # Arabic code point can expand into a muuuch longer series
91 setf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
92 setf "arabic_\xd8\xb5\xd9\x84\xd9\x89\x20\xd8\xa7\xd9\x84\xd9\x84\xd9\x87\x20\xd8\xb9\xd9\x84\xd9\x8a\xd9\x87\x20\xd9\x88\xd8\xb3\xd9\x84\xd9\x85.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFKC"
93
94 # Fake slash?
95 setf "urk\xc0\xafmoo" "FAKESLASH"
96
97 # Emoji: octopus butterfly owl giraffe
98 setf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
99
100 # Line draw characters, because why not?
101 setf "\x6c\x69\x6e\x65\x64\x72\x61\x77\x5f\x0a\xe2\x95\x94\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x97\x0a\xe2\x95\x91\x20\x6d\x65\x74\x61\x74\x61\x62\x6c\x65\x20\xe2\x95\x91\x0a\xe2\x95\x9f\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x95\xa2\x0a\xe2\x95\x91\x20\x5f\x5f\x69\x6e\x64\x65\x78\x20\x20\x20\xe2\x95\x91\x0a\xe2\x95\x9a\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x9d\x0a.txt" "ugly box because we can"
102
103 # unicode rtl widgets too...
104 setf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
105 setf "mootxt.png" "Harvey"
106
107 # mixed-script confusables
108 setf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
109 setf "mixed_top.txt" "greek omicron instead of o"
110
111 # single-script spoofing
112 setf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
113 setf "hyphens_a-b.txt" "hyphens"
114
115 setf "dz_digraph_dze.txt" "d-z digraph"
116 setf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
117
118 # inadequate rendering
119 setf "inadequate_al.txt" "is it l or is it 1"
120 setf "inadequate_a1.txt" "is it l or is it 1"
121
122 # symbols
123 setf "prohibition_Rs.txt" "rupee symbol"
124 setf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
125
126 # zero width joiners
127 setf "zerojoin_moocow.txt" "zero width joiners"
128 setf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
129
130 # combining marks
131 setf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
132 setf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
133
134 _getfattr --absolute-names -d "${testfile}" >> $seqres.full
135
136 echo "Test files"
137 testf "french_caf\xc3\xa9.txt" "NFC"
138 testf "french_cafe\xcc\x81.txt" "NFD"
139
140 testf "chinese_\xef\xbd\xb6.txt" "NFKC1"
141 testf "chinese_\xe3\x82\xab.txt" "NFKC2"
142
143 testf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
144 testf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
145 testf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
146 testf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
147
148 testf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
149 testf "arabic_\xd8\xb5\xd9\x84\xd9\x89\x20\xd8\xa7\xd9\x84\xd9\x84\xd9\x87\x20\xd8\xb9\xd9\x84\xd9\x8a\xd9\x87\x20\xd9\x88\xd8\xb3\xd9\x84\xd9\x85.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFKC"
150
151 testf "urk\xc0\xafmoo" "FAKESLASH"
152
153 testf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
154
155 testf "\x6c\x69\x6e\x65\x64\x72\x61\x77\x5f\x0a\xe2\x95\x94\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x97\x0a\xe2\x95\x91\x20\x6d\x65\x74\x61\x74\x61\x62\x6c\x65\x20\xe2\x95\x91\x0a\xe2\x95\x9f\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x95\xa2\x0a\xe2\x95\x91\x20\x5f\x5f\x69\x6e\x64\x65\x78\x20\x20\x20\xe2\x95\x91\x0a\xe2\x95\x9a\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x9d\x0a.txt" "ugly box because we can"
156
157 testf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
158 testf "mootxt.png" "Harvey"
159
160 testf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
161 testf "mixed_top.txt" "greek omicron instead of o"
162
163 testf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
164 testf "hyphens_a-b.txt" "hyphens"
165
166 testf "dz_digraph_dze.txt" "d-z digraph"
167 testf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
168
169 testf "inadequate_al.txt" "is it l or is it 1"
170 testf "inadequate_a1.txt" "is it l or is it 1"
171
172 testf "prohibition_Rs.txt" "rupee symbol"
173 testf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
174
175 testf "zerojoin_moocow.txt" "zero width joiners"
176 testf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
177
178 testf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
179 testf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
180
181 echo "Uniqueness of keys?"
182 crazy_keys="$(_getfattr --absolute-names -d "${testfile}" | egrep -c '(french_|chinese_|greek_|arabic_|urk)')"
183 expected_keys=11
184 test "${crazy_keys}" -ne "${expected_keys}" && echo "Expected ${expected_keys} keys, saw ${crazy_keys}."
185
186 echo "Test XFS online scrub, if applicable"
187
188 if _check_xfs_scrub_does_unicode "$SCRATCH_MNT" "$SCRATCH_DEV"; then
189         output="$(LC_ALL="C.UTF-8" ${XFS_SCRUB_PROG} -v -n "${SCRATCH_MNT}" 2>&1 | filter_scrub)"
190         echo "${output}" | grep -q "french_" || echo "No complaints about french e accent?"
191         echo "${output}" | grep -q "greek_" || echo "No complaints about greek letter mess?"
192         echo "${output}" | grep -q "arabic_" || echo "No complaints about arabic expanded string?"
193         echo "${output}" | grep -q "mixed_" || echo "No complaints about mixed script confusables?"
194         echo "${output}" | grep -q "hyphens_" || echo "No complaints about hyphenation confusables?"
195         echo "${output}" | grep -q "dz_digraph_" || echo "No complaints about single script confusables?"
196         echo "${output}" | grep -q "inadequate_" || echo "No complaints about inadequate rendering confusables?"
197         echo "${output}" | grep -q "prohibition_" || echo "No complaints about prohibited sequence confusables?"
198         echo "${output}" | grep -q "zerojoin_" || echo "No complaints about zero-width join confusables?"
199         echo "Actual xfs_scrub output:" >> $seqres.full
200         echo "${output}" >> $seqres.full
201 fi
202
203 # success, all done
204 status=0
205 exit