1#   Copyright (C) 1988, 1990, 1991, 1992 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Rob Savoye. (rob@cygnus.com)
21
22if $tracelevel then {
23    strace $tracelevel
24}
25
26# This only works for native, I think.
27if ![isnative] then {
28    continue
29}
30
31#
32# test running programs
33#
34set prms_id 0
35set bug_id 0
36
37set testfile "run"
38set srcfile ${testfile}.c
39set binfile ${objdir}/${subdir}/${testfile}
40if  { [compile "${srcdir}/${subdir}/${srcfile} -g -o ${binfile}"] != "" } {
41    perror "Couldn't compile ${srcfile}"
42    return -1
43}
44
45delete_breakpoints
46gdb_reinitialize_dir $srcdir/$subdir
47gdb_load ${binfile}
48
49send "set print sevenbit-strings\n" ; expect -re "$prompt $"
50send "set print address off\n" ; expect -re "$prompt $"
51send "set width 0\n" ; expect -re "$prompt $"
52
53# Test that GDB correctly identifies that it does not control a terminal.
54send "info terminal\n"
55expect {
56    -re "No saved terminal information..*$prompt $"\
57	{ send "run 5\n"
58	    expect {
59		-re "Starting program.*$binfile.*120.*Program exited normally..*$prompt $"\
60		    { send "info terminal\n"
61			expect {
62			    -re "No saved terminal information..*$prompt $"\
63				{ pass "info terminal" }
64			    -re ".*$prompt $"	{ fail "info terminal" }
65			    timeout		{ fail "(timeout) info terminal" }
66			}
67		    }
68		-re ".*$prompt $"	{ fail "info terminal" }
69		timeout		{ fail "(timeout) info terminal" }
70	    }
71	}
72    -re ".*$prompt $"	{ fail "info terminal" }
73    timeout		{ fail "(timeout) info terminal" }
74}
75
76
77# In mid-execution
78send "break main\n"
79expect {
80    -re "Breakpoint.* file .*, line.*$prompt $"\
81	{ send "run 5\n"
82	    expect {
83		-re "Starting program.*Breakpoint \[0-9\]+,.*main.*if .argc != 2.*$prompt $"\
84		    { send "info terminal\n"
85			expect {
86			    -re "Inferior's terminal status .currently saved by GDB.:.*$prompt $"\
87				{ pass "info terminal at breakpoint" }
88			    -re ".*$prompt $"	{ fail "info terminal at breakpoint" }
89			    timeout			{ fail "(timeout) info terminal at breakpoint" }
90			}
91		    }
92		-re ".*$prompt $"	{ fail "info terminal at breakpoint" }
93		timeout			{ fail "(timeout) info terminal at breakpoint" }
94	    }
95	}
96    -re ".*$prompt $"	{ fail "info terminal at breakpoint" }
97    timeout		{ fail "(timeout) info terminal at breakpoint" }
98}
99
100
101