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