This is the mail archive of the gdb-patches@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]

Re: [RFC] Fixing gdb.base/completion.exp (PR testsuite/12649)


On 05/01/2011 11:16 AM, Jan Kratochvil wrote:
> 10 is too low for parallel runs where machine can be in 20+ load.  I do not
> see this test needs to excercise $timeout, I would even remove this whole
> override.
 
I removed this.

> The problem with this proposed intermediate step is that it in fact brings a
> testsuite regression.  Original "sleep 1" was there to ensure all the output
> has been caught.  This was racy but in most cases it worked.
> 
> Now it will false PASS with regressing GDB where the current FSF GDB HEAD
> testcase would correctly FAIL.  If GDB outputs "show output-radix " first and
> after 0.5sec it yet outputs "foobar" the original testcase correctly FAILed
> while the current testcase will falsely PASS.
 
I see your point.  However, even with sleep 1, if GDB outputs "foobar"
after 1.1 sec, the test still incorrectly PASSes.  This is a no-win 
situation.

> The "complete" command appraoch does introduce this new kind of race.
 
Yeah :(.  Basically, we would like to have some kind of signal, that the
`complete' is all done and thus we can test the result, IIUC.

> But the patch can be commited in two parts if it is preferred although
> reviewing these racy send_gdb-gdb_expect cases for the intermediate step is
> tricky and it gets dropped immediately afterwards.

I propose to apply the attached patch.  It is basically Pedro's patch, but
I've removed the timeout-fiddling as well as this unnecessary change:

>> -	-re "^p \"break1\\..*$"
>> +	-re "^p \"break1\\...*$"

I ran this test with read{,1}().  Is this, at least for now, OK?

2011-05-02  Marek Polacek  <mpolacek@redhat.com>

        * gdb.base/completion.exp: Fix racy tests.  Remove `sleep's.  
        Also do not change the timeout.
        ($oldtimeout1): Remove variable.


Index: completion.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/completion.exp,v
retrieving revision 1.50
diff -u -r1.50 completion.exp
--- completion.exp	23 Feb 2011 19:20:39 -0000	1.50
+++ completion.exp	2 May 2011 13:49:54 -0000
@@ -91,12 +91,7 @@
         perror "tests suppressed"
 }
 
-set oldtimeout1 $timeout
-set timeout 30
-
-
 send_gdb "hfgfh\t"
