[gdb/testsuite] Factor out lib/valgrind.exp
[external/binutils.git] / gdb / testsuite / gdb.base / quit.exp
1 # Copyright (C) 2016-2018 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 3 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, see <http://www.gnu.org/licenses/>.
15
16 # Check the "quit" command.
17
18 clean_restart
19
20 # Test that a syntax error causes quit to abort.
21 # Regression test for PR gdb/20604.
22 gdb_test "quit()" "A syntax error in expression, near .*" \
23     "quit with syntax error"
24
25 # Test that an expression can be used to set the error code.
26
27 set test "quit with expression"
28 gdb_test_multiple "quit 22+1" $test {
29     eof {
30         set result [wait -i $gdb_spawn_id]
31         verbose $result
32         gdb_assert {[lindex $result 2] == 0 && [lindex $result 3] == 23} $test
33
34         remote_close host
35         clear_gdb_spawn_id
36     }
37 }