2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
7 # Create a directory with multiple filenames that all appear the same
8 # (in unicode, anyway) but point to different inodes. 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 _begin_fstest auto quick dir
15 # Import common functions.
18 _require_names_are_bytes
20 echo "Format and mount"
21 _scratch_mkfs > $seqres.full 2>&1
22 _scratch_mount >> $seqres.full 2>&1
24 testdir="${SCRATCH_MNT}/test-${seq}"
28 echo -n "$1" | od -tx1 -w99999 | head -n1 | sed -e 's/^0* //g'
35 echo "${value}" > "${testdir}/${key}"
36 echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
43 mkdir -p "${testdir}/${key}"
44 echo "${value}" > "${testdir}/${key}/value"
45 echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
51 fname="${testdir}/${key}"
53 echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
55 if [ ! -e "${fname}" ]; then
56 echo "Key ${key} does not exist for ${value} test??"
60 actual_value="$(cat "${fname}")"
61 if [ "${actual_value}" != "${value}" ]; then
62 echo "Key ${key} has value ${value}, expected ${actual_value}."
69 fname="${testdir}/${key}/value"
71 echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
73 if [ ! -e "${fname}" ]; then
74 echo "Key ${key} does not exist for ${value} test??"
78 actual_value="$(cat "${fname}")"
79 if [ "${actual_value}" != "${value}" ]; then
80 echo "Key ${key} has value ${value}, expected ${actual_value}."
85 grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
89 # These two render the same
90 setf "french_caf\xc3\xa9.txt" "NFC"
91 setf "french_cafe\xcc\x81.txt" "NFD"
93 # These two may have different widths
94 setf "chinese_\xef\xbd\xb6.txt" "NFKC1"
95 setf "chinese_\xe3\x82\xab.txt" "NFKC2"
97 # Same point, different byte representations in NFC/NFD/NFKC/NFKD
98 setf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
99 setf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
100 setf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
101 setf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
103 # Arabic code point can expand into a muuuch longer series
104 setf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
105 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"
108 setf "urk\xc0\xafmoo" "FAKESLASH"
110 # Emoji: octopus butterfly owl giraffe
111 setf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
113 # Line draw characters, because why not?
114 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"
116 # unicode rtl widgets too...
117 setf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
118 setf "mootxt.png" "Harvey"
120 # mixed-script confusables
121 setf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
122 setf "mixed_top.txt" "greek omicron instead of o"
124 # single-script spoofing
125 setf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
126 setf "hyphens_a-b.txt" "hyphens"
128 setf "dz_digraph_dze.txt" "d-z digraph"
129 setf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
131 # inadequate rendering
132 setf "inadequate_al.txt" "is it l or is it 1"
133 setf "inadequate_a1.txt" "is it l or is it 1"
136 setf "prohibition_Rs.txt" "rupee symbol"
137 setf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
140 setf "zerojoin_moocow.txt" "zero width joiners"
141 setf "zerojoin_moo\xe2\x80\x8dcow.txt" "zero width joiners"
144 setf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
145 setf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
148 setd ".\xe2\x80\x8d" "zero width joiners in dot entry"
149 setd "..\xe2\x80\x8d" "zero width joiners in dotdot entry"
151 ls -la $testdir >> $seqres.full
154 testf "french_caf\xc3\xa9.txt" "NFC"
155 testf "french_cafe\xcc\x81.txt" "NFD"
157 testf "chinese_\xef\xbd\xb6.txt" "NFKC1"
158 testf "chinese_\xe3\x82\xab.txt" "NFKC2"
160 testf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
161 testf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
162 testf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
163 testf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
165 testf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
166 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"
168 testf "urk\xc0\xafmoo" "FAKESLASH"
170 testf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
172 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"
174 testf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
175 testf "mootxt.png" "Harvey"
177 testf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
178 testf "mixed_top.txt" "greek omicron instead of o"
180 testf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
181 testf "hyphens_a-b.txt" "hyphens"
183 testf "dz_digraph_dze.txt" "d-z digraph"
184 testf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
186 testf "inadequate_al.txt" "is it l or is it 1"
187 testf "inadequate_a1.txt" "is it l or is it 1"
189 testf "prohibition_Rs.txt" "rupee symbol"
190 testf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
192 testf "zerojoin_moocow.txt" "zero width joiners"
193 testf "zerojoin_moo\xe2\x80\x8dcow.txt" "zero width joiners"
195 testf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
196 testf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
198 testd ".\xe2\x80\x8d" "zero width joiners in dot entry"
199 testd "..\xe2\x80\x8d" "zero width joiners in dotdot entry"
201 echo "Uniqueness of inodes?"
202 stat -c '%i' "${testdir}/"* | sort | uniq -c | while read nr inum; do
203 if [ "${nr}" -gt 1 ]; then
208 echo "Test XFS online scrub, if applicable"
210 if _check_xfs_scrub_does_unicode "$SCRATCH_MNT" "$SCRATCH_DEV"; then
211 output="$(LC_ALL="C.UTF-8" ${XFS_SCRUB_PROG} -v -n "${SCRATCH_MNT}" 2>&1 | filter_scrub)"
212 echo "${output}" | grep -q "french_" || echo "No complaints about french e accent?"
213 echo "${output}" | grep -q "greek_" || echo "No complaints about greek letter mess?"
214 echo "${output}" | grep -q "arabic_" || echo "No complaints about arabic expanded string?"
215 echo "${output}" | grep -q "mixed_" || echo "No complaints about mixed script confusables?"
216 echo "${output}" | grep -q "hyphens_" || echo "No complaints about hyphenation confusables?"
217 echo "${output}" | grep -q "dz_digraph_" || echo "No complaints about single script confusables?"
218 echo "${output}" | grep -q "inadequate_" || echo "No complaints about inadequate rendering confusables?"
219 echo "${output}" | grep -q "prohibition_" || echo "No complaints about prohibited sequence confusables?"
220 echo "${output}" | grep -q "zerojoin_" || echo "No complaints about zero-width join confusables?"
221 echo "Actual xfs_scrub output:" >> $seqres.full
222 echo "${output}" >> $seqres.full