generic/{453,454}: Don't run for FSs restricting names
[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 . ./common/preamble
13 _begin_fstest auto quick attr
14
15 # Import common functions.
16 . ./common/attr
17
18 _require_scratch
19 _require_attrs
20 _require_names_are_bytes
21
22 echo "Format and mount"
23 _scratch_mkfs > $seqres.full 2>&1
24 _scratch_mount >> $seqres.full 2>&1
25
26 testdir="${SCRATCH_MNT}/test-${seq}"
27 mkdir $testdir
28 testfile="${testdir}/attrfile"
29 touch "${testfile}"
30
31 hexbytes() {
32         echo -n "$1" | od -tx1 -w99999 | head -n1 | sed -e 's/^0* //g'
33 }
34
35 setf() {
36         key="$(echo -e "$1")"
37         value="$2"
38
39         $SETFATTR_PROG -n "user.${key}" -v "${value}" "${testfile}" > $tmp.output 2>&1
40         if [ $? -ne 0 ]; then
41                 grep -q 'No space left on device' $tmp.output && \
42                         _notrun "ran out of space"
43                 cat $tmp.output
44         fi
45         echo "Storing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
46 }
47
48 testf() {
49         key="$(echo -e "$1")"
50         value="$2"
51
52         echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
53
54         actual_value="$(_getfattr --absolute-names --only-values -n "user.${key}" "${testfile}")"
55         if [ "${actual_value}" != "${value}" ]; then
56                 echo "Key ${key} has value ${actual_value}, expected ${value}."
57         fi
58 }
59
60 filter_scrub() {
61         grep 'Unicode' | sed -e 's/^.*Duplicate/Duplicate/g'
62 }
63
64 echo "Create files"
65 # These two render the same
66 setf "french_caf\xc3\xa9.txt" "NFC"
67 setf "french_cafe\xcc\x81.txt" "NFD"
68
69 # These two may have different widths
70 setf "chinese_\xef\xbd\xb6.txt" "NFKC1"
71 setf "chinese_\xe3\x82\xab.txt" "NFKC2"
72
73 # Same point, different byte representations in NFC/NFD/NFKC/NFKD
74 setf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
75 setf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
76 setf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
77 setf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
78
79 # Arabic code point can expand into a muuuch longer series
80 setf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
81 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"
82
83 # Fake slash?
84 setf "urk\xc0\xafmoo" "FAKESLASH"
85
86 # Emoji: octopus butterfly owl giraffe
87 setf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
88
89 # Line draw characters, because why not?
90 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"
91
92 # unicode rtl widgets too...
93 setf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
94 setf "mootxt.png" "Harvey"
95
96 # mixed-script confusables
97 setf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
98 setf "mixed_top.txt" "greek omicron instead of o"
99
100 # single-script spoofing
101 setf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
102 setf "hyphens_a-b.txt" "hyphens"
103
104 setf "dz_digraph_dze.txt" "d-z digraph"
105 setf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
106
107 # inadequate rendering
108 setf "inadequate_al.txt" "is it l or is it 1"
109 setf "inadequate_a1.txt" "is it l or is it 1"
110
111 # symbols
112 setf "prohibition_Rs.txt" "rupee symbol"
113 setf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
114
115 # zero width joiners
116 setf "zerojoin_moocow.txt" "zero width joiners"
117 setf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
118
119 # combining marks
120 setf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
121 setf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
122
123 _getfattr --absolute-names -d "${testfile}" >> $seqres.full
124
125 echo "Test files"
126 testf "french_caf\xc3\xa9.txt" "NFC"
127 testf "french_cafe\xcc\x81.txt" "NFD"
128
129 testf "chinese_\xef\xbd\xb6.txt" "NFKC1"
130 testf "chinese_\xe3\x82\xab.txt" "NFKC2"
131
132 testf "greek_\xcf\x93.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFC"
133 testf "greek_\xcf\x92\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFD"
134 testf "greek_\xce\x8e.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKC"
135 testf "greek_\xce\xa5\xcc\x81.txt" "GREEK UPSILON WITH ACUTE AND HOOK SYMBOL, NFKD"
136
137 testf "arabic_\xef\xb7\xba.txt" "ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM, NFC"
138 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"
139
140 testf "urk\xc0\xafmoo" "FAKESLASH"
141
142 testf "emoji_\xf0\x9f\xa6\x91\xf0\x9f\xa6\x8b\xf0\x9f\xa6\x89\xf0\x9f\xa6\x92.txt" "octopus butterfly owl giraffe emoji"
143
144 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"
145
146 testf "moo\xe2\x80\xaegnp.txt" "Well say hello,"
147 testf "mootxt.png" "Harvey"
148
149 testf "mixed_t\xce\xbfp.txt" "greek omicron instead of o"
150 testf "mixed_top.txt" "greek omicron instead of o"
151
152 testf "hyphens_a\xe2\x80\x90b.txt" "hyphens"
153 testf "hyphens_a-b.txt" "hyphens"
154
155 testf "dz_digraph_dze.txt" "d-z digraph"
156 testf "dz_digraph_\xca\xa3e.txt" "d-z digraph"
157
158 testf "inadequate_al.txt" "is it l or is it 1"
159 testf "inadequate_a1.txt" "is it l or is it 1"
160
161 testf "prohibition_Rs.txt" "rupee symbol"
162 testf "prohibition_\xe2\x82\xa8.txt" "rupee symbol"
163
164 testf "zerojoin_moocow.txt" "zero width joiners"
165 testf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
166
167 testf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
168 testf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
169
170 echo "Uniqueness of keys?"
171 crazy_keys="$(_getfattr --absolute-names -d "${testfile}" | egrep -c '(french_|chinese_|greek_|arabic_|urk)')"
172 expected_keys=11
173 test "${crazy_keys}" -ne "${expected_keys}" && echo "Expected ${expected_keys} keys, saw ${crazy_keys}."
174
175 echo "Test XFS online scrub, if applicable"
176
177 if _check_xfs_scrub_does_unicode "$SCRATCH_MNT" "$SCRATCH_DEV"; then
178         output="$(LC_ALL="C.UTF-8" ${XFS_SCRUB_PROG} -v -n "${SCRATCH_MNT}" 2>&1 | filter_scrub)"
179         echo "${output}" | grep -q "french_" || echo "No complaints about french e accent?"
180         echo "${output}" | grep -q "greek_" || echo "No complaints about greek letter mess?"
181         echo "${output}" | grep -q "arabic_" || echo "No complaints about arabic expanded string?"
182         echo "${output}" | grep -q "mixed_" || echo "No complaints about mixed script confusables?"
183         echo "${output}" | grep -q "hyphens_" || echo "No complaints about hyphenation confusables?"
184         echo "${output}" | grep -q "dz_digraph_" || echo "No complaints about single script confusables?"
185         echo "${output}" | grep -q "inadequate_" || echo "No complaints about inadequate rendering confusables?"
186         echo "${output}" | grep -q "prohibition_" || echo "No complaints about prohibited sequence confusables?"
187         echo "${output}" | grep -q "zerojoin_" || echo "No complaints about zero-width join confusables?"
188         echo "Actual xfs_scrub output:" >> $seqres.full
189         echo "${output}" >> $seqres.full
190 fi
191
192 # success, all done
193 status=0
194 exit