Home | History | Annotate | Line # | Download | only in gdb
      1 # $NetBSD: t_regress.sh,v 1.3 2020/06/25 11:12:03 jruoho Exp $
      2 #
      3 # Copyright (c) 2016 The NetBSD Foundation, Inc.
      4 # All rights reserved.
      5 #
      6 # Redistribution and use in source and binary forms, with or without
      7 # modification, are permitted provided that the following conditions
      8 # are met:
      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.
     14 #
     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.
     26 #
     27 
     28 # Regression tests for some GDB PRs
     29 
     30 atf_test_case threads
     31 threads_head() {
     32 	atf_set "descr" "Test that gdb works with " \
     33 		"threaded programs (PR bin/47430)"
     34 	atf_set "require.progs" "gdb"
     35 }
     36 threads_body() {
     37 	# Dig at an unused IP address so that dig fails the
     38 	# same way on machines with Internet connectivity
     39 	# as on those without.
     40 	cat <<EOF >test.gdb
     41 run +time=1 +tries=1 @127.0.0.177
     42 cont
     43 cont
     44 cont
     45 cont
     46 cont
     47 EOF
     48 	gdb --batch -x test.gdb dig >gdb.out
     49 	atf_check -s exit:1 -o ignore -e ignore grep "Program received signal SIGTRAP" gdb.out
     50 }
     51 
     52 atf_test_case pie
     53 pie_head() {
     54 	atf_set "descr" "Test that gdb works with " \
     55 		"PIE executables (PR bin/48250)"
     56 	atf_set "require.progs" "cc gdb"
     57 }
     58 pie_body() {
     59 	cat <<\EOF >test.c
     60 #include <stdio.h>
     61 int main(int argc, char **argv) { printf ("hello\n"); return 0; }
     62 EOF
     63 	cc -fpie -pie -g test.c -o test
     64 	cat <<EOF >test.gdb
     65 break main
     66 run
     67 EOF
     68 	gdb --batch -x test.gdb ./test >gdb.out 2>&1
     69 	atf_check -s exit:1 -o ignore -e ignore grep "annot access memory" gdb.out
     70 }
     71 
     72 atf_test_case xml
     73 xml_head() {
     74 	atf_set "descr" "Test that gdb was built " \
     75 		"with XML support (PR bin/54154)"
     76 	atf_set "require.progs" "gdb"
     77 }
     78 xml_body() {
     79 	cat <<\EOF >target.xml
     80 <target version="1.0">
     81   <architecture>i386:x86-64</architecture>
     82 </target>
     83 EOF
     84 	cat <<EOF >test.gdb
     85 set tdesc filename "target.xml"
     86 EOF
     87 	gdb --batch -x test.gdb >gdb.out 2>&1
     88 	atf_check -s exit:1 -o ignore -e ignore grep "Can not parse XML" gdb.out
     89 }
     90 
     91 atf_init_test_cases() {
     92 	atf_add_test_case threads
     93 	atf_add_test_case pie
     94 	atf_add_test_case xml
     95 }
     96