[v2,6/6] Add defaultinf.exp test to the testsuite
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
Commit Message
Test the behaviour of the inferior when GDBserver is run locally
and using stdio. The inferior should be able to write to STOUT
and STDERR and read from STDIN.
---
gdb/testsuite/gdb.server/defaultinf.c | 39 ++++++++++++++++
gdb/testsuite/gdb.server/defaultinf.exp | 59 +++++++++++++++++++++++++
2 files changed, 98 insertions(+)
create mode 100644 gdb/testsuite/gdb.server/defaultinf.c
create mode 100644 gdb/testsuite/gdb.server/defaultinf.exp
new file mode 100644
@@ -0,0 +1,39 @@
+/* Copyright 2023 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/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+ printf ("Hello stdout!\n");
+ fprintf (stderr, "Hello stderr!\n");
+
+ char *line = NULL;
+ size_t len = 0;
+ ssize_t nread;
+
+ while ((nread = getline (&line, &len, stdin)) != -1)
+ {
+ if (line[nread - 1] == '\n')
+ line[nread - 1] = '\0';
+ printf ("Got line len %zd: '%s'\n", nread, line);
+ }
+
+ printf ("Got EOF\n");
+ free (line);
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,59 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2023 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 the behaviour of the inferior when GDBserver is run locally
+# and using stdio. The inferior should be able to write to STOUT
+# and STDERR and read from STDIN.
+
+require {!is_remote target} {!is_remote host}
+
+load_lib gdbserver-support.exp
+
+require allow_gdbserver_tests
+
+set gdbserver [find_gdbserver]
+if { $gdbserver == "" } {
+ unsupported "could not find GDBserver"
+ return
+}
+
+standard_testfile
+
+if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+gdb_test "target remote | ${::gdbserver} - [standard_output_file $testfile]" ".*" \
+ "start gdbserver using pipe syntax"
+
+ set input_msg "hello world"
+ set input_len [expr [string length ${input_msg}] + 1]
+ gdb_test_multiple "c" "Test STDOUT/ERR, STDIN" {
+ -re "Hello stdout!\r\nHello stderr!" {
+ send_gdb "${input_msg}\n"
+ exp_continue
+ }
+ -re "${input_msg}\r\nGot line len ${input_len}: '${input_msg}'" {
+ send_gdb "\004"
+ exp_continue
+ }
+ -re "Got EOF" {
+ pass "$gdb_test_name"
+ }
+ }