xref: /freebsd/contrib/netbsd-tests/usr.bin/gdb/t_regress.sh (revision c22165b4f1f5d38b681921797a44b3ba8c13b7e0)
1*640235e2SEnji Cooper# $NetBSD: t_regress.sh,v 1.1 2016/04/08 10:09:16 gson Exp $
2*640235e2SEnji Cooper#
3*640235e2SEnji Cooper# Copyright (c) 2016 The NetBSD Foundation, Inc.
4*640235e2SEnji Cooper# All rights reserved.
5*640235e2SEnji Cooper#
6*640235e2SEnji Cooper# Redistribution and use in source and binary forms, with or without
7*640235e2SEnji Cooper# modification, are permitted provided that the following conditions
8*640235e2SEnji Cooper# are met:
9*640235e2SEnji Cooper# 1. Redistributions of source code must retain the above copyright
10*640235e2SEnji Cooper#    notice, this list of conditions and the following disclaimer.
11*640235e2SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright
12*640235e2SEnji Cooper#    notice, this list of conditions and the following disclaimer in the
13*640235e2SEnji Cooper#    documentation and/or other materials provided with the distribution.
14*640235e2SEnji Cooper#
15*640235e2SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16*640235e2SEnji Cooper# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17*640235e2SEnji Cooper# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18*640235e2SEnji Cooper# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19*640235e2SEnji Cooper# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20*640235e2SEnji Cooper# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21*640235e2SEnji Cooper# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22*640235e2SEnji Cooper# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23*640235e2SEnji Cooper# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24*640235e2SEnji Cooper# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25*640235e2SEnji Cooper# POSSIBILITY OF SUCH DAMAGE.
26*640235e2SEnji Cooper#
27*640235e2SEnji Cooper
28*640235e2SEnji Cooper# Regression tests for some GDB PRs
29*640235e2SEnji Cooper
30*640235e2SEnji Cooper# PR 47430
31*640235e2SEnji Cooper
32*640235e2SEnji Cooperatf_test_case threads
33*640235e2SEnji Cooperthreads_head() {
34*640235e2SEnji Cooper	atf_set "descr" "Test that gdb works with threaded programs"
35*640235e2SEnji Cooper	atf_set "require.progs" "gdb"
36*640235e2SEnji Cooper}
37*640235e2SEnji Cooperthreads_body() {
38*640235e2SEnji Cooper	# Dig at an unused IP address so that dig fails the
39*640235e2SEnji Cooper	# same way on machines with Internet connectivity
40*640235e2SEnji Cooper	# as on those without.
41*640235e2SEnji Cooper	cat <<EOF >test.gdb
42*640235e2SEnji Cooperrun +time=1 +tries=1 @127.0.0.177
43*640235e2SEnji Coopercont
44*640235e2SEnji Coopercont
45*640235e2SEnji Coopercont
46*640235e2SEnji Coopercont
47*640235e2SEnji Coopercont
48*640235e2SEnji CooperEOF
49*640235e2SEnji Cooper	gdb --batch -x test.gdb dig >gdb.out
50*640235e2SEnji Cooper	atf_check -s exit:1 -o ignore -e ignore grep "Program received signal SIGTRAP" gdb.out
51*640235e2SEnji Cooper}
52*640235e2SEnji Cooper
53*640235e2SEnji Cooper# PR 48250
54*640235e2SEnji Cooper
55*640235e2SEnji Cooperatf_test_case pie
56*640235e2SEnji Cooperpie_head() {
57*640235e2SEnji Cooper	atf_set "descr" "Test that gdb works with PIE executables"
58*640235e2SEnji Cooper	atf_set "require.progs" "cc gdb"
59*640235e2SEnji Cooper}
60*640235e2SEnji Cooperpie_body() {
61*640235e2SEnji Cooper	cat <<\EOF >test.c
62*640235e2SEnji Cooper#include <stdio.h>
63*640235e2SEnji Cooperint main(int argc, char **argv) { printf ("hello\n"); return 0; }
64*640235e2SEnji CooperEOF
65*640235e2SEnji Cooper	cc -fpie -pie -g test.c -o test
66*640235e2SEnji Cooper	cat <<EOF >test.gdb
67*640235e2SEnji Cooperbreak main
68*640235e2SEnji Cooperrun
69*640235e2SEnji CooperEOF
70*640235e2SEnji Cooper	gdb --batch -x test.gdb ./test >gdb.out 2>&1
71*640235e2SEnji Cooper	atf_check -s exit:1 -o ignore -e ignore grep "annot access memory" gdb.out
72*640235e2SEnji Cooper}
73*640235e2SEnji Cooper
74*640235e2SEnji Cooperatf_init_test_cases() {
75*640235e2SEnji Cooper	atf_add_test_case threads
76*640235e2SEnji Cooper	atf_add_test_case pie
77*640235e2SEnji Cooper}
78