2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
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.
13 seqres="$RESULT_DIR/$seq"
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
34 echo "Format and mount"
35 _scratch_mkfs > $seqres.full 2>&1
36 _scratch_mount >> $seqres.full 2>&1
38 testdir="${SCRATCH_MNT}/test-${seq}"
40 testfile="${testdir}/attrfile"
44 echo -n "$1" | od -tx1 -w99999 | head -n1 | sed -e 's/^0* //g'
51 $SETFATTR_PROG -n "user.${key}" -v "${value}" "${testfile}" > $tmp.output 2>&1
53 grep -q 'No space left on device' $tmp.output && \
54 _notrun "ran out of space"
57 echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
64 echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
66 actual_value="$(_getfattr --absolute-names --only-values -n "user.${key}" "${testfile}")"
67 if [ "${actual_value}" != "${value}" ]; then
68 echo "Key ${key} has value ${actual_value}, expected ${value}."
73 grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
77 # These two render the same
78 setf "french_caf\xc3\xa9.txt" "NFC"
79 setf "french_cafe\xcc\x81.txt" "NFD"
81 # These two may have different widths
82 setf "chinese_\xef\xbd\xb6.txt" "NFKC1"
83 setf "chinese_\xe3\x82\xab.txt" "NFKC2"
85 # Same point, different byte representations in NFC/NFD/NFKC/NFKD
86 setf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
87 setf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
88 setf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
89 setf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
91 # Arabic code point can expand into a muuuch longer series
92 setf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
93 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"
96 setf "urk\xc0\xafmoo" "FAKESLASH"
98 # Emoji: octopus butterfly owl giraffe
99 setf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
101 # Line draw characters, because why not?
102 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"
104 # unicode rtl widgets too...
105 setf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
106 setf "mootxt.png" "Harvey"
108 # mixed-script confusables
109 setf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
110 setf "mixed_top.txt" "greek omicron instead of o"
112 # single-script spoofing
113 setf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
114 setf "hyphens_a-b.txt" "hyphens"
116 setf "dz_digraph_dze.txt" "d-z digraph"
117 setf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
119 # inadequate rendering
120 setf "inadequate_al.txt" "is it l or is it 1"
121 setf "inadequate_a1.txt" "is it l or is it 1"
124 setf "prohibition_Rs.txt" "rupee symbol"
125 setf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
128 setf "zerojoin_moocow.txt" "zero width joiners"
129 setf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
132 setf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
133 setf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
135 _getfattr --absolute-names -d "${testfile}" >> $seqres.full
138 testf "french_caf\xc3\xa9.txt" "NFC"
139 testf "french_cafe\xcc\x81.txt" "NFD"
141 testf "chinese_\xef\xbd\xb6.txt" "NFKC1"
142 testf "chinese_\xe3\x82\xab.txt" "NFKC2"
144 testf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
145 testf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
146 testf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
147 testf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
149 testf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
150 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"
152 testf "urk\xc0\xafmoo" "FAKESLASH"
154 testf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
156 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"
158 testf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
159 testf "mootxt.png" "Harvey"
161 testf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
162 testf "mixed_top.txt" "greek omicron instead of o"
164 testf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
165 testf "hyphens_a-b.txt" "hyphens"
167 testf "dz_digraph_dze.txt" "d-z digraph"
168 testf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
170 testf "inadequate_al.txt" "is it l or is it 1"
171 testf "inadequate_a1.txt" "is it l or is it 1"
173 testf "prohibition_Rs.txt" "rupee symbol"
174 testf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
176 testf "zerojoin_moocow.txt" "zero width joiners"
177 testf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
179 testf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
180 testf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
182 echo "Uniqueness of keys?"
183 crazy_keys="$(_getfattr --absolute-names -d "${testfile}" | egrep -c '(french_|chinese_|greek_|arabic_|urk)')"
185 test "${crazy_keys}" -ne "${expected_keys}" && echo "Expected ${expected_keys} keys, saw ${crazy_keys}."
187 echo "Test XFS online scrub, if applicable"
189 if _check_xfs_scrub_does_unicode "$SCRATCH_MNT" "$SCRATCH_DEV"; then
190 output="$(LC_ALL="C.UTF-8" ${XFS_SCRUB_PROG} -v -n "${SCRATCH_MNT}" 2>&1 | filter_scrub)"
191 echo "${output}" | grep -q "french_" || echo "No complaints about french e accent?"
192 echo "${output}" | grep -q "greek_" || echo "No complaints about greek letter mess?"
193 echo "${output}" | grep -q "arabic_" || echo "No complaints about arabic expanded string?"
194 echo "${output}" | grep -q "mixed_" || echo "No complaints about mixed script confusables?"
195 echo "${output}" | grep -q "hyphens_" || echo "No complaints about hyphenation confusables?"
196 echo "${output}" | grep -q "dz_digraph_" || echo "No complaints about single script confusables?"
197 echo "${output}" | grep -q "inadequate_" || echo "No complaints about inadequate rendering confusables?"
198 echo "${output}" | grep -q "prohibition_" || echo "No complaints about prohibited sequence confusables?"
199 echo "${output}" | grep -q "zerojoin_" || echo "No complaints about zero-width join confusables?"
200 echo "Actual xfs_scrub output:" >> $seqres.full
201 echo "${output}" >> $seqres.full