xref: /netbsd-src/tests/usr.bin/gdb/t_regress.sh (revision bf613d334239dc669c9330f8a8b4e87340b0068f)
1*bf613d33Sjruoho# $NetBSD: t_regress.sh,v 1.3 2020/06/25 11:12:03 jruoho Exp $
25973801cSgson#
35973801cSgson# Copyright (c) 2016 The NetBSD Foundation, Inc.
45973801cSgson# All rights reserved.
55973801cSgson#
65973801cSgson# Redistribution and use in source and binary forms, with or without
75973801cSgson# modification, are permitted provided that the following conditions
85973801cSgson# are met:
95973801cSgson# 1. Redistributions of source code must retain the above copyright
105973801cSgson#    notice, this list of conditions and the following disclaimer.
115973801cSgson# 2. Redistributions in binary form must reproduce the above copyright
125973801cSgson#    notice, this list of conditions and the following disclaimer in the
135973801cSgson#    documentation and/or other materials provided with the distribution.
145973801cSgson#
155973801cSgson# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
165973801cSgson# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
175973801cSgson# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
185973801cSgson# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
195973801cSgson# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
205973801cSgson# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
215973801cSgson# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
225973801cSgson# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
235973801cSgson# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
245973801cSgson# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
255973801cSgson# POSSIBILITY OF SUCH DAMAGE.
265973801cSgson#
275973801cSgson
285973801cSgson# Regression tests for some GDB PRs
295973801cSgson
305973801cSgsonatf_test_case threads
315973801cSgsonthreads_head() {
32*bf613d33Sjruoho	atf_set "descr" "Test that gdb works with " \
33*bf613d33Sjruoho		"threaded programs (PR bin/47430)"
345973801cSgson	atf_set "require.progs" "gdb"
355973801cSgson}
365973801cSgsonthreads_body() {
375973801cSgson	# Dig at an unused IP address so that dig fails the
385973801cSgson	# same way on machines with Internet connectivity
395973801cSgson	# as on those without.
405973801cSgson	cat <<EOF >test.gdb
415973801cSgsonrun +time=1 +tries=1 @127.0.0.177
425973801cSgsoncont
435973801cSgsoncont
445973801cSgsoncont
455973801cSgsoncont
465973801cSgsoncont
475973801cSgsonEOF
485973801cSgson	gdb --batch -x test.gdb dig >gdb.out
495973801cSgson	atf_check -s exit:1 -o ignore -e ignore grep "Program received signal SIGTRAP" gdb.out
505973801cSgson}
515973801cSgson
525973801cSgsonatf_test_case pie
535973801cSgsonpie_head() {
54*bf613d33Sjruoho	atf_set "descr" "Test that gdb works with " \
55*bf613d33Sjruoho		"PIE executables (PR bin/48250)"
565973801cSgson	atf_set "require.progs" "cc gdb"
575973801cSgson}
585973801cSgsonpie_body() {
595973801cSgson	cat <<\EOF >test.c
605973801cSgson#include <stdio.h>
615973801cSgsonint main(int argc, char **argv) { printf ("hello\n"); return 0; }
625973801cSgsonEOF
635973801cSgson	cc -fpie -pie -g test.c -o test
645973801cSgson	cat <<EOF >test.gdb
655973801cSgsonbreak main
665973801cSgsonrun
675973801cSgsonEOF
685973801cSgson	gdb --batch -x test.gdb ./test >gdb.out 2>&1
695973801cSgson	atf_check -s exit:1 -o ignore -e ignore grep "annot access memory" gdb.out
705973801cSgson}
715973801cSgson
721430c33cSgsonatf_test_case xml
731430c33cSgsonxml_head() {
74*bf613d33Sjruoho	atf_set "descr" "Test that gdb was built " \
75*bf613d33Sjruoho		"with XML support (PR bin/54154)"
761430c33cSgson	atf_set "require.progs" "gdb"
771430c33cSgson}
781430c33cSgsonxml_body() {
791430c33cSgson	cat <<\EOF >target.xml
801430c33cSgson<target version="1.0">
811430c33cSgson  <architecture>i386:x86-64</architecture>
821430c33cSgson</target>
831430c33cSgsonEOF
841430c33cSgson	cat <<EOF >test.gdb
851430c33cSgsonset tdesc filename "target.xml"
861430c33cSgsonEOF
871430c33cSgson	gdb --batch -x test.gdb >gdb.out 2>&1
881430c33cSgson	atf_check -s exit:1 -o ignore -e ignore grep "Can not parse XML" gdb.out
891430c33cSgson}
901430c33cSgson
915973801cSgsonatf_init_test_cases() {
925973801cSgson	atf_add_test_case threads
935973801cSgson	atf_add_test_case pie
941430c33cSgson	atf_add_test_case xml
955973801cSgson}
96