From: Sandra Loosemore <sandra@codesourcery.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [patch] gdb/testsuite: Fix POSIX-isms in gdb.base/shell.exp
Date: Wed, 24 Jun 2020 19:35:43 -0600 [thread overview]
Message-ID: <6bc2b01e-3807-77b9-7d1e-d7f6a7875e49@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 741 bytes --]
This patch fixes a group of failures in gdb.base/shell.exp on Windows
host due to assumptions that GDB is launching a POSIX-like shell. On
Windows, we get CMD.EXE instead.
There is a potential second group of failures on Windows host not
addressed by this patch, due to the dependence of some of these tests on
utilities like wc, sed, and grep. These tests happen to work for me
because the test harness connects to the remote host using Cygwin ssh
and both GDB and CMD.EXE inherit the PATH setting from the parent Cygwin
shell. I don't know if disabling those tests on Windows host too is
appropriate, or again if this is an instance of badly-designed tests
that could be rewritten to avoid those dependencies. WDYT?
-Sandra
[-- Attachment #2: windows-shell.patch --]
[-- Type: text/x-patch, Size: 4194 bytes --]
commit 6d3377fd7e040e1c6001af12f8d8b2dfa8b7b0c6
Author: Sandra Loosemore <sandra@codesourcery.com>
Date: Wed Jun 24 17:32:16 2020 -0700
Fix POSIX-isms in gdb.base/shell.exp
Some recent tests added to gdb.base/shell.exp have been failing on
Windows host due to assumptions that the shell is a POSIX variant. On
Windows, GDB uses CMD.EXE via the system() call to run shell commands
instead.
There seems to be no obvious CMD.EXE equivalent for "kill -2 $$" to
signal the shell process, so this patch skips those tests on Windows
host. The second problem addressed here is that CMD.EXE only
recognizes double quotes, not single quotes; that change can be made
unconditionally since POSIX shells recognize double quotes as well.
2020-06-24 Sandra Loosemore <sandra@codesourcery.com>
* gdb.base/shell.exp: Skip pipe tests dependent on sh on Windows host.
Use double quotes instead of single quotes.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 1b77459..aebfe8d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-06-24 Sandra Loosemore <sandra@codesourcery.com>
+
+ * gdb.base/shell.exp: Skip pipe tests dependent on sh on Windows host.
+ Use double quotes instead of single quotes.
+
2020-06-24 Pedro Alves <palves@redhat.com>
* gdb.arch/amd64-entry-value-paramref.exp: Use
diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp
index f656077..ad36f6b 100644
--- a/gdb/testsuite/gdb.base/shell.exp
+++ b/gdb/testsuite/gdb.base/shell.exp
@@ -34,9 +34,12 @@ gdb_test_no_output "! exit 1"
gdb_test "p \$_shell_exitcode" " = 1" "shell fail exitcode"
gdb_test "p \$_shell_exitsignal" " = void" "shell fail exitsignal"
-gdb_test_no_output "! kill -2 $$"
-gdb_test "p \$_shell_exitcode" " = void" "shell interrupt exitcode"
-gdb_test "p \$_shell_exitsignal" " = 2" "shell interrupt exitsignal"
+# This test will not work when the shell is CMD.EXE.
+if { ! [ishost *-*-mingw*] } {
+ gdb_test_no_output "! kill -2 $$"
+ gdb_test "p \$_shell_exitcode" " = void" "shell interrupt exitcode"
+ gdb_test "p \$_shell_exitsignal" " = 2" "shell interrupt exitsignal"
+}
# Define the user command "foo", used to test "pipe" command.
gdb_test_multiple "define foo" "define foo" {
@@ -67,16 +70,16 @@ gdb_test "|foo|grep truc|wc -l" "1" "no space around pipe char"
gdb_test "echo coucou\\n" "coucou" "echo coucou"
gdb_test "||wc -l" "1" "repeat previous command"
-gdb_test "| -d ! echo this contains a | character\\n ! sed -e 's/|/PIPE/'" \
+gdb_test "| -d ! echo this contains a | character\\n ! sed -e \"s/|/PIPE/\"" \
"this contains a PIPE character" "alternate 1char delim"
-gdb_test "|-d ! echo this contains a | character\\n!sed -e 's/|/PIPE/'" \
+gdb_test "|-d ! echo this contains a | character\\n!sed -e \"s/|/PIPE/\"" \
"this contains a PIPE character" "alternate 1char delim, no space"
-gdb_test "| -d !!! echo this contains a | character\\n !!! sed -e 's/|/PIPE/'" \
+gdb_test "| -d !!! echo this contains a | character\\n !!! sed -e \"s/|/PIPE/\"" \
"this contains a PIPE character" "alternate 3char delim"
-gdb_test "|-d !!! echo this contains a | character\\n!!!sed -e 's/|/PIPE/'" \
+gdb_test "|-d !!! echo this contains a | character\\n!!!sed -e \"s/|/PIPE/\"" \
"this contains a PIPE character" "alternate 3char delim, no space"
# Convenience variables with pipe command.
@@ -88,9 +91,12 @@ gdb_test "|p 123| exit 1" ""
gdb_test "p \$_shell_exitcode" " = 1" "pipe fail exitcode"
gdb_test "p \$_shell_exitsignal" " = void" "pipe fail exitsignal"
-gdb_test "|p 123| kill -2 $$" ""
-gdb_test "p \$_shell_exitcode" " = void" "pipe interrupt exitcode"
-gdb_test "p \$_shell_exitsignal" " = 2" "pipe interrupt exitsignal"
+# This test will not work when the shell is CMD.EXE.
+if { ! [ishost *-*-mingw*] } {
+ gdb_test "|p 123| kill -2 $$" ""
+ gdb_test "p \$_shell_exitcode" " = void" "pipe interrupt exitcode"
+ gdb_test "p \$_shell_exitsignal" " = 2" "pipe interrupt exitsignal"
+}
# Error handling verifications.
gdb_test "|" "Missing COMMAND" "all missing"
next reply other threads:[~2020-06-25 1:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 1:35 Sandra Loosemore [this message]
2020-06-25 17:32 ` Christian Biesinger
2020-06-25 17:57 ` Sandra Loosemore
2020-06-25 18:07 ` Eli Zaretskii
2020-06-25 19:35 ` Sandra Loosemore
2020-06-26 7:08 ` Eli Zaretskii
2020-06-26 22:22 ` Sandra Loosemore
2020-06-25 22:36 ` Christian Biesinger
2020-07-15 19:53 ` [ping] " Sandra Loosemore
2020-07-16 2:41 ` Simon Marchi
2020-07-16 16:44 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6bc2b01e-3807-77b9-7d1e-d7f6a7875e49@codesourcery.com \
--to=sandra@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox