aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.server/fileio-packets.exp
blob: 9435efdc1906a727aea0b421b349ef6901578ce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright 2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Test some remote file I/O.  The associated Python script uses the
# Python API to create and send vFile:* packets to gdbserver to
# perform actions like 'stat'.  The same action is then performed
# directly from Python (e.g. a 'stat' is performed), and the results,
# from gdbserver, and from the local syscall, are compared.

load_lib gdb-python.exp
load_lib gdbserver-support.exp

require allow_python_tests
require allow_gdbserver_tests
require {!is_remote host}
require {!is_remote target}

standard_testfile

clean_restart

# Make sure we're disconnected, in case we're testing with an
# extended-remote board, therefore already connected.
gdb_test "disconnect" ".*"

set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
gdb_test_no_output "source $pyfile" "source the script"

# Start gdbserver, but always in extended-remote mode, and then
# connect to it from GDB.
set res [gdbserver_start "--multi --once" ""]
set gdbserver_protocol "extended-remote"
set gdbserver_gdbport [lindex $res 1]
gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport

gdb_test_no_output "set python print-stack full"

set test_file_1 [standard_output_file "test_file_1"]
remote_exec host "touch $test_file_1"

set test_file_2 [standard_output_file "test_file_2"]
remote_exec host "ln -s $test_file_1 $test_file_2"

gdb_test "python check_lstat(\"$test_file_1\")" "PASS" \
    "check remote lstat works on a normal file"

gdb_test "python check_lstat(\"$test_file_2\")" "PASS" \
    "check remote lstat works on a symbolic link"

gdb_test "python check_stat(\"$test_file_1\")" "PASS" \
    "check remote stat works on a normal file"

gdb_test "python check_stat(\"$test_file_2\")" "PASS" \
    "check remote stat works on a symbolic link"