Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb.mi/mi-basics.exp: fix racy tests (PR testsuite/12649)
@ 2011-05-06 16:22 Marek Polacek
  2011-05-11 18:41 ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Polacek @ 2011-05-06 16:22 UTC (permalink / raw)
  To: gdb-patches

Hi!

This test, when using read1(), fails completely since it doesn't pass the
`test_mi_interpreter_selection' which leads to aborting whole test file.
This one I've solved by a) replacing `gdb_test_multiple' with `mi_gdb_test' and 
b) using "~\"" at the start of the regexp.  We generally want to avoid
using gdb_test_multiply in gdb.mi/*.exp, see e.g. PR 12647.

Next fail was in `test_exec_and_symbol_mi_operatons'.  Here I've also replaced
`gdb_test_multiple' with `mi_gdb_test' even though the comment suggested that
this is not possible since we want to use return 0 when fail.  IMHO it is possible
using the if [mi_gdb_test "*" "*" "*"] { return 0 }.
Furthermore, the return value of this procedure is ignored, I think this is wrong,
there is even a comment "# FIXME: if we cannot load we have to skip all other tests."
Thus, at the end of the file, I've changed the condition to honour the return value
of this procedure. Therefore, if the `test_exec_and_symbol_mi_operatons' fails, we
bail out.  In addition, I've used simpler regexp which doesn't fail with read1().

Next, in `test_path_specification' I've only replaced `gdb_test_multiple' with
`send_gdb'+`gdb_expect'.  I cannot use `mi_gdb_test' here because with this the
`$expect_out(1,string);' didn't work (unknown variable).


Tested with both read{,1}.  Ok?  

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

        * gdb.mi/mi-basics.exp: Fix races.  Honour the
        `test_exec_and_symbol_mi_operatons' return value.
        (test_mi_interpreter_selection): Use mi_gdb_test instead of
        gdb_test_multiple.
        (test_exec_and_symbol_mi_operatons): Likewise.
        (test_path_specification):  Use send_gdb+gdb_expect instead of
        gdb_test_multiple.


Index: mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.26
diff -u -r1.26 mi-basics.exp
--- mi-basics.exp	1 Jan 2011 15:33:47 -0000	1.26
+++ mi-basics.exp	6 May 2011 16:09:34 -0000
@@ -60,18 +60,10 @@
 
     # All this test expects is to get the prompt back
     # with no syntax error message
-    gdb_test_multiple "-gdb-version" "acceptance of MI operations" {
-	-re "GNU gdb .*\r\n$mi_gdb_prompt$" {
-	    pass "acceptance of MI operations"
-	    return 1
-	}
-	-re ".*\r\n$mi_gdb_prompt$" {
-	    fail "acceptance of MI operations"
-	}
-	-re "Undefined command.*$gdb_prompt $" {
-	    fail "acceptance of MI operations"
-	}
-    }
+    if ![mi_gdb_test "-gdb-version" "~\"GNU gdb.*" "acceptance of MI operations"] {
+	return 1
+    } 
+
     note "Skipping all other MI tests."
     return 0
 }
@@ -84,19 +76,11 @@
     # Tests:
     # -file-exec-and-symbols
 
-    # Can't use mi_gdb_test as if this doesn't work,
-    #  we must give up on the whole test file
-    gdb_test_multiple "-file-exec-and-symbols ${binfile}" \
-	"-file-exec-and-symbols ${binfile}" {
-	    -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" {
-		pass "file-exec-and-symbols operation"
-	    }
-	    timeout {
-		fail "file-exec-and-symbols operation (timeout)"
-		note "Skipping all other MI tests."
-		return 0
-	    }
-	}
+    if [mi_gdb_test "-file-exec-and-symbols ${binfile}" "\\\^done" \
+       "file-exec-and-symbols operation"] {
+	note "Skipping all other MI tests."
+	return 0
+    }
 
     # The following is not used by mi-support.exp, but we test here so
     # we get done with loading a program basics.
@@ -121,7 +105,8 @@
              "\\\^done" \
              "file-symbol-file operation"
 
-    # FIXME: if we cannot load we have to skip all other tests.
+    # We need to return != 0.
+    return 1
 }
 
 proc test_breakpoints_deletion {} {
@@ -207,7 +192,8 @@
     # -environment-path -r dir
     # -environment-path -r
 
-    gdb_test_multiple "-environment-path" "-environment-path" {
+    send_gdb "-environment-path\n"
+    gdb_expect {
 	-re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" { 
 	    set orig_path $expect_out(1,string); 
 	}
@@ -276,8 +262,8 @@
 		"verify tty is correct"
 }
 
-if [test_mi_interpreter_selection] {
-  test_exec_and_symbol_mi_operatons
+if { [test_mi_interpreter_selection]
+      && [test_exec_and_symbol_mi_operatons] } {
   test_breakpoints_deletion
   test_dir_specification
   test_cwd_specification


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb.mi/mi-basics.exp: fix racy tests (PR testsuite/12649)
  2011-05-06 16:22 [PATCH] gdb.mi/mi-basics.exp: fix racy tests (PR testsuite/12649) Marek Polacek
@ 2011-05-11 18:41 ` Jan Kratochvil
  2011-05-12  7:14   ` Marek Polacek
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2011-05-11 18:41 UTC (permalink / raw)
  To: Marek Polacek; +Cc: gdb-patches

Hi Marek,

On Fri, 06 May 2011 18:21:42 +0200, Marek Polacek wrote:
> Next, in `test_path_specification' I've only replaced `gdb_test_multiple' with
> `send_gdb'+`gdb_expect'.  I cannot use `mi_gdb_test' here because with this the
> `$expect_out(1,string);' didn't work (unknown variable).

It works with:
    global expect_out

    mi_gdb_test "-environment-path" "\\\^done,path=\"(.*)\"" "environment-path"
    set orig_path $expect_out(3,string)

If not clear the index 1 and 2 is used by mi_gdb_test 2 indexes:
         -re "^($string_regex\[\r\n\]+)?($pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)" {


> 2011-05-06  Marek Polacek  <mpolacek@redhat.com>
> 
>         * gdb.mi/mi-basics.exp: Fix races.  Honour the
>         `test_exec_and_symbol_mi_operatons' return value.
>         (test_mi_interpreter_selection): Use mi_gdb_test instead of
>         gdb_test_multiple.
>         (test_exec_and_symbol_mi_operatons): Likewise.
>         (test_path_specification):  Use send_gdb+gdb_expect instead of
>         gdb_test_multiple.

OK with that change, sorry for the delay.


Thanks,
Jan


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb.mi/mi-basics.exp: fix racy tests (PR testsuite/12649)
  2011-05-11 18:41 ` Jan Kratochvil
@ 2011-05-12  7:14   ` Marek Polacek
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Polacek @ 2011-05-12  7:14 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On 05/11/2011 08:40 PM, Jan Kratochvil wrote:
> It works with:
>     global expect_out
> 
>     mi_gdb_test "-environment-path" "\\\^done,path=\"(.*)\"" "environment-path"
>     set orig_path $expect_out(3,string)

Yes, this works and looks much better.  Thanks for this!

> OK with that change, sorry for the delay.

No problem at all, checked in:
http://sourceware.org/ml/gdb-cvs/2011-05/msg00079.html

	Marek


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-12  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 16:22 [PATCH] gdb.mi/mi-basics.exp: fix racy tests (PR testsuite/12649) Marek Polacek
2011-05-11 18:41 ` Jan Kratochvil
2011-05-12  7:14   ` Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox