]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh
- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
[FreeBSD/releng/10.3.git] / contrib / netbsd-tests / lib / libc / ssp / t_ssp.sh
1 # $NetBSD: t_ssp.sh,v 1.7 2014/04/06 19:28:59 christos Exp $
2 #
3 # Copyright (c) 2008 The NetBSD Foundation, Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 #    notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 #    notice, this list of conditions and the following disclaimer in the
13 #    documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
26 #
27
28 h_pass()
29 {
30         echo "Executing command [ $2$1 ]"
31         eval $2 atf_check -s exit:0 -o ignore -e ignore $1
32 }
33
34 h_fail()
35 {
36         echo "Executing command [ $2$1 ]"
37         # Begin FreeBSD
38         ulimit -c 0
39         if true; then
40                 eval $2 atf_check -s signal -o ignore -e ignore $1
41         else
42         # End FreeBSD
43         eval $2 atf_check -s signal:6 -o ignore -e ignore $1
44         # Begin FreeBSD
45         fi
46         # End FreeBSD
47 }
48
49 atf_test_case sprintf
50 sprintf_head()
51 {
52         atf_set "descr" "Checks sprintf(3)"
53 }
54 sprintf_body()
55 {
56         prog="$(atf_get_srcdir)/h_sprintf"
57
58         h_pass "$prog ok"
59         # Begin FreeBSD
60         if true; then
61                 h_fail "$prog 0123456789ab"
62         else
63         # End FreeBSD
64         h_fail "$prog 0123456789"
65         # Begin FreeBSD
66         fi
67         # End FreeBSD
68 }
69
70 atf_test_case vsprintf
71 vsprintf_head()
72 {
73         atf_set "descr" "Checks vsprintf(3)"
74 }
75 vsprintf_body()
76 {
77         prog="$(atf_get_srcdir)/h_vsprintf"
78
79         h_pass "$prog ok"
80         # Begin FreeBSD
81         if true; then
82                 h_fail "$prog 0123456789ab"
83         else
84         # End FreeBSD
85         h_fail "$prog 0123456789"
86         # Begin FreeBSD
87         fi
88         # End FreeBSD
89 }
90
91 atf_test_case snprintf
92 snprintf_head()
93 {
94         atf_set "descr" "Checks snprintf(3)"
95 }
96 snprintf_body()
97 {
98         prog="$(atf_get_srcdir)/h_snprintf"
99
100         h_pass "$prog 10"
101         # Begin FreeBSD
102         if true; then
103                 h_fail "$prog 13"
104         else
105         # End FreeBSD
106         h_fail "$prog 11"
107         # Begin FreeBSD
108         fi
109         # End FreeBSD
110 }
111
112 atf_test_case vsnprintf
113 vsnprintf_head()
114 {
115         atf_set "descr" "Checks vsnprintf(3)"
116 }
117 vsnprintf_body()
118 {
119         prog="$(atf_get_srcdir)/h_vsnprintf"
120
121         h_pass "$prog 10"
122         # Begin FreeBSD
123         if true; then
124                 h_fail "$prog 13"
125         else
126         # End FreeBSD
127         h_fail "$prog 11"
128         # Begin FreeBSD
129         fi
130         # End FreeBSD
131 }
132
133 atf_test_case gets
134 gets_head()
135 {
136         atf_set "descr" "Checks gets(3)"
137 }
138 gets_body()
139 {
140         prog="$(atf_get_srcdir)/h_gets"
141
142         h_pass "$prog" "echo ok |"
143         # Begin FreeBSD
144         if true; then
145                 h_fail "$prog" "echo 0123456789ab |"
146         else
147         # End FreeBSD
148         h_fail "$prog" "echo 0123456789 |"
149         # Begin FreeBSD
150         fi
151         # End FreeBSD
152 }
153
154 atf_test_case fgets
155 fgets_head()
156 {
157         atf_set "descr" "Checks fgets(3)"
158 }
159 fgets_body()
160 {
161         prog="$(atf_get_srcdir)/h_fgets"
162
163         h_pass "$prog 10" "echo ok |"
164         # Begin FreeBSD
165         if true; then
166                 h_fail "$prog 13" "echo 0123456789abc |"
167         else
168         # End FreeBSD
169         h_fail "$prog 11" "echo busted |"
170         # Begin FreeBSD
171         fi
172         # End FreeBSD
173 }
174
175 atf_test_case memcpy
176 memcpy_head()
177 {
178         atf_set "descr" "Checks memcpy(3)"
179 }
180 memcpy_body()
181 {
182         prog="$(atf_get_srcdir)/h_memcpy"
183
184         h_pass "$prog 10"
185         # Begin FreeBSD
186         if true; then
187                 h_fail "$prog 13"
188         else
189         # End FreeBSD
190         h_fail "$prog 11"
191         # Begin FreeBSD
192         fi
193         # End FreeBSD
194 }
195
196 atf_test_case memmove
197 memmove_head()
198 {
199         atf_set "descr" "Checks memmove(3)"
200 }
201 memmove_body()
202 {
203         prog="$(atf_get_srcdir)/h_memmove"
204
205         h_pass "$prog 10"
206         # Begin FreeBSD
207         if true; then
208                 h_fail "$prog 13"
209         else
210         # End FreeBSD
211         h_fail "$prog 11"
212         # Begin FreeBSD
213         fi
214         # End FreeBSD
215 }
216
217 atf_test_case memset
218 memset_head()
219 {
220         atf_set "descr" "Checks memset(3)"
221 }
222 memset_body()
223 {
224         prog="$(atf_get_srcdir)/h_memset"
225
226         h_pass "$prog 10"
227         # Begin FreeBSD
228         if true; then
229                 h_fail "$prog 13"
230         else
231         # End FreeBSD
232         h_fail "$prog 11"
233         # Begin FreeBSD
234         fi
235         # End FreeBSD
236 }
237
238 atf_test_case strcpy
239 strcpy_head()
240 {
241         atf_set "descr" "Checks strcpy(3)"
242 }
243 strcpy_body()
244 {
245         prog="$(atf_get_srcdir)/h_strcpy"
246
247         h_pass "$prog 0123456"
248         # Begin FreeBSD
249         if true; then
250                 h_fail "$prog 0123456789ab"
251         else
252         # End FreeBSD
253         h_fail "$prog 0123456789"
254         # Begin FreeBSD
255         fi
256         # End FreeBSD
257 }
258
259 atf_test_case stpcpy
260 stpcpy_head()
261 {
262         atf_set "descr" "Checks stpcpy(3)"
263 }
264 stpcpy_body()
265 {
266         prog="$(atf_get_srcdir)/h_stpcpy"
267
268         h_pass "$prog 0123456"
269         # Begin FreeBSD
270         if true; then
271                 h_fail "$prog 0123456789ab"
272         else
273         # End FreeBSD
274         h_fail "$prog 0123456789"
275         # Begin FreeBSD
276         fi
277         # End FreeBSD
278 }
279
280 atf_test_case strcat
281 strcat_head()
282 {
283         atf_set "descr" "Checks strcat(3)"
284 }
285 strcat_body()
286 {
287         prog="$(atf_get_srcdir)/h_strcat"
288
289         h_pass "$prog 0123456"
290         h_fail "$prog 0123456789ABCDEF"
291 }
292
293 atf_test_case strncpy
294 strncpy_head()
295 {
296         atf_set "descr" "Checks strncpy(3)"
297 }
298 strncpy_body()
299 {
300         prog="$(atf_get_srcdir)/h_strncpy"
301
302         h_pass "$prog 10"
303         # Begin FreeBSD
304         if true; then
305                 h_fail "$prog 13"
306         else
307         # End FreeBSD
308         h_fail "$prog 11"
309         # Begin FreeBSD
310         fi
311         # End FreeBSD
312 }
313
314 atf_test_case stpncpy
315 stpncpy_head()
316 {
317         atf_set "descr" "Checks stpncpy(3)"
318 }
319 stpncpy_body()
320 {
321         prog="$(atf_get_srcdir)/h_stpncpy"
322
323         h_pass "$prog 10"
324         # Begin FreeBSD
325         if true; then
326                 h_fail "$prog 13"
327         else
328         # End FreeBSD
329         h_fail "$prog 11"
330         # Begin FreeBSD
331         fi
332         # End FreeBSD
333 }
334
335 atf_test_case strncat
336 strncat_head()
337 {
338         atf_set "descr" "Checks strncat(3)"
339 }
340 strncat_body()
341 {
342         prog="$(atf_get_srcdir)/h_strncat"
343
344         # Begin FreeBSD
345         h_pass "$prog 8"
346         if true; then
347                 h_fail "$prog 11"
348         else
349         # End FreeBSD
350         h_fail "$prog 9"
351         # Begin FreeBSD
352         fi
353         # End FreeBSD
354 }
355
356 atf_test_case raw
357 raw_head()
358 {
359         atf_set "descr" "Checks raw array overflow"
360 }
361 raw_body()
362 {
363         prog="$(atf_get_srcdir)/h_raw"
364
365         h_pass "$prog 9"
366         # Begin FreeBSD
367         if true; then
368                 h_fail "$prog 12"
369         else
370         # End FreeBSD
371         h_fail "$prog 10"
372         # Begin FreeBSD
373         fi
374         # End FreeBSD
375 }
376
377 atf_test_case read
378 read_head()
379 {
380         atf_set "descr" "Checks read(2)"
381 }
382 read_body()
383 {
384         prog="$(atf_get_srcdir)/h_read"
385
386         h_pass "$prog 1024" "echo foo |"
387         # Begin FreeBSD
388         if true; then
389                 h_fail "$prog 1027" "echo bar |"
390         else
391         # End FreeBSD
392         h_fail "$prog 1025" "echo bar |"
393         # Begin FreeBSD
394         fi
395         # End FreeBSD
396 }
397
398 atf_test_case readlink
399 readlink_head()
400 {
401         atf_set "descr" "Checks readlink(2)"
402 }
403 readlink_body()
404 {
405         prog="$(atf_get_srcdir)/h_readlink"
406
407         # Begin FreeBSD
408         if true; then
409                 h_pass "$prog 512"
410                 h_fail "$prog 523"
411         else
412         # End FreeBSD
413         h_pass "$prog 1024"
414         h_fail "$prog 1025"
415         # Begin FreeBSD
416         fi
417         # End FreeBSD
418 }
419
420 atf_test_case getcwd
421 getcwd_head()
422 {
423         atf_set "descr" "Checks getcwd(3)"
424 }
425 getcwd_body()
426 {
427         prog="$(atf_get_srcdir)/h_getcwd"
428
429         h_pass "$prog 1024"
430         # Begin FreeBSD
431         if false; then
432         # End FreeBSD
433         h_fail "$prog 1025"
434         # Begin FreeBSD
435         fi
436         # End FreeBSD
437 }
438
439 atf_init_test_cases()
440 {
441         atf_add_test_case sprintf
442         atf_add_test_case vsprintf
443         atf_add_test_case snprintf
444         atf_add_test_case vsnprintf
445         atf_add_test_case gets
446         atf_add_test_case fgets
447         atf_add_test_case memcpy
448         atf_add_test_case memmove
449         atf_add_test_case memset
450         atf_add_test_case stpcpy
451         atf_add_test_case stpncpy
452         atf_add_test_case strcat
453         atf_add_test_case strcpy
454         atf_add_test_case strncat
455         atf_add_test_case strncpy
456         atf_add_test_case raw
457         atf_add_test_case read
458         atf_add_test_case readlink
459         atf_add_test_case getcwd
460 }