Home | History | Annotate | Line # | Download | only in ssp
      1  1.8  christos # $NetBSD: t_ssp.sh,v 1.8 2023/11/10 23:03:25 christos Exp $
      2  1.1  pgoyette #
      3  1.1  pgoyette # Copyright (c) 2008 The NetBSD Foundation, Inc.
      4  1.1  pgoyette # All rights reserved.
      5  1.1  pgoyette #
      6  1.1  pgoyette # Redistribution and use in source and binary forms, with or without
      7  1.1  pgoyette # modification, are permitted provided that the following conditions
      8  1.1  pgoyette # are met:
      9  1.1  pgoyette # 1. Redistributions of source code must retain the above copyright
     10  1.1  pgoyette #    notice, this list of conditions and the following disclaimer.
     11  1.1  pgoyette # 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  pgoyette #    notice, this list of conditions and the following disclaimer in the
     13  1.1  pgoyette #    documentation and/or other materials provided with the distribution.
     14  1.1  pgoyette #
     15  1.1  pgoyette # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1  pgoyette # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1  pgoyette # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1  pgoyette # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1  pgoyette # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1  pgoyette # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1  pgoyette # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1  pgoyette # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1  pgoyette # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1  pgoyette # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  pgoyette # POSSIBILITY OF SUCH DAMAGE.
     26  1.1  pgoyette #
     27  1.1  pgoyette 
     28  1.1  pgoyette h_pass()
     29  1.1  pgoyette {
     30  1.2  pgoyette 	echo "Executing command [ $2$1 ]"
     31  1.2  pgoyette 	eval $2 atf_check -s exit:0 -o ignore -e ignore $1
     32  1.1  pgoyette }
     33  1.1  pgoyette 
     34  1.1  pgoyette h_fail()
     35  1.1  pgoyette {
     36  1.2  pgoyette 	echo "Executing command [ $2$1 ]"
     37  1.2  pgoyette 	eval $2 atf_check -s signal:6 -o ignore -e ignore $1
     38  1.1  pgoyette }
     39  1.1  pgoyette 
     40  1.1  pgoyette atf_test_case sprintf
     41  1.1  pgoyette sprintf_head()
     42  1.1  pgoyette {
     43  1.1  pgoyette 	atf_set "descr" "Checks sprintf(3)"
     44  1.1  pgoyette }
     45  1.1  pgoyette sprintf_body()
     46  1.1  pgoyette {
     47  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_sprintf"
     48  1.1  pgoyette 
     49  1.1  pgoyette 	h_pass "$prog ok"
     50  1.1  pgoyette 	h_fail "$prog 0123456789"
     51  1.1  pgoyette }
     52  1.1  pgoyette 
     53  1.1  pgoyette atf_test_case vsprintf
     54  1.1  pgoyette vsprintf_head()
     55  1.1  pgoyette {
     56  1.1  pgoyette 	atf_set "descr" "Checks vsprintf(3)"
     57  1.1  pgoyette }
     58  1.1  pgoyette vsprintf_body()
     59  1.1  pgoyette {
     60  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_vsprintf"
     61  1.1  pgoyette 
     62  1.1  pgoyette 	h_pass "$prog ok"
     63  1.1  pgoyette 	h_fail "$prog 0123456789"
     64  1.1  pgoyette }
     65  1.1  pgoyette 
     66  1.1  pgoyette atf_test_case snprintf
     67  1.1  pgoyette snprintf_head()
     68  1.1  pgoyette {
     69  1.1  pgoyette 	atf_set "descr" "Checks snprintf(3)"
     70  1.1  pgoyette }
     71  1.1  pgoyette snprintf_body()
     72  1.1  pgoyette {
     73  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_snprintf"
     74  1.1  pgoyette 
     75  1.1  pgoyette 	h_pass "$prog 10"
     76  1.1  pgoyette 	h_fail "$prog 11"
     77  1.1  pgoyette }
     78  1.1  pgoyette 
     79  1.1  pgoyette atf_test_case vsnprintf
     80  1.1  pgoyette vsnprintf_head()
     81  1.1  pgoyette {
     82  1.1  pgoyette 	atf_set "descr" "Checks vsnprintf(3)"
     83  1.1  pgoyette }
     84  1.1  pgoyette vsnprintf_body()
     85  1.1  pgoyette {
     86  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_vsnprintf"
     87  1.1  pgoyette 
     88  1.1  pgoyette 	h_pass "$prog 10"
     89  1.1  pgoyette 	h_fail "$prog 11"
     90  1.1  pgoyette }
     91  1.1  pgoyette 
     92  1.1  pgoyette atf_test_case gets
     93  1.1  pgoyette gets_head()
     94  1.1  pgoyette {
     95  1.1  pgoyette 	atf_set "descr" "Checks gets(3)"
     96  1.1  pgoyette }
     97  1.1  pgoyette gets_body()
     98  1.1  pgoyette {
     99  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_gets"
    100  1.1  pgoyette 
    101  1.2  pgoyette 	h_pass "$prog" "echo ok |"
    102  1.2  pgoyette 	h_fail "$prog" "echo 0123456789 |"
    103  1.1  pgoyette }
    104  1.1  pgoyette 
    105  1.1  pgoyette atf_test_case fgets
    106  1.1  pgoyette fgets_head()
    107  1.1  pgoyette {
    108  1.1  pgoyette 	atf_set "descr" "Checks fgets(3)"
    109  1.1  pgoyette }
    110  1.1  pgoyette fgets_body()
    111  1.1  pgoyette {
    112  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_fgets"
    113  1.1  pgoyette 
    114  1.2  pgoyette 	h_pass "$prog 10" "echo ok |"
    115  1.2  pgoyette 	h_fail "$prog 11" "echo busted |"
    116  1.1  pgoyette }
    117  1.1  pgoyette 
    118  1.1  pgoyette atf_test_case memcpy
    119  1.1  pgoyette memcpy_head()
    120  1.1  pgoyette {
    121  1.1  pgoyette 	atf_set "descr" "Checks memcpy(3)"
    122  1.1  pgoyette }
    123  1.1  pgoyette memcpy_body()
    124  1.1  pgoyette {
    125  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_memcpy"
    126  1.1  pgoyette 
    127  1.1  pgoyette 	h_pass "$prog 10"
    128  1.1  pgoyette 	h_fail "$prog 11"
    129  1.1  pgoyette }
    130  1.1  pgoyette 
    131  1.1  pgoyette atf_test_case memmove
    132  1.1  pgoyette memmove_head()
    133  1.1  pgoyette {
    134  1.1  pgoyette 	atf_set "descr" "Checks memmove(3)"
    135  1.1  pgoyette }
    136  1.1  pgoyette memmove_body()
    137  1.1  pgoyette {
    138  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_memmove"
    139  1.1  pgoyette 
    140  1.1  pgoyette 	h_pass "$prog 10"
    141  1.1  pgoyette 	h_fail "$prog 11"
    142  1.1  pgoyette }
    143  1.1  pgoyette 
    144  1.1  pgoyette atf_test_case memset
    145  1.1  pgoyette memset_head()
    146  1.1  pgoyette {
    147  1.1  pgoyette 	atf_set "descr" "Checks memset(3)"
    148  1.1  pgoyette }
    149  1.1  pgoyette memset_body()
    150  1.1  pgoyette {
    151  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_memset"
    152  1.1  pgoyette 
    153  1.1  pgoyette 	h_pass "$prog 10"
    154  1.1  pgoyette 	h_fail "$prog 11"
    155  1.1  pgoyette }
    156  1.1  pgoyette 
    157  1.1  pgoyette atf_test_case strcpy
    158  1.1  pgoyette strcpy_head()
    159  1.1  pgoyette {
    160  1.1  pgoyette 	atf_set "descr" "Checks strcpy(3)"
    161  1.1  pgoyette }
    162  1.1  pgoyette strcpy_body()
    163  1.1  pgoyette {
    164  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_strcpy"
    165  1.1  pgoyette 
    166  1.1  pgoyette 	h_pass "$prog 0123456"
    167  1.1  pgoyette 	h_fail "$prog 0123456789"
    168  1.1  pgoyette }
    169  1.1  pgoyette 
    170  1.7  christos atf_test_case stpcpy
    171  1.7  christos stpcpy_head()
    172  1.7  christos {
    173  1.7  christos 	atf_set "descr" "Checks stpcpy(3)"
    174  1.7  christos }
    175  1.7  christos stpcpy_body()
    176  1.7  christos {
    177  1.7  christos 	prog="$(atf_get_srcdir)/h_stpcpy"
    178  1.7  christos 
    179  1.7  christos 	h_pass "$prog 0123456"
    180  1.7  christos 	h_fail "$prog 0123456789"
    181  1.7  christos }
    182  1.7  christos 
    183  1.1  pgoyette atf_test_case strcat
    184  1.1  pgoyette strcat_head()
    185  1.1  pgoyette {
    186  1.1  pgoyette 	atf_set "descr" "Checks strcat(3)"
    187  1.1  pgoyette }
    188  1.1  pgoyette strcat_body()
    189  1.1  pgoyette {
    190  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_strcat"
    191  1.1  pgoyette 
    192  1.1  pgoyette 	h_pass "$prog 0123456"
    193  1.6    martin 	h_fail "$prog 0123456789ABCDEF"
    194  1.1  pgoyette }
    195  1.1  pgoyette 
    196  1.1  pgoyette atf_test_case strncpy
    197  1.1  pgoyette strncpy_head()
    198  1.1  pgoyette {
    199  1.1  pgoyette 	atf_set "descr" "Checks strncpy(3)"
    200  1.1  pgoyette }
    201  1.1  pgoyette strncpy_body()
    202  1.1  pgoyette {
    203  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_strncpy"
    204  1.1  pgoyette 
    205  1.1  pgoyette 	h_pass "$prog 10"
    206  1.1  pgoyette 	h_fail "$prog 11"
    207  1.1  pgoyette }
    208  1.1  pgoyette 
    209  1.7  christos atf_test_case stpncpy
    210  1.7  christos stpncpy_head()
    211  1.7  christos {
    212  1.7  christos 	atf_set "descr" "Checks stpncpy(3)"
    213  1.7  christos }
    214  1.7  christos stpncpy_body()
    215  1.7  christos {
    216  1.7  christos 	prog="$(atf_get_srcdir)/h_stpncpy"
    217  1.7  christos 
    218  1.7  christos 	h_pass "$prog 10"
    219  1.7  christos 	h_fail "$prog 11"
    220  1.7  christos }
    221  1.7  christos 
    222  1.1  pgoyette atf_test_case strncat
    223  1.1  pgoyette strncat_head()
    224  1.1  pgoyette {
    225  1.1  pgoyette 	atf_set "descr" "Checks strncat(3)"
    226  1.1  pgoyette }
    227  1.1  pgoyette strncat_body()
    228  1.1  pgoyette {
    229  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_strncat"
    230  1.1  pgoyette 
    231  1.1  pgoyette 	h_pass "$prog 8"
    232  1.1  pgoyette 	h_fail "$prog 9"
    233  1.1  pgoyette }
    234  1.1  pgoyette 
    235  1.5    plunky atf_test_case raw
    236  1.5    plunky raw_head()
    237  1.5    plunky {
    238  1.5    plunky 	atf_set "descr" "Checks raw array overflow"
    239  1.5    plunky }
    240  1.5    plunky raw_body()
    241  1.5    plunky {
    242  1.5    plunky 	prog="$(atf_get_srcdir)/h_raw"
    243  1.5    plunky 
    244  1.5    plunky 	h_pass "$prog 9"
    245  1.5    plunky 	h_fail "$prog 10"
    246  1.5    plunky }
    247  1.5    plunky 
    248  1.1  pgoyette atf_test_case read
    249  1.1  pgoyette read_head()
    250  1.1  pgoyette {
    251  1.1  pgoyette 	atf_set "descr" "Checks read(2)"
    252  1.1  pgoyette }
    253  1.1  pgoyette read_body()
    254  1.1  pgoyette {
    255  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_read"
    256  1.1  pgoyette 
    257  1.2  pgoyette 	h_pass "$prog 1024" "echo foo |"
    258  1.2  pgoyette 	h_fail "$prog 1025" "echo bar |"
    259  1.1  pgoyette }
    260  1.1  pgoyette 
    261  1.1  pgoyette atf_test_case readlink
    262  1.1  pgoyette readlink_head()
    263  1.1  pgoyette {
    264  1.1  pgoyette 	atf_set "descr" "Checks readlink(2)"
    265  1.1  pgoyette }
    266  1.1  pgoyette readlink_body()
    267  1.1  pgoyette {
    268  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_readlink"
    269  1.1  pgoyette 
    270  1.1  pgoyette 	h_pass "$prog 1024"
    271  1.1  pgoyette 	h_fail "$prog 1025"
    272  1.1  pgoyette }
    273  1.1  pgoyette 
    274  1.1  pgoyette atf_test_case getcwd
    275  1.1  pgoyette getcwd_head()
    276  1.1  pgoyette {
    277  1.1  pgoyette 	atf_set "descr" "Checks getcwd(3)"
    278  1.1  pgoyette }
    279  1.1  pgoyette getcwd_body()
    280  1.1  pgoyette {
    281  1.1  pgoyette 	prog="$(atf_get_srcdir)/h_getcwd"
    282  1.1  pgoyette 
    283  1.1  pgoyette 	h_pass "$prog 1024"
    284  1.1  pgoyette 	h_fail "$prog 1025"
    285  1.1  pgoyette }
    286  1.1  pgoyette 
    287  1.8  christos atf_test_case getcwd2
    288  1.8  christos getcwd2_head()
    289  1.8  christos {
    290  1.8  christos 	atf_set "descr" "Checks getcwd(3) override"
    291  1.8  christos }
    292  1.8  christos getcwd2_body()
    293  1.8  christos {
    294  1.8  christos 	prog="$(atf_get_srcdir)/h_getcwd2"
    295  1.8  christos 
    296  1.8  christos 	atf_check -s exit:1 -o ignore \
    297  1.8  christos 	    -e 'match:.*getcwd failed: Function not implemented$' $prog
    298  1.8  christos }
    299  1.8  christos 
    300  1.1  pgoyette atf_init_test_cases()
    301  1.1  pgoyette {
    302  1.1  pgoyette 	atf_add_test_case sprintf
    303  1.1  pgoyette 	atf_add_test_case vsprintf
    304  1.1  pgoyette 	atf_add_test_case snprintf
    305  1.1  pgoyette 	atf_add_test_case vsnprintf
    306  1.1  pgoyette 	atf_add_test_case gets
    307  1.1  pgoyette 	atf_add_test_case fgets
    308  1.1  pgoyette 	atf_add_test_case memcpy
    309  1.1  pgoyette 	atf_add_test_case memmove
    310  1.1  pgoyette 	atf_add_test_case memset
    311  1.7  christos 	atf_add_test_case stpcpy
    312  1.7  christos 	atf_add_test_case stpncpy
    313  1.1  pgoyette 	atf_add_test_case strcat
    314  1.1  pgoyette 	atf_add_test_case strcpy
    315  1.1  pgoyette 	atf_add_test_case strncat
    316  1.1  pgoyette 	atf_add_test_case strncpy
    317  1.5    plunky 	atf_add_test_case raw
    318  1.1  pgoyette 	atf_add_test_case read
    319  1.1  pgoyette 	atf_add_test_case readlink
    320  1.1  pgoyette 	atf_add_test_case getcwd
    321  1.8  christos 	atf_add_test_case getcwd2
    322  1.1  pgoyette }
    323