This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Testsuite: Fix racy conditions in py-cmd.exp


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b04480b11925aff2a1d2fbca30908801fd46c7f3

commit b04480b11925aff2a1d2fbca30908801fd46c7f3
Author: Alan Hayward <alan.hayward@arm.com>
Date:   Tue Oct 9 16:42:33 2018 +0100

    Testsuite: Fix racy conditions in py-cmd.exp
    
    The test loop in test_python_inline_or_multiline was not checking for the
    gdb prompt. readline_is_used then reads in the prompt causing it to fail
    and the final chunk of tests to be skipped.
    
    Spotted this error because sometimes the gdb prompt does get processed
    correctly and the final tests are run, causing it to show up in the
    racy tests script output.
    
    Fix by ensuring the prompt is always checked for. To do this the list
    style needs reformatting so that variables get expanded.
    
    2018-10-19  Alan Hayward  <alan.hayward@arm.com>
    
    	* gdb.python/py-cmd.exp: Check for gdb_prompt.

Diff:
---
 gdb/testsuite/ChangeLog             |  4 +++
 gdb/testsuite/gdb.python/py-cmd.exp | 71 +++++++++++++++++++------------------
 2 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index d33e7f2..a917a6d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2018-10-19  Alan Hayward  <alan.hayward@arm.com>
 
+	* gdb.python/py-cmd.exp: Check for gdb_prompt.
+
+2018-10-19  Alan Hayward  <alan.hayward@arm.com>
+
 	* gdb.base/vla-optimized-out.exp: Allow either optimized out or 6.
 
 2018-10-19  Alan Hayward  <alan.hayward@arm.com>
diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
index d2d8205..33a5b39 100644
--- a/gdb/testsuite/gdb.python/py-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-cmd.exp
@@ -188,44 +188,45 @@ gdb_test "complete expr_test bar\." \
 # the easiest way is just to test with Python.
 proc test_python_inline_or_multiline { } {
     global gdb_prompt
+    set end "\r\n$gdb_prompt $"
 
-    set define_cmd_not_inline {
-	{ "if 1"                 " >$"            "multi-line if 1" }
-	{ "python"               " >$"            "multi-line python command" }
-	{ "print ('hello')"      "  >$"           "multi-line print" }
-	{ "end"                  " >$"            "multi-line first end" }
-	{ "end"                  "hello\r\n"      "multi-line last end" } }
+    set define_cmd_not_inline [ list \
+	[ list "if 1"                 " >$"            "multi-line if 1" ] \
+	[ list "python"               " >$"            "multi-line python command" ] \
+	[ list "print ('hello')"      "  >$"           "multi-line print" ] \
+	[ list "end"                  " >$"            "multi-line first end" ] \
+	[ list "end"                  "hello$end"      "multi-line last end" ] ]
 
     # This also tests trailing whitespace on the command.
-    set define_cmd_alias_not_inline {
-	{ "if 1"                 " >$"            "multi-line if 1 alias" }
-	{ "py    "               " >$"            "multi-line python command alias" }
-	{ "print ('hello')"      "  >$"           "multi-line print alias" }
-	{ "end"                  " >$"            "multi-line first end alias" }
-	{ "end"                  "hello\r\n"      "multi-line last end alias" } }
-
-    set define_cmd_alias_foo_not_inline {
-	{ "alias foo=python"     "\r\n"           "multi-line alias foo" }
-	{ "if 1"                 " >$"            "multi-line if 1 alias foo" }
-	{ "foo    "              " >$"            "multi-line python command alias foo" }
-	{ "print ('hello')"      "  >$"           "multi-line print alias foo" }
-	{ "end"                  " >$"            "multi-line first end alias foo" }
-	{ "end"                  "hello\r\n"      "multi-line last end alias foo" } }
-
-    set define_cmd_inline {
-	{ "if 1"                      " >$"          "inline if 1" }
-	{ "python print ('hello')"    " >$"          "inline python command" }
-	{ "end"                       "hello\r\n"    "inline end" } }
-
-    set define_cmd_alias_inline {
-	{ "if 1"                      " >$"          "inline if 1 alias" }
-	{ "py print ('hello')"        " >$"          "inline python command alias" }
-	{ "end"                       "hello\r\n"    "inline end alias" } }
-
-    set define_cmd_alias_foo_inline {
-	{ "if 1"                      " >$"          "inline if 1 alias foo" }
-	{ "foo print ('hello')"       " >$"          "inline python command alias foo" }
-	{ "end"                       "hello\r\n"    "inline end alias foo" } }
+    set define_cmd_alias_not_inline [ list \
+	[ list "if 1"                 " >$"            "multi-line if 1 alias" ] \
+	[ list "py    "               " >$"            "multi-line python command alias" ] \
+	[ list "print ('hello')"      "  >$"           "multi-line print alias" ] \
+	[ list "end"                  " >$"            "multi-line first end alias" ] \
+	[ list "end"                  "hello$end"      "multi-line last end alias" ] ]
+
+    set define_cmd_alias_foo_not_inline [ list \
+	[ list "alias foo=python"     "$end"           "multi-line alias foo" ] \
+	[ list "if 1"                 " >$"            "multi-line if 1 alias foo" ] \
+	[ list "foo    "              " >$"            "multi-line python command alias foo" ] \
+	[ list "print ('hello')"      "  >$"           "multi-line print alias foo" ] \
+	[ list "end"                  " >$"            "multi-line first end alias foo" ] \
+	[ list "end"                  "hello$end"      "multi-line last end alias foo" ] ]
+
+    set define_cmd_inline [ list \
+	[ list "if 1"                      " >$"          "inline if 1" ] \
+	[ list "python print ('hello')"    " >$"          "inline python command" ] \
+	[ list "end"                       "hello$end"    "inline end" ] ]
+
+    set define_cmd_alias_inline [ list \
+	[ list "if 1"                      " >$"          "inline if 1 alias" ] \
+	[ list "py print ('hello')"        " >$"          "inline python command alias" ] \
+	[ list "end"                       "hello$end"    "inline end alias" ] ]
+
+    set define_cmd_alias_foo_inline [ list \
+	[ list "if 1"                      " >$"          "inline if 1 alias foo" ] \
+	[ list "foo print ('hello')"       " >$"          "inline python command alias foo" ] \
+	[ list "end"                       "hello$end"    "inline end alias foo" ] ]
 
     foreach t [list $define_cmd_not_inline \
 	       $define_cmd_alias_not_inline \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]