-sleep 1
 gdb_expect  {
         -re "^hfgfh\\\x07$"\
             { send_gdb "\n"
@@ -114,7 +109,6 @@
 #exp_internal 0
 
 send_gdb "show output\t"
-sleep 1
 gdb_expect  {
         -re "^show output-radix $"\
             { send_gdb "\n"
@@ -125,16 +119,6 @@
                       timeout           {fail "(timeout) complete 'show output'"}
                      }
             }
-        -re "^show output$"\
-            { send_gdb "\n"
-               gdb_expect {
-                      -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
-                                        { fail "complete 'show output'"}
-                      -re ".*$gdb_prompt $" { fail "complete 'show output'"}
-                      timeout           { fail "(timeout) complete 'show output'"}
-                     }
-
-             }
 
         -re ".*$gdb_prompt $"       { fail "complete 'show output'" }
         timeout         { fail "(timeout) complete 'show output'" }
@@ -142,7 +126,6 @@
 
 
 send_gdb "show output-\t"
-sleep 1
 gdb_expect  {
         -re "^show output-radix $"\
             { send_gdb "\n"
@@ -153,27 +136,15 @@
                       timeout           {fail "(timeout) complete 'show output-'"}
                      }
             }
-        -re "^show output-$"\
-            { send_gdb "\n"
-               gdb_expect {
-                      -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
-                                        { fail "complete 'show output-'"}
-                      -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
-                      timeout           { fail "(timeout) complete 'show output-'"}
-                     }
-
-             }
 
         -re ".*$gdb_prompt $"       { fail "complete 'show output-'" }
         timeout         { fail "(timeout) complete 'show output-'" }
         }
 
 send_gdb "p\t"
-sleep 1
 gdb_expect  {
         -re "^p\\\x07$"\
             { send_gdb "\n"
-	      sleep 1
               gdb_expect {
                       -re "The history is empty\\..*$gdb_prompt $"\
                                         { pass "complete 'p'"}
@@ -186,11 +157,9 @@
         }
 
 send_gdb "p \t"
-sleep 3
 gdb_expect  {
         -re "^p \\\x07$"\
             { send_gdb "\n"
-	      sleep 1
               gdb_expect {
                       -re "The history is empty\\..*$gdb_prompt $"\
                                         { pass "complete 'p '"}
@@ -204,7 +173,6 @@
 
 
 send_gdb "info t foo\t"
-sleep 1
 gdb_expect  {
         -re "^info t foo\\\x07$"\
             { send_gdb "\n"
@@ -220,7 +188,6 @@
         }
 
 send_gdb "info t\t"
-sleep 1
 gdb_expect  {
         -re "^info t\\\x07$"\
             { send_gdb "\n"
@@ -238,7 +205,6 @@
 
 
 send_gdb "info t \t"
-sleep 1
 gdb_expect  {
         -re "^info t \\\x07$"\
             { send_gdb "\n"
@@ -256,7 +222,6 @@
 
 
 send_gdb "info asdfgh\t"
-sleep 1
 gdb_expect  {
         -re "^info asdfgh\\\x07$"\
             { send_gdb "\n"
@@ -274,7 +239,6 @@
 
 
 send_gdb "info asdfgh \t"
-sleep 1
 gdb_expect  {
         -re "^info asdfgh \\\x07$"\
             { send_gdb "\n"
@@ -291,7 +255,6 @@
         }
 
 send_gdb "info\t"
-sleep 1
 gdb_expect  {
         -re "^info $"\
             { send_gdb "\n"
@@ -307,7 +270,6 @@
         }
 
 send_gdb "info \t"
-sleep 1
 gdb_expect  {
         -re "^info \\\x07$"\
             { send_gdb "\n"
@@ -322,14 +284,12 @@
         timeout         { fail "(timeout) complete 'info '" }
         }
 
-
 send_gdb "info \t"
-sleep 1
 gdb_expect  {
         -re "^info \\\x07$"\
             { send_gdb "\t"
               gdb_expect {
-                      -re "address.*types.*$gdb_prompt info $"\
+                      -re "address.*types.*$gdb_prompt "\
                           { send_gdb "\n"
                             gdb_expect {
                                      -re "\"info\".*unambiguous\\..*$gdb_prompt $"\
@@ -365,7 +325,6 @@
 
 
 send_gdb "p \"break1\t"
-sleep 1
 gdb_expect  {
         -re "^p \"break1\\\x07$"\
             { send_gdb "\n"
@@ -381,20 +340,12 @@
 		    timeout           {fail "(timeout) complete 'p \"break1'"}
 		}
 	    }
-	-re "^p \"break1.*$"
-	    {	send_gdb "\n"
-		gdb_expect {
-		    -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"}
-		    timeout           {fail "(timeout) complete 'p \"break1'"}
-		}
-	    }
         -re ".*$gdb_prompt $"       { fail "complete 'p \"break1'" }
         timeout         { fail "(timeout) complete 'p \"break1'" }
         }
 
 setup_xfail "*-*-*"
 send_gdb "p \"break1.\t"
-sleep 1
 gdb_expect  {
         -re "^p \"break1\\.\\\x07$"\
             { send_gdb "\n"
@@ -422,7 +373,6 @@
         }
 
 send_gdb "p 'arg\t"
-sleep 1
 gdb_expect  {
         -re "^p 'arg\\\x07$"\
             { send_gdb "\n"
@@ -438,12 +388,11 @@
         }
 
 send_gdb "p 'arg\t"
-sleep 1
 gdb_expect {
     -re "^p 'arg\\\x07$" {
 	send_gdb "\t"
 	gdb_expect {
-	    -re ".*argv.*$gdb_prompt p 'arg$" {
+	    -re ".*argv.*$gdb_prompt " {
 		send_gdb "\n"
 		gdb_expect {
 		    -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
@@ -503,7 +452,6 @@
 # So, I'm hoping that there is no system with a static library variable named
 # `no_var_by_this_name'.
 send_gdb "p no_var_named_this-arg\t"
-sleep 1
 gdb_expect {
     -re "^p no_var_named_this-arg\\\x07$" {
         send_gdb "\n"
@@ -528,12 +476,11 @@
 }
 
 send_gdb "p no_var_named_this-arg\t"
-sleep 1
 gdb_expect {
     -re "^p no_var_named_this-arg\\\x07$" {
 	send_gdb "\t"
 	gdb_expect {
-	    -re ".*argv.*$gdb_prompt p no_var_named_this-arg$" {
+	    -re ".*argv.*$gdb_prompt " {
 		send_gdb "\n"
 		gdb_expect {
 		    -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
@@ -548,28 +495,26 @@
 		}
 	    }
 	    -re "(There are $decimal possibilities\\.  Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
-		send_gdb "n"
+		send_gdb "n\n"
+
+		# Eat the prompt
 		gdb_expect {
-		    -re "\\(gdb\\) p no_var_named_this-arg$" {
-			send_gdb "\n"
-			gdb_expect {
-			    -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
-				pass "complete (2) 'p no_var_named_this-arg'"
-			    }
-			    -re ".*$gdb_prompt $" {
-				fail "complete (2) 'p no_var_named_this-arg'"
-			    }
-			    timeout {
-                                fail "(timeout) complete (2) 'p no_var_named_this-arg'"
-                            }
-			}
+		    -re "$gdb_prompt " {
+			pass "complete (2) 'p no_var_named_this-arg' (eat prompt)"
+		    }
+		    timeout { fail "(timeout) complete (2) 'p no_var_named_this-' (eat prompt)" }
+		}
+
+		gdb_expect {
+		    -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
+			pass "complete (2) 'p no_var_named_this-arg'"
 		    }
 		    -re ".*$gdb_prompt $" {
-                        fail "complete (2) 'p no_var_named_this-arg'"
-                    }
+			fail "complete (2) 'p no_var_named_this-arg'"
+		    }
 		    timeout {
-                        fail "(timeout) complete (2) 'p no_var_named_this-arg'"
-                    }
+			fail "(timeout) complete (2) 'p no_var_named_this-arg'"
+		    }
 		}
 	    }
 	    -re ".*$gdb_prompt $" {
@@ -583,37 +528,35 @@
 }
 
 send_gdb "p no_var_named_this-\t"
-sleep 1
 gdb_expect  {
     -re "^p no_var_named_this-\\\x07$" {
 	send_gdb "\t"
+
 	gdb_expect {
 	    -re "(There are $decimal possibilities\\.  Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
-		send_gdb "n"
+		send_gdb "n\n"
+
+		# Eat the prompt
 		gdb_expect {
-		    -re "\\(gdb\\) p no_var_named_this-$" {
-			send_gdb "\n"
-			gdb_expect {
-			    -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
-				pass "complete (2) 'p no_var_named_this-'"
-			    }
-			    -re ".*$gdb_prompt $" {
-				fail "complete (2) 'p no_var_named_this-'"
-			    }
-			    timeout {
-                                fail "(timeout) complete (2) 'p no_var_named_this-'"
-                            }
-			}
+		    -re "$gdb_prompt " {
+			pass "complete (2) 'p no_var_named_this-' (eat prompt)"
+		    }
+		    timeout { fail "(timeout) complete (2) 'p no_var_named_this-' (eat prompt)" }
+		}
+
+		gdb_expect {
+		    -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
+			pass "complete (2) 'p no_var_named_this-'"
 		    }
 		    -re ".*$gdb_prompt $" {
-                        fail "complete (2) 'p no_var_named_this-'"
-                    }
+			fail "complete (2) 'p no_var_named_this-'"
+		    }
 		    timeout {
-                        fail "(timeout) complete (2) 'p no_var_named_this-'"
-                    }
+			fail "(timeout) complete (2) 'p no_var_named_this-'"
+		    }
 		}
 	    }
-	    -re ".*argv.*$gdb_prompt p no_var_named_this-$" {
+	    -re ".*argv.*$gdb_prompt $" {
 		send_gdb "\n"
 		gdb_expect {
 		    -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
@@ -638,11 +581,9 @@
 }
 
 send_gdb "p values\[0\].a\t"
-sleep 3
 gdb_expect  {
         -re "^p values.0..a_field $"\
             { send_gdb "\n"
-	      sleep 1
               gdb_expect {
                       -re "^.* = 0.*$gdb_prompt $"\
                                         { pass "complete 'p values\[0\].a'"}
@@ -761,7 +702,6 @@
 
 
 send_gdb "complete file ./gdb.base/compl\n"
-sleep 1
 gdb_expect  {
     -re "file ./gdb.base/completion\\.exp.*$gdb_prompt $"
 	{ pass "complete-command 'file ./gdb.base/compl'"}
@@ -770,7 +710,6 @@
 }
 
 send_gdb "file ./gdb.base/complet\t"
-sleep 1
 gdb_expect  {
         -re "^file ./gdb.base/completion\\.exp $"\
             { send_gdb "\n"
@@ -788,14 +727,12 @@
         }
 
 send_gdb "info func marke\t"
-sleep 1
 gdb_expect  {
         -re "^info func marke.*r$"\
             {
 	      send_gdb "\t\t"
-              sleep 3
               gdb_expect {
-                      -re "marker1.*$gdb_prompt info func marker$"\
+                      -re "marker1.*$gdb_prompt "\
                       { send_gdb "\n"
                         gdb_expect {
                                 -re "All functions matching regular expression \"marker\":.*File.*break1.c:\r\nint marker1\\((void|)\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long( int)?\\);.*$gdb_prompt $"\
@@ -814,9 +751,8 @@
 
 
 send_gdb "set follow-fork-mode \t\t"
-sleep 1
 gdb_expect  {
-        -re "child.*parent.*$gdb_prompt set follow-fork-mode $"\
+        -re "child.*parent.*$gdb_prompt "\
             { send_gdb "\n"
               gdb_expect {
                       -re "Requires an argument.*child.*parent.*$gdb_prompt $"\
@@ -839,8 +775,4 @@
 # If there is only a deprecated completion, then it should be returned.
 gdb_test "complete save-t" "save-tracepoints" "test deprecated completion"
 
-
-# Restore globals modified in this test...
-set timeout $oldtimeout1
-
 return 0


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