]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/interrupt.exp
* gdb.base/a1-selftest.exp (test_with_self), gdb.base/interrupt.exp:
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / interrupt.exp
1 if $tracelevel then {
2 strace $tracelevel
3 }
4
5 set prms_id 0
6 set bug_id 0
7
8 set binfile $objdir/$subdir/interrupt
9
10 if ![file exists $binfile] then {
11 perror "$binfile does not exist."
12 return 0
13 } else {
14 gdb_reinitialize_dir $srcdir/$subdir
15 gdb_load $binfile
16 gdb_test "shell stty intr ^C" "" \
17 "set interrupt character in interrupt.exp"
18 if [runto main] then {
19 send "continue\n"
20 expect {
21 -re "\r\ntalk to me baby\r\n$" {}
22 timeout { fail "run (timeout)" }
23 eof { fail "run (eof)" }
24 }
25 # This should appear twice, once for the echo and once for the
26 # program's output. Under dejagnu (but not interactively) for
27 # SunOS4, it only appears once. Don't worry about it, I imagine
28 # dejagnu has just done something to the tty modes.
29 send "a\n"
30 expect {
31 -re "^a\r\n(|a\r\n)$" {}
32 timeout { fail "echo a (timeout)" }
33 eof { fail "echo a (eof)" }
34 }
35 # Wait until the program is in the read system call again.
36 exec sleep 2
37
38 send "\003"
39 expect {
40 -re "Program received signal SIGINT.*$prompt $" {
41 pass "send control C"
42 }
43 -re ".*$prompt $" { fail "send control C" }
44 timeout { fail "send control C (timeout)" }
45 eof { fail "send control C (eof)" }
46 }
47
48 send "p func1 ()\n"
49 expect {
50 -re " = 4.*$prompt $" { pass "call function when asleep" }
51 -re "$prompt $" { fail "call function when asleep (wrong output)" }
52 timeout {
53
54 # This fail probably happens whenever we use /proc (we
55 # don't use PRSABORT), but apparently also happens on
56 # other machines as well.
57
58 setup_xfail "sparc-*-solaris2*"
59 setup_xfail "mips-*-ultrix*"
60 setup_xfail "hppa*-*-*"
61 setup_xfail "i386*-*-bsd*"
62 setup_xfail "*-*-sysv4*"
63 setup_xfail "vax-*-*"
64 setup_xfail "alpha-*-*"
65 setup_xfail "*-*-irix*"
66 fail "call function when asleep (stays asleep)"
67 # Send a newline to wake it up
68 send "\n"
69 gdb_test "" " = 4" "call function after waking it"
70 }
71 eof { fail "call function when asleep (eof)" }
72 }
73
74 # Now try calling the function again.
75 gdb_test "p func1 ()" " = 4" "call function a second time"
76
77 # And the program should still be doing the same thing.
78 # The optional trailing \r\n is in case we sent a newline above
79 # to wake the program, in which case the program now sends it
80 # back. We check for it either here or in the next expect
81 # command, because which one it ends up in is timing dependent.
82 send "continue\n"
83 # For some reason, i386-*-sysv4 gdb fails to issue the Continuing
84 # message, but otherwise appears normal (FIXME).
85 expect {
86 -re "^continue\r\nContinuing.\r\n(\r\n|)$" { pass "continue" }
87 -re "^continue\r\n\r\n" { fail "continue (missing Continuing.)" }
88 -re "$prompt $" { fail "continue" }
89 timeout { fail "continue" }
90 eof { fail "continue" }
91 }
92
93 send "data\n"
94 # The optional leading \r\n is in case we sent a newline above
95 # to wake the program, in which case the program now sends it
96 # back.
97 expect {
98 -re "^(\r\n|)data\r\n(|data\r\n)$" { pass "echo data" }
99 timeout { fail "echo data (timeout)" }
100 eof { fail "echo data (eof)" }
101 }
102
103 send "\004"
104 expect {
105 -re "end of file.*Program exited normally.*$prompt $" {
106 pass "send end of file"
107 }
108 -re "$prompt $" { fail "send end of file" }
109 timeout { fail "send end of file (timeout)" }
110 eof { fail "send end of file (eof)" }
111 }
112 }
113 }
114 return 0