]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.python/py-send-packet.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-send-packet.exp
1 # Copyright (C) 2021-2024 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 # Test the gdb.RemoteTargetConnection.send_packet API. This is done
17 # by connecting to a remote target and fetching the thread list in two
18 # ways, first, we manually send the packets required to read the
19 # thread list using gdb.TargetConnection.send_packet, then we compare
20 # the results to the thread list using the standard API calls.
21
22 load_lib gdb-python.exp
23 load_lib gdbserver-support.exp
24
25 standard_testfile
26
27 require allow_gdbserver_tests allow_python_tests
28
29 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
30 return -1
31 }
32
33 # Make sure we're disconnected, in case we're testing with an
34 # extended-remote board, therefore already connected.
35 gdb_test "disconnect" ".*"
36
37 gdbserver_run ""
38
39 gdb_breakpoint "breakpt"
40 gdb_continue_to_breakpoint "breakpt"
41
42 # Source the python script.
43 set remote_python_file [gdb_remote_download host \
44 ${srcdir}/${subdir}/${testfile}.py]
45 gdb_test "source $remote_python_file" "Sourcing complete\\." \
46 "source ${testfile}.py script"
47
48 # The test is actually written in the Python script. Run it now.
49 gdb_test "python run_send_packet_test()" "Send packet test passed"
50
51 # Check the string representation of a remote target connection.
52 gdb_test "python print(gdb.selected_inferior().connection)" \
53 "<gdb.RemoteTargetConnection num=$decimal, what=\".*\">"
54
55 # Check to see if there's any auxv data for this target.
56 gdb_test_multiple "info auxv" "" {
57 -re -wrap "The program has no auxiliary information now\\. " {
58 set skip_auxv_test true
59 }
60 -re -wrap "0\\s+AT_NULL\\s+End of vector\\s+0x0" {
61 set skip_auxv_test false
62 }
63 }
64
65 if { ! $skip_auxv_test } {
66 # Use 'maint packet' to fetch the auxv data.
67 set reply_data ""
68 gdb_test_multiple "maint packet qXfer:auxv:read::0,1000" "" {
69 -re "sending: \"qXfer:auxv:read::0,1000\"\r\n" {
70 exp_continue
71 }
72 -re -wrap "received: \"(.*)\"" {
73 set reply_data $expect_out(1,string)
74 }
75 }
76
77 # Escape any backslash characters in the output, so we can safely
78 # pass a string through to Python.
79 set reply_data [string map {\\ \\\\} $reply_data]
80 gdb_assert { ![string equal "$reply_data" ""] }
81
82 # Run the test, fetches the auxv data in Python and confirm it
83 # matches the expected results.
84 gdb_test "python run_auxv_send_packet_test(\"$reply_data\")" \
85 "auxv send packet test passed" \
86 "call python run_auxv_send_packet_test function"
87 }
88
89 set sizeof_global_var [get_valueof "/d" "sizeof(global_var)" "UNKNOWN"]
90 if { $sizeof_global_var == 4 } {
91 gdb_test_no_output "set debug remote 1"
92 gdb_test "python run_set_global_var_test()" \
93 "set global_var test passed"
94 }