[PATCH 4/4] [PR gdbserver/25893]: Add gdbserver test for argument with space in it
Michael Weghorn
m.weghorn@posteo.de
Wed Apr 29 11:16:38 GMT 2020
This adds a test to call gdbserver with a program
that is passed an argument containing a space and
checks that argv[1] actually contains the value
of this arg.
gdb/testsuite/ChangeLog:
2020-04-29 Michael Weghorn <m.weghorn@posteo.de>
PR gdbserver/25893
* gdb.server/arg-with-space.exp: New test that
covers running program with arg containing
a space with gdbserver
---
gdb/testsuite/gdb.server/arg-with-space.exp | 41 +++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 gdb/testsuite/gdb.server/arg-with-space.exp
diff --git a/gdb/testsuite/gdb.server/arg-with-space.exp b/gdb/testsuite/gdb.server/arg-with-space.exp
new file mode 100644
index 0000000000..d768b7ca0f
--- /dev/null
+++ b/gdb/testsuite/gdb.server/arg-with-space.exp
@@ -0,0 +1,41 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2020 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 gdbserver to properly handle a program arg with a space in it
+# as a single argument.
+
+load_lib gdbserver-support.exp
+
+standard_testfile "normal.c"
+
+if {[skip_gdbserver_tests]} {
+ return 0
+}
+
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ return -1
+}
+clean_restart ${testfile}
+
+gdbserver_run "\"hello world\""
+
+gdb_breakpoint main
+gdb_continue main
+
+# check that program arg was passed properly
+gdb_test "print argc" "2"
+gdb_test "print argv\[1\]" "\"hello world\""
--
2.26.2
More information about the Gdb-patches
mailing list