nptl_db: disable DT_RELR on libthread_db.so
[glibc.git] / iconv / tst-iconv_prog.sh
blobb3d8bf51107eabecbcbe1b29cb9c5a96dbce5f92
1 #!/bin/bash
2 # Test for some known iconv(1) hangs from bug 19519, and miscellaneous
3 # iconv(1) program error conditions.
4 # Copyright (C) 2020-2022 Free Software Foundation, Inc.
5 # This file is part of the GNU C Library.
7 # The GNU C Library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # The GNU C Library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with the GNU C Library; if not, see
19 # <https://www.gnu.org/licenses/>.
21 codir=$1
22 test_wrapper_env="$2"
23 run_program_env="$3"
25 # We have to have some directories in the library path.
26 LIBPATH=$codir:$codir/iconvdata
28 # How the start the iconv(1) program. $from is not defined/expanded yet.
29 ICONV='
30 $codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so
31 $codir/iconv/iconv_prog
33 ICONV="$test_wrapper_env $run_program_env $ICONV"
35 TIMEOUTFACTOR=${TIMEOUTFACTOR:-1}
37 # List of known hangs;
38 # Gathered by running an exhaustive 2 byte input search against glibc-2.28
39 hangarray=(
40 "\x00\x23;-c;ANSI_X3.110;UTF-8//TRANSLIT//IGNORE"
41 "\x00\xa1;-c;ARMSCII-8;UTF-8//TRANSLIT//IGNORE"
42 "\x00\xa1;-c;ASMO_449;UTF-8//TRANSLIT//IGNORE"
43 "\x00\x81;-c;BIG5;UTF-8//TRANSLIT//IGNORE"
44 "\x00\xff;-c;BIG5HKSCS;UTF-8//TRANSLIT//IGNORE"
45 "\x00\xff;-c;BRF;UTF-8//TRANSLIT//IGNORE"
46 "\x00\xff;-c;BS_4730;UTF-8//TRANSLIT//IGNORE"
47 "\x00\x81;-c;CP1250;UTF-8//TRANSLIT//IGNORE"
48 "\x00\x98;-c;CP1251;UTF-8//TRANSLIT//IGNORE"
49 "\x00\x81;-c;CP1252;UTF-8//TRANSLIT//IGNORE"
50 "\x00\x81;-c;CP1253;UTF-8//TRANSLIT//IGNORE"
51 "\x00\x81;-c;CP1254;UTF-8//TRANSLIT//IGNORE"
52 "\x00\x81;-c;CP1255;UTF-8//TRANSLIT//IGNORE"
53 "\x00\x81;-c;CP1257;UTF-8//TRANSLIT//IGNORE"
54 "\x00\x81;-c;CP1258;UTF-8//TRANSLIT//IGNORE"
55 "\xff\xff;-c;CP932;UTF-8//TRANSLIT//IGNORE"
56 "\xff\xff;-c;CSA_Z243.4-1985-1;UTF-8//TRANSLIT//IGNORE"
57 "\xff\xff;-c;CSA_Z243.4-1985-2;UTF-8//TRANSLIT//IGNORE"
58 "\xff\xff;-c;DEC-MCS;UTF-8//TRANSLIT//IGNORE"
59 "\xff\xff;-c;DIN_66003;UTF-8//TRANSLIT//IGNORE"
60 "\xff\xff;-c;DS_2089;UTF-8//TRANSLIT//IGNORE"
61 "\x00\x41;-c;EBCDIC-AT-DE;UTF-8//TRANSLIT//IGNORE"
62 "\x00\x41;-c;EBCDIC-AT-DE-A;UTF-8//TRANSLIT//IGNORE"
63 "\x00\x41;-c;EBCDIC-CA-FR;UTF-8//TRANSLIT//IGNORE"
64 "\x00\x41;-c;EBCDIC-DK-NO;UTF-8//TRANSLIT//IGNORE"
65 "\x00\x41;-c;EBCDIC-DK-NO-A;UTF-8//TRANSLIT//IGNORE"
66 "\x00\x41;-c;EBCDIC-ES;UTF-8//TRANSLIT//IGNORE"
67 "\x00\x41;-c;EBCDIC-ES-A;UTF-8//TRANSLIT//IGNORE"
68 "\x00\x41;-c;EBCDIC-ES-S;UTF-8//TRANSLIT//IGNORE"
69 "\x00\x41;-c;EBCDIC-FI-SE;UTF-8//TRANSLIT//IGNORE"
70 "\x00\x41;-c;EBCDIC-FI-SE-A;UTF-8//TRANSLIT//IGNORE"
71 "\x00\x41;-c;EBCDIC-FR;UTF-8//TRANSLIT//IGNORE"
72 "\x00\x41;-c;EBCDIC-IS-FRISS;UTF-8//TRANSLIT//IGNORE"
73 "\x00\x41;-c;EBCDIC-IT;UTF-8//TRANSLIT//IGNORE"
74 "\x00\x41;-c;EBCDIC-PT;UTF-8//TRANSLIT//IGNORE"
75 "\x00\x41;-c;EBCDIC-UK;UTF-8//TRANSLIT//IGNORE"
76 "\x00\x41;-c;EBCDIC-US;UTF-8//TRANSLIT//IGNORE"
77 "\xff\xff;-c;ES;UTF-8//TRANSLIT//IGNORE"
78 "\xff\xff;-c;ES2;UTF-8//TRANSLIT//IGNORE"
79 "\xff\xff;-c;EUC-CN;UTF-8//TRANSLIT//IGNORE"
80 "\xff\xff;-c;EUC-JISX0213;UTF-8//TRANSLIT//IGNORE"
81 "\xff\xff;-c;EUC-JP;UTF-8//TRANSLIT//IGNORE"
82 "\xff\xff;-c;EUC-JP-MS;UTF-8//TRANSLIT//IGNORE"
83 "\xff\xff;-c;EUC-KR;UTF-8//TRANSLIT//IGNORE"
84 "\xff\xff;-c;EUC-TW;UTF-8//TRANSLIT//IGNORE"
85 "\xff\xff;-c;GB18030;UTF-8//TRANSLIT//IGNORE"
86 "\xff\xff;-c;GB_1988-80;UTF-8//TRANSLIT//IGNORE"
87 "\xff\xff;-c;GBK;UTF-8//TRANSLIT//IGNORE"
88 "\xff\xff;-c;GOST_19768-74;UTF-8//TRANSLIT//IGNORE"
89 "\xff\xff;-c;GREEK7;UTF-8//TRANSLIT//IGNORE"
90 "\xff\xff;-c;GREEK7-OLD;UTF-8//TRANSLIT//IGNORE"
91 "\xff\xff;-c;GREEK-CCITT;UTF-8//TRANSLIT//IGNORE"
92 "\xff\xff;-c;HP-GREEK8;UTF-8//TRANSLIT//IGNORE"
93 "\xff\xff;-c;HP-ROMAN8;UTF-8//TRANSLIT//IGNORE"
94 "\xff\xff;-c;HP-ROMAN9;UTF-8//TRANSLIT//IGNORE"
95 "\xff\xff;-c;HP-THAI8;UTF-8//TRANSLIT//IGNORE"
96 "\xff\xff;-c;HP-TURKISH8;UTF-8//TRANSLIT//IGNORE"
97 "\x00\x41;-c;IBM038;UTF-8//TRANSLIT//IGNORE"
98 "\x00\x80;-c;IBM1004;UTF-8//TRANSLIT//IGNORE"
99 "\x00\xff;-c;IBM1008;UTF-8//TRANSLIT//IGNORE"
100 "\xff\xff;-c;IBM1046;UTF-8//TRANSLIT//IGNORE"
101 "\x00\x51;-c;IBM1132;UTF-8//TRANSLIT//IGNORE"
102 "\x00\xa0;-c;IBM1133;UTF-8//TRANSLIT//IGNORE"
103 "\x00\xce;-c;IBM1137;UTF-8//TRANSLIT//IGNORE"
104 "\x00\x80;-c;IBM1161;UTF-8//TRANSLIT//IGNORE"
105 "\x00\xdb;-c;IBM1162;UTF-8//TRANSLIT//IGNORE"
106 "\x00\x70;-c;IBM12712;UTF-8//TRANSLIT//IGNORE"
107 "\x00\x0f;-c;IBM1364;UTF-8"
108 "\x0e\x0e;-c;IBM1364;UTF-8"
109 "\x00\x0f;-c;IBM1371;UTF-8"
110 "\x0e\x0e;-c;IBM1371;UTF-8"
111 "\x00\x0f;-c;IBM1388;UTF-8"
112 "\x0e\x0e;-c;IBM1388;UTF-8"
113 "\x00\x0f;-c;IBM1390;UTF-8"
114 "\x0e\x0e;-c;IBM1390;UTF-8"
115 "\x00\x0f;-c;IBM1399;UTF-8"
116 "\x0e\x0e;-c;IBM1399;UTF-8"
117 "\x00\x53;-c;IBM16804;UTF-8//TRANSLIT//IGNORE"
118 "\x00\x41;-c;IBM274;UTF-8//TRANSLIT//IGNORE"
119 "\x00\x41;-c;IBM275;UTF-8//TRANSLIT//IGNORE"
120 "\x00\x41;-c;IBM281;UTF-8//TRANSLIT//IGNORE"
121 "\x00\x57;-c;IBM290;UTF-8//TRANSLIT//IGNORE"
122 "\x00\x45;-c;IBM420;UTF-8//TRANSLIT//IGNORE"
123 "\x00\x68;-c;IBM423;UTF-8//TRANSLIT//IGNORE"
124 "\x00\x70;-c;IBM424;UTF-8//TRANSLIT//IGNORE"
125 "\x00\x53;-c;IBM4517;UTF-8//TRANSLIT//IGNORE"
126 "\x00\x53;-c;IBM4899;UTF-8//TRANSLIT//IGNORE"
127 "\x00\xa5;-c;IBM4909;UTF-8//TRANSLIT//IGNORE"
128 "\x00\xdc;-c;IBM4971;UTF-8//TRANSLIT//IGNORE"
129 "\x00\x41;-c;IBM803;UTF-8//TRANSLIT//IGNORE"
130 "\x00\x91;-c;IBM851;UTF-8//TRANSLIT//IGNORE"
131 "\x00\x9b;-c;IBM856;UTF-8//TRANSLIT//IGNORE"
132 "\x00\xd5;-c;IBM857;UTF-8//TRANSLIT//IGNORE"
133 "\xff\xff;-c;IBM864;UTF-8//TRANSLIT//IGNORE"
134 "\x00\x94;-c;IBM868;UTF-8//TRANSLIT//IGNORE"
135 "\x00\x94;-c;IBM869;UTF-8//TRANSLIT//IGNORE"
136 "\xff\xff;-c;IBM874;UTF-8//TRANSLIT//IGNORE"
137 "\x00\x6a;-c;IBM875;UTF-8//TRANSLIT//IGNORE"
138 "\x00\x41;-c;IBM880;UTF-8//TRANSLIT//IGNORE"
139 "\x00\x80;-c;IBM891;UTF-8//TRANSLIT//IGNORE"
140 "\xff\xff;-c;IBM903;UTF-8//TRANSLIT//IGNORE"
141 "\xff\xff;-c;IBM904;UTF-8//TRANSLIT//IGNORE"
142 "\x00\x41;-c;IBM905;UTF-8//TRANSLIT//IGNORE"
143 "\x00\x80;-c;IBM9066;UTF-8//TRANSLIT//IGNORE"
144 "\x00\x48;-c;IBM918;UTF-8//TRANSLIT//IGNORE"
145 "\x00\x57;-c;IBM930;UTF-8//TRANSLIT//IGNORE"
146 "\x00\x80;-c;IBM932;UTF-8//TRANSLIT//IGNORE"
147 "\x00\x41;-c;IBM933;UTF-8//TRANSLIT//IGNORE"
148 "\x00\x41;-c;IBM935;UTF-8//TRANSLIT//IGNORE"
149 "\x00\x41;-c;IBM937;UTF-8//TRANSLIT//IGNORE"
150 "\x00\x41;-c;IBM939;UTF-8//TRANSLIT//IGNORE"
151 "\x00\x80;-c;IBM943;UTF-8//TRANSLIT//IGNORE"
152 "\xff\xff;-c;INIS;UTF-8//TRANSLIT//IGNORE"
153 "\xff\xff;-c;INIS-8;UTF-8//TRANSLIT//IGNORE"
154 "\xff\xff;-c;INIS-CYRILLIC;UTF-8//TRANSLIT//IGNORE"
155 "\x00\xec;-c;ISIRI-3342;UTF-8//TRANSLIT//IGNORE"
156 "\x00\xec;-c;ISO_10367-BOX;UTF-8//TRANSLIT//IGNORE"
157 "\xff\xff;-c;ISO-2022-CN;UTF-8//TRANSLIT//IGNORE"
158 "\xff\xff;-c;ISO-2022-CN-EXT;UTF-8//TRANSLIT//IGNORE"
159 "\xff\xff;-c;ISO-2022-JP;UTF-8//TRANSLIT//IGNORE"
160 "\xff\xff;-c;ISO-2022-JP-2;UTF-8//TRANSLIT//IGNORE"
161 "\xff\xff;-c;ISO-2022-JP-3;UTF-8//TRANSLIT//IGNORE"
162 "\xff\xff;-c;ISO-2022-KR;UTF-8//TRANSLIT//IGNORE"
163 "\xff\xff;-c;ISO_2033;UTF-8//TRANSLIT//IGNORE"
164 "\xff\xff;-c;ISO_5427;UTF-8//TRANSLIT//IGNORE"
165 "\xff\xff;-c;ISO_5427-EXT;UTF-8//TRANSLIT//IGNORE"
166 "\xff\xff;-c;ISO_5428;UTF-8//TRANSLIT//IGNORE"
167 "\x00\xa4;-c;ISO_6937;UTF-8//TRANSLIT//IGNORE"
168 "\x00\xa0;-c;ISO_6937-2;UTF-8//TRANSLIT//IGNORE"
169 "\xff\xff;-c;ISO-8859-11;UTF-8//TRANSLIT//IGNORE"
170 "\x00\xa5;-c;ISO-8859-3;UTF-8//TRANSLIT//IGNORE"
171 "\xff\xff;-c;ISO-8859-6;UTF-8//TRANSLIT//IGNORE"
172 "\xff\xff;-c;ISO-8859-7;UTF-8//TRANSLIT//IGNORE"
173 "\xff\xff;-c;ISO-8859-8;UTF-8//TRANSLIT//IGNORE"
174 "\x00\x80;-c;ISO-IR-197;UTF-8//TRANSLIT//IGNORE"
175 "\x00\x80;-c;ISO-IR-209;UTF-8//TRANSLIT//IGNORE"
176 "\x00\x80;-c;IT;UTF-8//TRANSLIT//IGNORE"
177 "\x00\x80;-c;JIS_C6220-1969-RO;UTF-8//TRANSLIT//IGNORE"
178 "\x00\x80;-c;JIS_C6229-1984-B;UTF-8//TRANSLIT//IGNORE"
179 "\x00\x80;-c;JOHAB;UTF-8//TRANSLIT//IGNORE"
180 "\x00\x80;-c;JUS_I.B1.002;UTF-8//TRANSLIT//IGNORE"
181 "\x00\x80;-c;KOI-8;UTF-8//TRANSLIT//IGNORE"
182 "\x00\x88;-c;KOI8-T;UTF-8//TRANSLIT//IGNORE"
183 "\xff\xff;-c;KSC5636;UTF-8//TRANSLIT//IGNORE"
184 "\xff\xff;-c;LATIN-GREEK;UTF-8//TRANSLIT//IGNORE"
185 "\xff\xff;-c;LATIN-GREEK-1;UTF-8//TRANSLIT//IGNORE"
186 "\x00\xf6;-c;MAC-IS;UTF-8//TRANSLIT//IGNORE"
187 "\xff\xff;-c;MSZ_7795.3;UTF-8//TRANSLIT//IGNORE"
188 "\xff\xff;-c;NATS-DANO;UTF-8//TRANSLIT//IGNORE"
189 "\xff\xff;-c;NATS-SEFI;UTF-8//TRANSLIT//IGNORE"
190 "\xff\xff;-c;NC_NC00-10;UTF-8//TRANSLIT//IGNORE"
191 "\xff\xff;-c;NF_Z_62-010;UTF-8//TRANSLIT//IGNORE"
192 "\xff\xff;-c;NF_Z_62-010_1973;UTF-8//TRANSLIT//IGNORE"
193 "\xff\xff;-c;NS_4551-1;UTF-8//TRANSLIT//IGNORE"
194 "\xff\xff;-c;NS_4551-2;UTF-8//TRANSLIT//IGNORE"
195 "\xff\xff;-c;PT;UTF-8//TRANSLIT//IGNORE"
196 "\xff\xff;-c;PT2;UTF-8//TRANSLIT//IGNORE"
197 "\x00\x98;-c;RK1048;UTF-8//TRANSLIT//IGNORE"
198 "\x00\x98;-c;SEN_850200_B;UTF-8//TRANSLIT//IGNORE"
199 "\x00\x98;-c;SEN_850200_C;UTF-8//TRANSLIT//IGNORE"
200 "\x00\x80;-c;Shift_JISX0213;UTF-8//TRANSLIT//IGNORE"
201 "\x00\x80;-c;SJIS;UTF-8//TRANSLIT//IGNORE"
202 "\x00\x23;-c;T.61-8BIT;UTF-8//TRANSLIT//IGNORE"
203 "\xff\xff;-c;TIS-620;UTF-8//TRANSLIT//IGNORE"
204 "\xff\xff;-c;TSCII;UTF-8//TRANSLIT//IGNORE"
205 "\xff\xff;-c;UHC;UTF-8//TRANSLIT//IGNORE"
206 "\x00\xd8;-c;UNICODE;UTF-8//TRANSLIT//IGNORE"
207 "\x00\xdc;-c;UTF-16;UTF-8//TRANSLIT//IGNORE"
208 "\xdc\x00;-c;UTF-16BE;UTF-8//TRANSLIT//IGNORE"
209 "\x00\xdc;-c;UTF-16LE;UTF-8//TRANSLIT//IGNORE"
210 "\xff\xff;-c;UTF-7;UTF-8//TRANSLIT//IGNORE"
211 "\x00\x81;-c;WIN-SAMI-2;UTF-8//TRANSLIT//IGNORE"
214 # List of option combinations that *should* lead to an error
215 errorarray=(
216 # Converting from/to invalid character sets should cause error
217 "\x00\x00;;INVALID;INVALID"
218 "\x00\x00;;INVALID;UTF-8"
219 "\x00\x00;;UTF-8;INVALID"
222 # Requires $twobyte input, $c flag, $from, and $to to be set; sets $ret
223 execute_test ()
225 eval PROG=\"$ICONV\"
226 echo -en "$twobyte" \
227 | timeout -k 4 $((3*$TIMEOUTFACTOR)) \
228 $PROG $c -f $from -t "$to" &>/dev/null
229 ret=$?
232 check_hangtest_result ()
234 if [ "$ret" -eq "124" ] || [ "$ret" -eq "137" ]; then # timeout/hang
235 result="HANG"
236 else
237 if [ "$ret" -eq "139" ]; then # segfault
238 result="SEGFAULT"
239 else
240 if [ "$ret" -gt "127" ]; then # unexpected error
241 result="UNEXPECTED"
242 else
243 result="OK"
248 echo -n "$result: from: \"$from\", to: \"$to\","
249 echo " input \"$twobyte\", flags \"$c\""
251 if [ "$result" != "OK" ]; then
252 exit 1
256 for hangcommand in "${hangarray[@]}"; do
257 twobyte="$(echo "$hangcommand" | cut -d";" -f 1)"
258 c="$(echo "$hangcommand" | cut -d";" -f 2)"
259 from="$(echo "$hangcommand" | cut -d";" -f 3)"
260 to="$(echo "$hangcommand" | cut -d";" -f 4)"
261 execute_test
262 check_hangtest_result
263 done
265 check_errtest_result ()
267 if [ "$ret" -eq "1" ]; then # we errored out as expected
268 result="PASS"
269 else
270 result="FAIL"
272 echo -n "$result: from: \"$from\", to: \"$to\","
273 echo " input \"$twobyte\", flags \"$c\", return code $ret"
275 if [ "$result" != "PASS" ]; then
276 exit 1
280 for errorcommand in "${errorarray[@]}"; do
281 twobyte="$(echo "$errorcommand" | cut -d";" -f 1)"
282 c="$(echo "$errorcommand" | cut -d";" -f 2)"
283 from="$(echo "$errorcommand" | cut -d";" -f 3)"
284 to="$(echo "$errorcommand" | cut -d";" -f 4)"
285 execute_test
286 check_errtest_result
287 done