xref: /freebsd/tools/test/sort/bigtest/kcmd (revision fed1ca4b719c56c930f2259d80663cd34be812bb)
1#!/bin/sh
2
3# $FreeBSD$
4
5rm -rf siks
6mkdir -p siks
7
8export GNUSORT_NUMERIC_COMPATIBILITY=x
9
10BSDSORT=../sort
11GNUSORT=~/coreutils/bin/sort
12#GNUSORT=sort
13
14FILECMP=cmp
15
16INPUT_FILE=si
17
18rm -rf test.log
19
20#ru_RU.ISO-8859-5 en_US.ISO8859-15 zh_HK.Big5HKSCS
21#
22# ru KOI-8 is an "irregular" locale with non-trivial ordering.
23# zh* is a 2-bytes locale
24
25for lang in ru_RU.KOI8-R C ru_RU.ISO-8859-5 en_US.ISO8859-15 zh_HK.Big5HKSCS
26do
27
28    export LANG=${lang}
29
30    for KEYS in -srh -sfrudb -Vs -sM -siz
31    do
32
33	echo ${LANG} ${KEYS}
34
35	${BSDSORT} ${KEYS} ${INPUT_FILE} -o siks/sik1
36	ER=$?
37	if ! [ ${ER} -eq 0 ] ; then
38	    echo ${LANG} ${KEYS} crash >> test.log
39	    exit
40	fi
41	${GNUSORT} ${KEYS} ${INPUT_FILE} -o siks/sik2
42	if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.0.0 2>&1 ; then
43	    echo ${LANG} ${KEYS}  error >> test.log
44	fi
45	${BSDSORT} -c ${KEYS}  siks/sik1
46	ER=$?
47	if ! [ ${ER} -eq 0 ] ; then
48	    echo ${LANG} ${KEYS}  -c error  >> test.log
49	fi
50	rm siks/res.0.0
51
52	${BSDSORT} ${KEYS} -t " "  ${INPUT_FILE} -o siks/sik1
53	ER=$?
54	if ! [ ${ER} -eq 0 ] ; then
55	    echo ${LANG} ${KEYS} -t " " crash >> test.log
56	    exit
57	fi
58	${GNUSORT} ${KEYS} -t " "  ${INPUT_FILE} -o siks/sik2
59	if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.0.0 2>&1 ; then
60	    echo ${LANG} ${KEYS} error -t " " >> test.log
61	fi
62	${BSDSORT} -c -t " " ${KEYS}  siks/sik1
63	ER=$?
64	if ! [ ${ER} -eq 0 ] ; then
65	    echo $? ${LANG} ${KEYS}  -t " " -c error >> test.log
66	fi
67	rm siks/res.0.0
68
69	${BSDSORT} ${KEYS} -t "|"  ${INPUT_FILE} -o siks/sik1
70	ER=$?
71	if ! [ ${ER} -eq 0 ] ; then
72	    echo ${LANG} ${KEYS} -t "|" crash >> test.log
73	    exit
74	fi
75	${GNUSORT} ${KEYS} -t "|"  ${INPUT_FILE} -o siks/sik2
76	if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.0.0 2>&1 ; then
77	    echo ${LANG} ${KEYS}  error -t "|" >> test.log
78	fi
79	${BSDSORT} -c -t "|" ${KEYS}  siks/sik1
80	ER=$?
81	if ! [ ${ER} -eq 0 ] ; then
82	    echo ${LANG} ${KEYS}  -c -t "|" error >> test.log
83	fi
84	rm siks/res.0.0
85
86	${BSDSORT} ${KEYS} -t '\0' ${INPUT_FILE} -o siks/sik1
87	ER=$?
88	if ! [ ${ER} -eq 0 ] ; then
89	    echo ${LANG} ${KEYS} -t 0 crash >> test.log
90	    exit
91	fi
92	${GNUSORT} ${KEYS} -t '\0' ${INPUT_FILE} -o siks/sik2
93	if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.0.0 2>&1 ; then
94	    echo ${LANG} ${KEYS} error -t '\0' >> test.log
95	fi
96	${BSDSORT} -c -t '\0' ${KEYS} siks/sik1
97	ER=$?
98	if ! [ ${ER} -eq 0 ] ; then
99	    echo ${LANG} ${KEYS} -c -t '\0' error >> test.log
100	fi
101	rm siks/res.0.0
102
103	for f1 in 1 2 3 4 5 6 7 8 9
104	do
105	    for c1 in 1 2 3 4 5 10 15 20 25 30
106	    do
107		echo ${LANG} ${KEYS} ${f1} ${c1}
108
109		${BSDSORT} ${KEYS} +${f1}.${c1} ${INPUT_FILE} -o siks/sik1
110		ER=$?
111		if ! [ ${ER} -eq 0 ] ; then
112	        echo ${LANG} ${KEYS} +${f1}.${c1} crash +- >> test.log
113	        exit
114		fi
115		${GNUSORT} ${KEYS} +${f1}.${c1} ${INPUT_FILE} -o siks/sik2
116		if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1} 2>&1 ; then
117		    echo ${LANG} ${KEYS} +${f1}.${c1} error +- >> test.log
118		fi
119		${BSDSORT} -c ${KEYS} +${f1}.${c1} siks/sik1
120		ER=$?
121		if ! [ ${ER} -eq 0 ] ; then
122		    echo ${LANG} ${KEYS} +${f1}.${c1} -c error +- >> test.log
123		fi
124		rm siks/res.${f1}.${c1}
125
126		${BSDSORT} ${KEYS} -k${f1}.${c1} ${INPUT_FILE} -o siks/sik1
127		ER=$?
128		if ! [ ${ER} -eq 0 ] ; then
129	        echo ${LANG} ${KEYS} -k${f1}.${c1} crash >> test.log
130	        exit
131		fi
132		${GNUSORT} ${KEYS} -k${f1}.${c1} ${INPUT_FILE} -o siks/sik2
133		if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1} 2>&1 ; then
134		    echo ${LANG} ${KEYS} -k${f1}.${c1} error >> test.log
135		fi
136		${BSDSORT} -c ${KEYS} -k${f1}.${c1} siks/sik1
137		ER=$?
138		if ! [ ${ER} -eq 0 ] ; then
139		    echo ${LANG} ${KEYS} -k${f1}.${c1} -c error >> test.log
140		fi
141		rm siks/res.${f1}.${c1}
142
143		${BSDSORT} ${KEYS} -k${f1}.${c1}b ${INPUT_FILE} -o siks/sik1
144		ER=$?
145		if ! [ ${ER} -eq 0 ] ; then
146	        echo ${LANG} ${KEYS} -k${f1}.${c1}b crash >> test.log
147	        exit
148		fi
149		${GNUSORT} ${KEYS} -k${f1}.${c1}b ${INPUT_FILE} -o siks/sik2
150		if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1} 2>&1 ; then
151		    echo ${LANG} ${KEYS} -k${f1}.${c1}b error >> test.log
152		fi
153		${BSDSORT} -c ${KEYS} -k${f1}.${c1}b siks/sik1
154		ER=$?
155		if ! [ ${ER} -eq 0 ] ; then
156		    echo ${LANG} ${KEYS} -k${f1}.${c1}b -c error >> test.log
157		fi
158		rm siks/res.${f1}.${c1}
159
160		${BSDSORT} ${KEYS} -t " " -k${f1}.${c1} ${INPUT_FILE} -o siks/sik1
161		ER=$?
162		if ! [ ${ER} -eq 0 ] ; then
163	            echo ${LANG} ${KEYS} -t -k${f1}.${c1} crash >> test.log
164	            exit
165		fi
166		${GNUSORT} ${KEYS} -t " " -k${f1}.${c1} ${INPUT_FILE} -o siks/sik2
167		if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1} 2>&1 ; then
168		    echo ${LANG} ${KEYS} -k${f1}.${c1} error -t " " >> test.log
169		fi
170		${BSDSORT} -c -t " " ${KEYS} -k${f1}.${c1} siks/sik1
171		ER=$?
172		if ! [ ${ER} -eq 0 ] ; then
173		    echo ${LANG} ${KEYS} -k${f1}.${c1} -t " " -c error >> test.log
174		fi
175		rm siks/res.${f1}.${c1}
176
177		${BSDSORT} ${KEYS} -t " " -k${f1}.${c1}n ${INPUT_FILE} -o siks/sik1
178		ER=$?
179		if ! [ ${ER} -eq 0 ] ; then
180	            echo ${LANG} ${KEYS} -k${f1}.${c1}n crash >> test.log
181	            exit
182		fi
183		${GNUSORT} ${KEYS} -t " " -k${f1}.${c1}n ${INPUT_FILE} -o siks/sik2
184		if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1} 2>&1 ; then
185		    echo ${LANG} ${KEYS} -k${f1}.${c1} error -t " " n >> test.log
186		fi
187		${BSDSORT} -c -t " " ${KEYS} -k${f1}.${c1}n siks/sik1
188		ER=$?
189		if ! [ ${ER} -eq 0 ] ; then
190		    echo ${LANG} ${KEYS} -k${f1}.${c1} -c -t " " n error >> test.log
191		fi
192		rm siks/res.${f1}.${c1}
193
194		${BSDSORT} ${KEYS} -t "|" -k${f1}.${c1} ${INPUT_FILE} -o siks/sik1
195		ER=$?
196		if ! [ ${ER} -eq 0 ] ; then
197	            echo ${LANG} ${KEYS} -t "|" -k${f1}.${c1} crash >> test.log
198	            exit
199		fi
200		${GNUSORT} ${KEYS} -t "|" -k${f1}.${c1} ${INPUT_FILE} -o siks/sik2
201		if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1} 2>&1 ; then
202		    echo ${LANG} ${KEYS} -k${f1}.${c1} error -t "|" >> test.log
203		fi
204		${BSDSORT} -c -t "|" ${KEYS} -k${f1}.${c1} siks/sik1
205		ER=$?
206		if ! [ ${ER} -eq 0 ] ; then
207		    echo ${LANG} ${KEYS} -k${f1}.${c1} -c -t "|" error >> test.log
208		fi
209		rm siks/res.${f1}.${c1}
210
211		for f2 in 1 2 3 4 5 6 7 8 9 10
212		do
213		    for c2 in 0 1 2 3 4 5 10 15 20 25 30
214		    do
215			echo ${LANG} ${KEYS} ${f1} ${c1} ${f2} ${c2}
216
217			${BSDSORT} ${KEYS} +${f1}.${c1} -${f2}.${c2} ${INPUT_FILE} -o siks/sik1
218	    		ER=$?
219	    		if ! [ ${ER} -eq 0 ] ; then
220	        	    echo ${LANG} ${KEYS} +${f1}.${c1} -${f2}.${c2} crash >> test.log
221	        	    exit
222			fi
223			${GNUSORT} ${KEYS} +${f1}.${c1} -${f2}.${c2} ${INPUT_FILE} -o siks/sik2
224			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
225			    echo ${LANG} ${KEYS} +${f1}.${c1} -${f2}.${c2} error +- >> test.log
226			fi
227			${BSDSORT} -c ${KEYS} +${f1}.${c1} -${f2}.${c2} siks/sik1
228			ER=$?
229			if ! [ ${ER} -eq 0 ] ; then
230			    echo ${LANG} ${KEYS} +${f1}.${c1} -${f2}.${c2} -c error +- >> test.log
231			fi
232			rm siks/res.${f1}.${c1}.${f2}.${c2}
233
234			${BSDSORT} ${KEYS} -k${f1}.${c1},${f2}.${c2} ${INPUT_FILE} -o siks/sik1
235	    		ER=$?
236	    		if ! [ ${ER} -eq 0 ] ; then
237	        	    echo ${LANG} ${KEYS} -k${f1}.${c1},${f2}.${c2} crash >> test.log
238	        	    exit
239			fi
240			${GNUSORT} ${KEYS} -k${f1}.${c1},${f2}.${c2} ${INPUT_FILE} -o siks/sik2
241			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
242			    echo ${LANG} ${KEYS} -k${f1}.${c1}.${f2}.${c2} error >> test.log
243			fi
244			${BSDSORT} -c ${KEYS} -k${f1}.${c1},${f2}.${c2} siks/sik1
245			ER=$?
246			if ! [ ${ER} -eq 0 ] ; then
247			    echo ${LANG} ${KEYS} -k${f1}.${c1},${f2}.${c2} -c error >> test.log
248			fi
249			rm siks/res.${f1}.${c1}.${f2}.${c2}
250
251			${BSDSORT} ${KEYS} -k${f1}.${c1}b,${f2}.${c2} ${INPUT_FILE} -o siks/sik1
252	    		ER=$?
253	    		if ! [ ${ER} -eq 0 ] ; then
254	        	    echo ${LANG} ${KEYS} -k${f1}.${c1}b,${f2}.${c2} crash >> test.log
255	        	    exit
256			fi
257			${GNUSORT} ${KEYS} -k${f1}.${c1}b,${f2}.${c2} ${INPUT_FILE} -o siks/sik2
258			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
259			    echo ${LANG} ${KEYS} -k${f1}.${c1}.b.${f2}.${c2} error >> test.log
260			fi
261			${BSDSORT} -c ${KEYS} -k${f1}.${c1}b,${f2}.${c2} siks/sik1
262			ER=$?
263			if ! [ ${ER} -eq 0 ] ; then
264			    echo ${LANG} ${KEYS} -k${f1}.${c1}b,${f2}.${c2} -c error >> test.log
265			fi
266			rm siks/res.${f1}.${c1}.${f2}.${c2}
267
268			${BSDSORT} ${KEYS} -t " " -k${f1}.${c1},${f2}.${c2} ${INPUT_FILE} -o siks/sik1
269	    		ER=$?
270	    		if ! [ ${ER} -eq 0 ] ; then
271	        	    echo ${LANG} ${KEYS} -t " " -k${f1}.${c1},${f2}.${c2} crash >> test.log
272	        	    exit
273			fi
274			${GNUSORT} ${KEYS} -t " " -k${f1}.${c1},${f2}.${c2} ${INPUT_FILE} -o siks/sik2
275			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
276			    echo ${LANG} ${KEYS} -k${f1}.${c1}.${f2}.${c2} error -t " " >> test.log
277			fi
278			${BSDSORT} -c -t " " ${KEYS} -k${f1}.${c1},${f2}.${c2} siks/sik1
279			ER=$?
280			if ! [ ${ER} -eq 0 ] ; then
281			    echo ${LANG} ${KEYS} -k${f1}.${c1},${f2}.${c2} -c -t " " error >> test.log
282			fi
283			rm siks/res.${f1}.${c1}.${f2}.${c2}
284
285			${BSDSORT} ${KEYS} -t " " -k${f1}.${c1}n,${f2}.${c2} ${INPUT_FILE} -o siks/sik1
286	    		ER=$?
287	    		if ! [ ${ER} -eq 0 ] ; then
288	        	    echo ${LANG} ${KEYS} -t " " -k${f1}.${c1}n,${f2}.${c2} crash >> test.log
289	        	    exit
290			fi
291			${GNUSORT} ${KEYS} -t " " -k${f1}.${c1}n,${f2}.${c2} ${INPUT_FILE} -o siks/sik2
292			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
293			    echo ${LANG} ${KEYS} -t " " -k${f1}.${c1}.${f2}.${c2} error n >> test.log
294			fi
295			${BSDSORT} -c -t " " ${KEYS} -k${f1}.${c1}n,${f2}.${c2} siks/sik1
296			ER=$?
297			if ! [ ${ER} -eq 0 ] ; then
298			    echo ${LANG} ${KEYS} -k${f1}.${c1},${f2}.${c2} -c -t " " n error >> test.log
299			fi
300			rm siks/res.${f1}.${c1}.${f2}.${c2}
301
302			${BSDSORT} ${KEYS} -t '\0' -k${f1}.${c1}n,${f2}.${c2} ${INPUT_FILE} -o siks/sik1
303	    		ER=$?
304	    		if ! [ ${ER} -eq 0 ] ; then
305	        	    echo ${LANG} ${KEYS} -t '\0' -k${f1}.${c1}n,${f2}.${c2} crash >> test.log
306	        	    exit
307			fi
308			${GNUSORT} ${KEYS} -t '\0' -k${f1}.${c1}n,${f2}.${c2} ${INPUT_FILE} -o siks/sik2
309			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
310			    echo ${LANG} ${KEYS} -k${f1}.${c1}.${f2}.${c2} error -t '\0' n >> test.log
311			fi
312			${BSDSORT} -c -t '\0' ${KEYS} -k${f1}.${c1}n,${f2}.${c2} siks/sik1
313			ER=$?
314			if ! [ ${ER} -eq 0 ] ; then
315			    echo ${LANG} ${KEYS} -k${f1}.${c1},${f2}.${c2} -c -t '\0' n error >> test.log
316			fi
317			rm siks/res.${f1}.${c1}.${f2}.${c2}
318
319			${BSDSORT} ${KEYS} -t "|" -k${f1}.${c1},${f2}.${c2} ${INPUT_FILE} -o siks/sik1
320	    		ER=$?
321	    		if ! [ ${ER} -eq 0 ] ; then
322	        	    echo ${LANG} ${KEYS} -t "|" -k${f1}.${c1},${f2}.${c2} crash >> test.log
323	        	    exit
324			fi
325			${GNUSORT} ${KEYS} -t "|" -k${f1}.${c1},${f2}.${c2} ${INPUT_FILE} -o siks/sik2
326			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
327			    echo ${LANG} ${KEYS} -k${f1}.${c1}.${f2}.${c2} error -t "|" >> test.log
328			fi
329			${BSDSORT} -c -t "|" ${KEYS} -k${f1}.${c1},${f2}.${c2} siks/sik1
330			ER=$?
331			if ! [ ${ER} -eq 0 ] ; then
332			    echo ${LANG} ${KEYS} -k${f1}.${c1},${f2}.${c2} -c -t "|" error >> test.log
333			fi
334			rm siks/res.${f1}.${c1}.${f2}.${c2}
335
336			${BSDSORT} ${KEYS} -t "|" -k${f1}.${c1},${f2}.${c2} -k${f2}.${c1},${f1}.${c2} ${INPUT_FILE} -o siks/sik1
337	    		ER=$?
338	    		if ! [ ${ER} -eq 0 ] ; then
339	        	    echo ${LANG} ${KEYS} -t "|" -k${f1}.${c1},${f2}.${c2} -k${f2}.${c1},${f1}.${c2} crash >> test.log
340	        	    exit
341			fi
342			${GNUSORT} ${KEYS} -t "|" -k${f1}.${c1},${f2}.${c2} -k${f2}.${c1},${f1}.${c2} ${INPUT_FILE} -o siks/sik2
343			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
344			    echo ${LANG} ${KEYS} -k${f1}.${c1}.${f2}.${c2} error -t "|" 2k >> test.log
345			fi
346			${BSDSORT} -c -t "|" ${KEYS} -k${f1}.${c1},${f2}.${c2} -k${f2}.${c1},${f1}.${c2} siks/sik1
347			ER=$?
348			if ! [ ${ER} -eq 0 ] ; then
349			    echo ${LANG} ${KEYS} -k${f1}.${c1},${f2}.${c2} -c -t "|" 2k error >> test.log
350			fi
351			rm siks/res.${f1}.${c1}.${f2}.${c2}
352
353			${BSDSORT} ${KEYS} -k${f1}.${c1}b,${f2}.${c2} -k${f2}.${c1},${f1}.${c2} ${INPUT_FILE} -o siks/sik1
354	    		ER=$?
355	    		if ! [ ${ER} -eq 0 ] ; then
356	        	    echo ${LANG} ${KEYS} -k${f1}.${c1}b,${f2}.${c2} -k${f2}.${c1},${f1}.${c2} crash >> test.log
357	        	    exit
358			fi
359			${GNUSORT} ${KEYS} -k${f1}.${c1}b,${f2}.${c2} -k${f2}.${c1},${f1}.${c2} ${INPUT_FILE} -o siks/sik2
360			if ! ${FILECMP} siks/sik1 siks/sik2 >siks/res.${f1}.${c1}.${f2}.${c2} 2>&1 ; then
361			    echo ${LANG} ${KEYS} -k${f1}.${c1}.b.${f2}.${c2} error 2k >> test.log
362			fi
363			${BSDSORT} -c ${KEYS} -k${f1}.${c1}b,${f2}.${c2} -k${f2}.${c1},${f1}.${c2} siks/sik1
364			ER=$?
365			if ! [ ${ER} -eq 0 ] ; then
366			    echo ${LANG} ${KEYS} -k${f1}.${c1}b,${f2}.${c2} -c 2k error >> test.log
367			fi
368			rm siks/res.${f1}.${c1}.${f2}.${c2}
369
370		    done
371		done
372	    done
373	done
374    done
375done
376
377