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 ]"
37 eval $2 atf_check
-s signal
:6 -o ignore
-e ignore
$1
43 atf_set
"descr" "Checks sprintf(3)"
47 prog
="$(atf_get_srcdir)/h_sprintf"
50 h_fail
"$prog 0123456789"
53 atf_test_case vsprintf
56 atf_set
"descr" "Checks vsprintf(3)"
60 prog
="$(atf_get_srcdir)/h_vsprintf"
63 h_fail
"$prog 0123456789"
66 atf_test_case snprintf
69 atf_set
"descr" "Checks snprintf(3)"
73 prog
="$(atf_get_srcdir)/h_snprintf"
79 atf_test_case vsnprintf
82 atf_set
"descr" "Checks vsnprintf(3)"
86 prog
="$(atf_get_srcdir)/h_vsnprintf"
95 atf_set
"descr" "Checks gets(3)"
99 prog
="$(atf_get_srcdir)/h_gets"
101 h_pass
"$prog" "echo ok |"
102 h_fail
"$prog" "echo 0123456789 |"
108 atf_set
"descr" "Checks fgets(3)"
112 prog
="$(atf_get_srcdir)/h_fgets"
114 h_pass
"$prog 10" "echo ok |"
115 h_fail
"$prog 11" "echo busted |"
121 atf_set
"descr" "Checks memcpy(3)"
125 prog
="$(atf_get_srcdir)/h_memcpy"
131 atf_test_case memmove
134 atf_set
"descr" "Checks memmove(3)"
138 prog
="$(atf_get_srcdir)/h_memmove"
147 atf_set
"descr" "Checks memset(3)"
151 prog
="$(atf_get_srcdir)/h_memset"
160 atf_set
"descr" "Checks strcpy(3)"
164 prog
="$(atf_get_srcdir)/h_strcpy"
166 h_pass
"$prog 0123456"
167 h_fail
"$prog 0123456789"
173 atf_set
"descr" "Checks stpcpy(3)"
177 prog
="$(atf_get_srcdir)/h_stpcpy"
179 h_pass
"$prog 0123456"
180 h_fail
"$prog 0123456789"
186 atf_set
"descr" "Checks strcat(3)"
190 prog
="$(atf_get_srcdir)/h_strcat"
192 h_pass
"$prog 0123456"
193 h_fail
"$prog 0123456789ABCDEF"
196 atf_test_case strncpy
199 atf_set
"descr" "Checks strncpy(3)"
203 prog
="$(atf_get_srcdir)/h_strncpy"
209 atf_test_case stpncpy
212 atf_set
"descr" "Checks stpncpy(3)"
216 prog
="$(atf_get_srcdir)/h_stpncpy"
222 atf_test_case strncat
225 atf_set
"descr" "Checks strncat(3)"
229 prog
="$(atf_get_srcdir)/h_strncat"
238 atf_set
"descr" "Checks raw array overflow"
242 prog
="$(atf_get_srcdir)/h_raw"
251 atf_set
"descr" "Checks read(2)"
255 prog
="$(atf_get_srcdir)/h_read"
257 h_pass
"$prog 1024" "echo foo |"
258 h_fail
"$prog 1025" "echo bar |"
261 atf_test_case readlink
264 atf_set
"descr" "Checks readlink(2)"
268 prog
="$(atf_get_srcdir)/h_readlink"
277 atf_set
"descr" "Checks getcwd(3)"
281 prog
="$(atf_get_srcdir)/h_getcwd"
287 atf_init_test_cases
()
289 atf_add_test_case sprintf
290 atf_add_test_case vsprintf
291 atf_add_test_case snprintf
292 atf_add_test_case vsnprintf
293 atf_add_test_case gets
294 atf_add_test_case fgets
295 atf_add_test_case memcpy
296 atf_add_test_case memmove
297 atf_add_test_case memset
298 atf_add_test_case stpcpy
299 atf_add_test_case stpncpy
300 atf_add_test_case strcat
301 atf_add_test_case strcpy
302 atf_add_test_case strncat
303 atf_add_test_case strncpy
304 atf_add_test_case raw
305 atf_add_test_case
read
306 atf_add_test_case readlink
307 atf_add_test_case getcwd