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}"
52 echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
59 echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
61 actual_value="$(_getfattr --absolute-names --only-values -n "user.${key}" "${testfile}")"
62 if [ "${actual_value}" != "${value}" ]; then
63 echo "Key ${key} has value ${actual_value}, expected ${value}."
68 grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
72 # These two render the same
73 setf "french_caf\xc3\xa9.txt" "NFC"
74 setf "french_cafe\xcc\x81.txt" "NFD"
76 # These two may have different widths
77 setf "chinese_\xef\xbd\xb6.txt" "NFKC1"
78 setf "chinese_\xe3\x82\xab.txt" "NFKC2"
80 # Same point, different byte representations in NFC/NFD/NFKC/NFKD
81 setf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
82 setf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
83 setf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
84 setf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
86 # Arabic code point can expand into a muuuch longer series
87 setf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
88 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"
91 setf "urk\xc0\xafmoo" "FAKESLASH"
93 # Emoji: octopus butterfly owl giraffe
94 setf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
96 # Line draw characters, because why not?
97 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"
99 # unicode rtl widgets too...
100 setf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
101 setf "mootxt.png" "Harvey"
103 # mixed-script confusables
104 setf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
105 setf "mixed_top.txt" "greek omicron instead of o"
107 # single-script spoofing
108 setf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
109 setf "hyphens_a-b.txt" "hyphens"
111 setf "dz_digraph_dze.txt" "d-z digraph"
112 setf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
114 # inadequate rendering
115 setf "inadequate_al.txt" "is it l or is it 1"
116 setf "inadequate_a1.txt" "is it l or is it 1"
119 setf "prohibition_Rs.txt" "rupee symbol"
120 setf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
123 setf "zerojoin_moocow.txt" "zero width joiners"
124 setf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
127 setf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
128 setf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
130 _getfattr --absolute-names -d "${testfile}" >> $seqres.full
133 testf "french_caf\xc3\xa9.txt" "NFC"
134 testf "french_cafe\xcc\x81.txt" "NFD"
136 testf "chinese_\xef\xbd\xb6.txt" "NFKC1"
137 testf "chinese_\xe3\x82\xab.txt" "NFKC2"
139 testf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
140 testf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
141 testf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
142 testf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
144 testf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
145 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"
147 testf "urk\xc0\xafmoo" "FAKESLASH"
149 testf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
151 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"
153 testf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
154 testf "mootxt.png" "Harvey"
156 testf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
157 testf "mixed_top.txt" "greek omicron instead of o"
159 testf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
160 testf "hyphens_a-b.txt" "hyphens"
162 testf "dz_digraph_dze.txt" "d-z digraph"
163 testf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
165 testf "inadequate_al.txt" "is it l or is it 1"
166 testf "inadequate_a1.txt" "is it l or is it 1"
168 testf "prohibition_Rs.txt" "rupee symbol"
169 testf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
171 testf "zerojoin_moocow.txt" "zero width joiners"
172 testf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
174 testf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
175 testf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
177 echo "Uniqueness of keys?"
178 crazy_keys="$(_getfattr --absolute-names -d "${testfile}" | egrep -c '(french_|chinese_|greek_|arabic_|urk)')"
180 test "${crazy_keys}" -ne "${expected_keys}" && echo "Expected ${expected_keys} keys, saw ${crazy_keys}."
182 echo "Test XFS online scrub, if applicable"
184 # Only run this on xfs if xfs_scrub is available and has the unicode checker
186 [ "$FSTYP" == "xfs" ] || return 1
187 _supports_xfs_scrub "$SCRATCH_MNT" "$SCRATCH_DEV" || return 1
189 # We only care if xfs_scrub has unicode string support...
190 if ! type ldd > /dev/null 2>&1 || \
191 ! ldd "${XFS_SCRUB_PROG}" | grep -q libicui18n; then
198 if check_xfs_scrub; then
199 output="$(LC_ALL="C.UTF-8" ${XFS_SCRUB_PROG} -v -n "${SCRATCH_MNT}" 2>&1 | filter_scrub)"
200 echo "${output}" | grep -q "french_" || echo "No complaints about french e accent?"
201 echo "${output}" | grep -q "greek_" || echo "No complaints about greek letter mess?"
202 echo "${output}" | grep -q "arabic_" || echo "No complaints about arabic expanded string?"
203 echo "${output}" | grep -q "mixed_" || echo "No complaints about mixed script confusables?"
204 echo "${output}" | grep -q "hyphens_" || echo "No complaints about hyphenation confusables?"
205 echo "${output}" | grep -q "dz_digraph_" || echo "No complaints about single script confusables?"
206 echo "${output}" | grep -q "inadequate_" || echo "No complaints about inadequate rendering confusables?"
207 echo "${output}" | grep -q "prohibition_" || echo "No complaints about prohibited sequence confusables?"
208 echo "${output}" | grep -q "zerojoin_" || echo "No complaints about zero-width join confusables?"
209 echo "Actual xfs_scrub output:" >> $seqres.full
210 echo "${output}" >> $seqres.full