Home | History | Annotate | Line # | Download | only in csu
t_hello.sh revision 1.1
      1  1.1  riastrad #	$NetBSD: t_hello.sh,v 1.1 2025/04/27 04:09:35 riastradh Exp $
      2  1.1  riastrad #
      3  1.1  riastrad # Copyright (c) 2025 The NetBSD Foundation, Inc.
      4  1.1  riastrad # All rights reserved.
      5  1.1  riastrad #
      6  1.1  riastrad # Redistribution and use in source and binary forms, with or without
      7  1.1  riastrad # modification, are permitted provided that the following conditions
      8  1.1  riastrad # are met:
      9  1.1  riastrad # 1. Redistributions of source code must retain the above copyright
     10  1.1  riastrad #    notice, this list of conditions and the following disclaimer.
     11  1.1  riastrad # 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  riastrad #    notice, this list of conditions and the following disclaimer in the
     13  1.1  riastrad #    documentation and/or other materials provided with the distribution.
     14  1.1  riastrad #
     15  1.1  riastrad # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1  riastrad # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1  riastrad # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1  riastrad # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1  riastrad # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1  riastrad # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1  riastrad # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1  riastrad # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1  riastrad # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1  riastrad # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  riastrad # POSSIBILITY OF SUCH DAMAGE.
     26  1.1  riastrad #
     27  1.1  riastrad 
     28  1.1  riastrad checksupport()
     29  1.1  riastrad {
     30  1.1  riastrad 	local prog
     31  1.1  riastrad 
     32  1.1  riastrad 	prog=$1
     33  1.1  riastrad 	test -f "$(atf_get_srcdir)/${prog}" || atf_skip "not supported"
     34  1.1  riastrad }
     35  1.1  riastrad 
     36  1.1  riastrad checkrun()
     37  1.1  riastrad {
     38  1.1  riastrad 	local prog
     39  1.1  riastrad 
     40  1.1  riastrad 	prog=$1
     41  1.1  riastrad 	atf_check -o inline:"${prog}: Hello, world! 42\n" \
     42  1.1  riastrad 	    "$(atf_get_srcdir)/${prog}"
     43  1.1  riastrad }
     44  1.1  riastrad 
     45  1.1  riastrad cleanup()
     46  1.1  riastrad {
     47  1.1  riastrad 	local prog
     48  1.1  riastrad 
     49  1.1  riastrad 	prog=$1
     50  1.1  riastrad 	test -f "${prog}.core" || return 0
     51  1.1  riastrad 	readelf -rs "$(atf_get_srcdir)/${prog}"
     52  1.1  riastrad 	gdb -batch -ex bt -ex 'info registers' -ex disas \
     53  1.1  riastrad 	    "$(atf_get_srcdir)/${prog}" "${prog}.core"
     54  1.1  riastrad }
     55  1.1  riastrad 
     56  1.1  riastrad atf_test_case dynamic cleanup
     57  1.1  riastrad dynamic_head()
     58  1.1  riastrad {
     59  1.1  riastrad 	atf_set "descr" "Test a dynamic executable"
     60  1.1  riastrad }
     61  1.1  riastrad dynamic_body()
     62  1.1  riastrad {
     63  1.1  riastrad 	checksupport h_hello_dyn
     64  1.1  riastrad 	checkrun h_hello_dyn
     65  1.1  riastrad }
     66  1.1  riastrad dynamic_cleanup()
     67  1.1  riastrad {
     68  1.1  riastrad 	cleanup h_hello_dyn
     69  1.1  riastrad }
     70  1.1  riastrad 
     71  1.1  riastrad atf_test_case dynamicpie cleanup
     72  1.1  riastrad dynamicpie_head()
     73  1.1  riastrad {
     74  1.1  riastrad 	atf_set "descr" "Test a dynamic position-independent executable"
     75  1.1  riastrad }
     76  1.1  riastrad dynamicpie_body()
     77  1.1  riastrad {
     78  1.1  riastrad 	checksupport h_hello_dynpie
     79  1.1  riastrad 	checkrun h_hello_dynpie
     80  1.1  riastrad }
     81  1.1  riastrad dynamicpie_cleanup()
     82  1.1  riastrad {
     83  1.1  riastrad 	cleanup h_hello_dynpie
     84  1.1  riastrad }
     85  1.1  riastrad 
     86  1.1  riastrad atf_test_case static cleanup
     87  1.1  riastrad static_head()
     88  1.1  riastrad {
     89  1.1  riastrad 	atf_set "descr" "Test a static executable"
     90  1.1  riastrad }
     91  1.1  riastrad static_body()
     92  1.1  riastrad {
     93  1.1  riastrad 	checksupport h_hello_sta
     94  1.1  riastrad 	checkrun h_hello_sta
     95  1.1  riastrad }
     96  1.1  riastrad static_cleanup()
     97  1.1  riastrad {
     98  1.1  riastrad 	cleanup h_hello_sta
     99  1.1  riastrad }
    100  1.1  riastrad 
    101  1.1  riastrad atf_test_case staticpie cleanup
    102  1.1  riastrad staticpie_head()
    103  1.1  riastrad {
    104  1.1  riastrad 	atf_set "descr" "Test a static position-independent executable"
    105  1.1  riastrad }
    106  1.1  riastrad staticpie_body()
    107  1.1  riastrad {
    108  1.1  riastrad 	checksupport h_hello_stapie
    109  1.1  riastrad 	case `uname -p` in
    110  1.1  riastrad 	i386|x86_64)
    111  1.1  riastrad 		;;
    112  1.1  riastrad 	*)	atf_expect_fail "PR lib/59359: static pies are broken"
    113  1.1  riastrad 		;;
    114  1.1  riastrad 	esac
    115  1.1  riastrad 	checkrun h_hello_stapie
    116  1.1  riastrad }
    117  1.1  riastrad staticpie_cleanup()
    118  1.1  riastrad {
    119  1.1  riastrad 	cleanup h_hello_stapie
    120  1.1  riastrad }
    121  1.1  riastrad 
    122  1.1  riastrad atf_init_test_cases()
    123  1.1  riastrad {
    124  1.1  riastrad 	atf_add_test_case dynamic
    125  1.1  riastrad 	atf_add_test_case dynamicpie
    126  1.1  riastrad 	atf_add_test_case static
    127  1.1  riastrad 	atf_add_test_case staticpie
    128  1.1  riastrad }
    129