fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / generic / 453
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. 453
6 #
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.
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
29 _require_scratch
30
31 echo "Format and mount"
32 _scratch_mkfs > $seqres.full 2>&1
33 _scratch_mount >> $seqres.full 2>&1
34
35 testdir="${SCRATCH_MNT}/test-${seq}"
36 mkdir $testdir
37
38 hexbytes() {
39         echo -n "$1" | od -tx1 -w99999 | head -n1 | sed -e 's/^0* //g'
40 }
41
42 setf() {
43         key="$(echo -e "$1")"
44         value="$2"
45
46         echo "${value}" > "${testdir}/${key}"
47         echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
48 }
49
50 setd() {
51         key="$(echo -e "$1")"
52         value="$2"
53
54         mkdir -p "${testdir}/${key}"
55         echo "${value}" > "${testdir}/${key}/value"
56         echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
57 }
58
59 testf() {
60         key="$(echo -e "$1")"
61         value="$2"
62         fname="${testdir}/${key}"
63
64         echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
65
66         if [ ! -e "${fname}" ]; then
67                 echo "Key ${key} does not exist for ${value} test??"
68                 return
69         fi
70
71         actual_value="$(cat "${fname}")"
72         if [ "${actual_value}" != "${value}" ]; then
73                 echo "Key ${key} has value ${value}, expected ${actual_value}."
74         fi
75 }
76
77 testd() {
78         key="$(echo -e "$1")"
79         value="$2"
80         fname="${testdir}/${key}/value"
81
82         echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
83
84         if [ ! -e "${fname}" ]; then
85                 echo "Key ${key} does not exist for ${value} test??"
86                 return
87         fi
88
89         actual_value="$(cat "${fname}")"
90         if [ "${actual_value}" != "${value}" ]; then
91                 echo "Key ${key} has value ${value}, expected ${actual_value}."
92         fi
93 }
94
95 filter_scrub() {
96         grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
97 }
98
99 echo "Create files"
100 # These two render the same
101 setf "french_caf\xc3\xa9.txt" "NFC"
102 setf "french_cafe\xcc\x81.txt" "NFD"
103
104 # These two may have different widths
105 setf "chinese_\xef\xbd\xb6.txt" "NFKC1"
106 setf "chinese_\xe3\x82\xab.txt" "NFKC2"
107
108 # Same point, different byte representations in NFC/NFD/NFKC/NFKD
109 setf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
110 setf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
111 setf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
112 setf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
113
114 # Arabic code point can expand into a muuuch longer series
115 setf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
116 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"
117
118 # Fake slash?
119 setf "urk\xc0\xafmoo" "FAKESLASH"
120
121 # Emoji: octopus butterfly owl giraffe
122 setf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
123
124 # Line draw characters, because why not?
125 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"
126
127 # unicode rtl widgets too...
128 setf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
129 setf "mootxt.png" "Harvey"
130
131 # mixed-script confusables
132 setf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
133 setf "mixed_top.txt" "greek omicron instead of o"
134
135 # single-script spoofing
136 setf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
137 setf "hyphens_a-b.txt" "hyphens"
138
139 setf "dz_digraph_dze.txt" "d-z digraph"
140 setf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
141
142 # inadequate rendering
143 setf "inadequate_al.txt" "is it l or is it 1"
144 setf "inadequate_a1.txt" "is it l or is it 1"
145
146 # symbols
147 setf "prohibition_Rs.txt" "rupee symbol"
148 setf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
149
150 # zero width joiners
151 setf "zerojoin_moocow.txt" "zero width joiners"
152 setf "zerojoin_moo\xe2\x80\x8dcow.txt" "zero width joiners"
153
154 # combining marks
155 setf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
156 setf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
157
158 # fake dotdot entry
159 setd ".\xe2\x80\x8d" "zero width joiners in dot entry"
160 setd "..\xe2\x80\x8d" "zero width joiners in dotdot entry"
161
162 ls -la $testdir >> $seqres.full
163
164 echo "Test files"
165 testf "french_caf\xc3\xa9.txt" "NFC"
166 testf "french_cafe\xcc\x81.txt" "NFD"
167
168 testf "chinese_\xef\xbd\xb6.txt" "NFKC1"
169 testf "chinese_\xe3\x82\xab.txt" "NFKC2"
170
171 testf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
172 testf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
173 testf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
174 testf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
175
176 testf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
177 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"
178
179 testf "urk\xc0\xafmoo" "FAKESLASH"
180
181 testf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
182
183 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"
184
185 testf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
186 testf "mootxt.png" "Harvey"
187
188 testf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
189 testf "mixed_top.txt" "greek omicron instead of o"
190
191 testf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
192 testf "hyphens_a-b.txt" "hyphens"
193
194 testf "dz_digraph_dze.txt" "d-z digraph"
195 testf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
196
197 testf "inadequate_al.txt" "is it l or is it 1"
198 testf "inadequate_a1.txt" "is it l or is it 1"
199
200 testf "prohibition_Rs.txt" "rupee symbol"
201 testf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
202
203 testf "zerojoin_moocow.txt" "zero width joiners"
204 testf "zerojoin_moo\xe2\x80\x8dcow.txt" "zero width joiners"
205
206 testf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
207 testf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
208
209 testd ".\xe2\x80\x8d" "zero width joiners in dot entry"
210 testd "..\xe2\x80\x8d" "zero width joiners in dotdot entry"
211
212 echo "Uniqueness of inodes?"
213 stat -c '%i' "${testdir}/"* | sort | uniq -c | while read nr inum; do
214         if [ "${nr}" -gt 1 ]; then
215                 echo "${nr} ${inum}"
216         fi
217 done
218
219 echo "Test XFS online scrub, if applicable"
220
221 if _check_xfs_scrub_does_unicode "$SCRATCH_MNT" "$SCRATCH_DEV"; then
222         output="$(LC_ALL="C.UTF-8" ${XFS_SCRUB_PROG} -v -n "${SCRATCH_MNT}" 2>&1 | filter_scrub)"
223         echo "${output}" | grep -q "french_" || echo "No complaints about french e accent?"
224         echo "${output}" | grep -q "greek_" || echo "No complaints about greek letter mess?"
225         echo "${output}" | grep -q "arabic_" || echo "No complaints about arabic expanded string?"
226         echo "${output}" | grep -q "mixed_" || echo "No complaints about mixed script confusables?"
227         echo "${output}" | grep -q "hyphens_" || echo "No complaints about hyphenation confusables?"
228         echo "${output}" | grep -q "dz_digraph_" || echo "No complaints about single script confusables?"
229         echo "${output}" | grep -q "inadequate_" || echo "No complaints about inadequate rendering confusables?"
230         echo "${output}" | grep -q "prohibition_" || echo "No complaints about prohibited sequence confusables?"
231         echo "${output}" | grep -q "zerojoin_" || echo "No complaints about zero-width join confusables?"
232         echo "Actual xfs_scrub output:" >> $seqres.full
233         echo "${output}" >> $seqres.full
234 fi
235
236 # success, all done
237 status=0
238 exit