1 # $NetBSD: t_ssp.sh,v 1.7 2014/04/06 19:28:59 christos Exp $
3 # Copyright (c) 2008 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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.
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.
30 echo "Executing command [ $2$1 ]"
31 eval $2 atf_check -s exit:0 -o ignore -e ignore $1
36 echo "Executing command [ $2$1 ]"
40 eval $2 atf_check -s signal -o ignore -e ignore $1
43 eval $2 atf_check -s signal:6 -o ignore -e ignore $1
52 atf_set "descr" "Checks sprintf(3)"
56 prog="$(atf_get_srcdir)/h_sprintf"
61 h_fail "$prog 0123456789ab"
64 h_fail "$prog 0123456789"
70 atf_test_case vsprintf
73 atf_set "descr" "Checks vsprintf(3)"
77 prog="$(atf_get_srcdir)/h_vsprintf"
82 h_fail "$prog 0123456789ab"
85 h_fail "$prog 0123456789"
91 atf_test_case snprintf
94 atf_set "descr" "Checks snprintf(3)"
98 prog="$(atf_get_srcdir)/h_snprintf"
112 atf_test_case vsnprintf
115 atf_set "descr" "Checks vsnprintf(3)"
119 prog="$(atf_get_srcdir)/h_vsnprintf"
136 atf_set "descr" "Checks gets(3)"
140 prog="$(atf_get_srcdir)/h_gets"
142 h_pass "$prog" "echo ok |"
145 h_fail "$prog" "echo 0123456789ab |"
148 h_fail "$prog" "echo 0123456789 |"
157 atf_set "descr" "Checks fgets(3)"
161 prog="$(atf_get_srcdir)/h_fgets"
163 h_pass "$prog 10" "echo ok |"
166 h_fail "$prog 13" "echo 0123456789abc |"
169 h_fail "$prog 11" "echo busted |"
178 atf_set "descr" "Checks memcpy(3)"
182 prog="$(atf_get_srcdir)/h_memcpy"
196 atf_test_case memmove
199 atf_set "descr" "Checks memmove(3)"
203 prog="$(atf_get_srcdir)/h_memmove"
220 atf_set "descr" "Checks memset(3)"
224 prog="$(atf_get_srcdir)/h_memset"
241 atf_set "descr" "Checks strcpy(3)"
245 prog="$(atf_get_srcdir)/h_strcpy"
247 h_pass "$prog 0123456"
250 h_fail "$prog 0123456789ab"
253 h_fail "$prog 0123456789"
262 atf_set "descr" "Checks stpcpy(3)"
266 prog="$(atf_get_srcdir)/h_stpcpy"
268 h_pass "$prog 0123456"
271 h_fail "$prog 0123456789ab"
274 h_fail "$prog 0123456789"
283 atf_set "descr" "Checks strcat(3)"
287 prog="$(atf_get_srcdir)/h_strcat"
289 h_pass "$prog 0123456"
290 h_fail "$prog 0123456789ABCDEF"
293 atf_test_case strncpy
296 atf_set "descr" "Checks strncpy(3)"
300 prog="$(atf_get_srcdir)/h_strncpy"
314 atf_test_case stpncpy
317 atf_set "descr" "Checks stpncpy(3)"
321 prog="$(atf_get_srcdir)/h_stpncpy"
335 atf_test_case strncat
338 atf_set "descr" "Checks strncat(3)"
342 prog="$(atf_get_srcdir)/h_strncat"
359 atf_set "descr" "Checks raw array overflow"
363 prog="$(atf_get_srcdir)/h_raw"
365 [ -x $prog ] || atf_skip "$prog is missing; skipping testcase"
383 atf_set "descr" "Checks read(2)"
387 prog="$(atf_get_srcdir)/h_read"
391 MAX_PATH=$(getconf _XOPEN_PATH_MAX) || atf_fail "getconf failed"
392 h_pass "$prog $MAX_PATH" "echo foo |"
393 h_fail "$prog $(( $MAX_PATH + 3 ))" "echo bar |"
396 h_pass "$prog 1024" "echo foo |"
397 h_fail "$prog 1025" "echo bar |"
403 atf_test_case readlink
406 atf_set "descr" "Checks readlink(2)"
410 prog="$(atf_get_srcdir)/h_readlink"
428 atf_set "descr" "Checks getcwd(3)"
432 prog="$(atf_get_srcdir)/h_getcwd"
444 atf_init_test_cases()
446 atf_add_test_case sprintf
447 atf_add_test_case vsprintf
448 atf_add_test_case snprintf
449 atf_add_test_case vsnprintf
450 atf_add_test_case gets
451 atf_add_test_case fgets
452 atf_add_test_case memcpy
453 atf_add_test_case memmove
454 atf_add_test_case memset
455 atf_add_test_case stpcpy
456 atf_add_test_case stpncpy
457 atf_add_test_case strcat
458 atf_add_test_case strcpy
459 atf_add_test_case strncat
460 atf_add_test_case strncpy
461 atf_add_test_case raw
462 atf_add_test_case read
463 atf_add_test_case readlink
464 atf_add_test_case getcwd