ee354604102b8e70303218c3682eef16240d93cc
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.server / non-existing-program.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 2015-2021 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 # Test starting gdbserver passing it the name of a non-existing
19 # program.
20
21 load_lib gdbserver-support.exp
22
23 standard_testfile
24
25 if { [skip_gdbserver_tests] } {
26 return 0
27 }
28
29 set gdbserver [find_gdbserver]
30 if { $gdbserver == "" } {
31 fail "could not find gdbserver"
32 return
33 }
34
35 # Fire off gdbserver. The port doesn't really matter, gdbserver tries
36 # to spawn the program before opening the connection.
37 set spawn_id [remote_spawn target "$gdbserver stdio non-existing-program"]
38
39 set msg "gdbserver exits cleanly"
40 set saw_exiting 0
41 expect {
42 # This is what we get on ptrace-based targets with
43 # startup-with-shell disabled (e.g., when the SHELL variable is
44 # unset).
45 -re "stdin/stdout redirected.*gdbserver: Cannot exec non-existing-program\r\ngdbserver: Error: No such file or directory\r\n\r\nDuring startup program exited with code 127\.\r\nExiting\r\n$" {
46 set saw_exiting 1
47 exp_continue
48 }
49 # Likewise, but with startup-with-shell enabled, which is the
50 # default behaviour.
51 -re "stdin/stdout redirected.*exec: non-existing-program: not found\r\nDuring startup program exited with code 127\.\r\nExiting\r\n$" {
52 set saw_exiting 1
53 exp_continue
54 }
55 # This is what we get on Windows.
56 -re "Error creating process\r\n\r\nExiting\r\n$" {
57 set saw_exiting 1
58 exp_continue
59 }
60 -re "A problem internal to GDBserver has been detected" {
61 fail "$msg (GDBserver internal error)"
62 wait
63 }
64 eof {
65 gdb_assert $saw_exiting $msg
66 wait
67 }
68 timeout {
69 fail "$msg (timeout)"
70 }
71 }
72
73 # expect defaults to spawn_id in many places. Avoid confusing any
74 # following code.
75 unset spawn_id
This page took 0.032227 seconds and 3 git commands to generate.