1303980Sngie# $NetBSD: t_regress.sh,v 1.1 2016/04/08 10:09:16 gson Exp $
2303980Sngie#
3303980Sngie# Copyright (c) 2016 The NetBSD Foundation, Inc.
4303980Sngie# All rights reserved.
5303980Sngie#
6303980Sngie# Redistribution and use in source and binary forms, with or without
7303980Sngie# modification, are permitted provided that the following conditions
8303980Sngie# are met:
9303980Sngie# 1. Redistributions of source code must retain the above copyright
10303980Sngie#    notice, this list of conditions and the following disclaimer.
11303980Sngie# 2. Redistributions in binary form must reproduce the above copyright
12303980Sngie#    notice, this list of conditions and the following disclaimer in the
13303980Sngie#    documentation and/or other materials provided with the distribution.
14303980Sngie#
15303980Sngie# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16303980Sngie# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17303980Sngie# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18303980Sngie# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19303980Sngie# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20303980Sngie# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21303980Sngie# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22303980Sngie# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23303980Sngie# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24303980Sngie# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25303980Sngie# POSSIBILITY OF SUCH DAMAGE.
26303980Sngie#
27303980Sngie
28303980Sngie# Regression tests for some GDB PRs
29303980Sngie
30303980Sngie# PR 47430
31303980Sngie
32303980Sngieatf_test_case threads
33303980Sngiethreads_head() {
34303980Sngie	atf_set "descr" "Test that gdb works with threaded programs"
35303980Sngie	atf_set "require.progs" "gdb"
36303980Sngie}
37303980Sngiethreads_body() {
38303980Sngie	# Dig at an unused IP address so that dig fails the
39303980Sngie	# same way on machines with Internet connectivity
40303980Sngie	# as on those without.
41303980Sngie	cat <<EOF >test.gdb
42303980Sngierun +time=1 +tries=1 @127.0.0.177
43303980Sngiecont
44303980Sngiecont
45303980Sngiecont
46303980Sngiecont
47303980Sngiecont
48303980SngieEOF
49303980Sngie	gdb --batch -x test.gdb dig >gdb.out
50303980Sngie	atf_check -s exit:1 -o ignore -e ignore grep "Program received signal SIGTRAP" gdb.out
51303980Sngie}
52303980Sngie
53303980Sngie# PR 48250
54303980Sngie
55303980Sngieatf_test_case pie
56303980Sngiepie_head() {
57303980Sngie	atf_set "descr" "Test that gdb works with PIE executables"
58303980Sngie	atf_set "require.progs" "cc gdb"
59303980Sngie}
60303980Sngiepie_body() {
61303980Sngie	cat <<\EOF >test.c
62303980Sngie#include <stdio.h>
63303980Sngieint main(int argc, char **argv) { printf ("hello\n"); return 0; }
64303980SngieEOF
65303980Sngie	cc -fpie -pie -g test.c -o test
66303980Sngie	cat <<EOF >test.gdb
67303980Sngiebreak main
68303980Sngierun
69303980SngieEOF
70303980Sngie	gdb --batch -x test.gdb ./test >gdb.out 2>&1
71303980Sngie	atf_check -s exit:1 -o ignore -e ignore grep "annot access memory" gdb.out
72303980Sngie}
73303980Sngie
74303980Sngieatf_init_test_cases() {
75303980Sngie	atf_add_test_case threads
76303980Sngie	atf_add_test_case pie
77303980Sngie}
78