Patchwork [testsuite] : Fix timeout in simulate-thread.exp

login
register
mail settings
Submitter Uros Bizjak
Date Nov. 17, 2011, 9:54 a.m.
Message ID <CAFULd4azy_saDKCeFWT72w7jPwJXtEc5Rjuvt0ksAXpGBUgJbg@mail.gmail.com>
Download mbox | patch
Permalink /patch/126169/
State New
Headers show

Comments

Uros Bizjak - Nov. 17, 2011, 9:54 a.m.
Hello!

The problem was, that dejagnu didn't kill gdb in case of timeout (i.e.
broken LL/SC sequences for alpha). The cause for this was in the way
remote_expect was called. The script found "simulate_thread_main" to
assume that gdb works OK, but unfortunately, this overrode the
"timeout" default case... so, the timeout never triggered.

The solution for this problem is to search for "simulate_thread_done"
in gdb log. If there is something wrong with gdb or atomics, we won't
reach to this breakpoint, so either atomics were wrong, or gdb fails.
In each case, this is FAIL.

The patch also sets timeout to 10 seconds, due to huge amount of
produced log and improves fail messages a bit.

2011-10-17  Uros Bizjak  <ubizjak@gmail.com>

	* lib/gcc-simulate-thread.exp (simulate-thread): Run on all targets.
	Look for simulate_thread_done to determine working gdb.  Reduce timeout
	to 10 seconds and fail when timeout occurs.  Improve error messages.

Patch was tested on alphaev68-pc-linux-gnu, where correctly finds
problematic tests with old gdb:

Running /home/uros/gcc-svn/trunk/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.exp
...
FAIL: gcc.dg/simulate-thread/atomic-other-int.c  -O0 -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-int.c  -O1 -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-int.c  -O2 -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-int.c  -O3 -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-int.c  -Os -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-short.c  -O0 -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-short.c  -O1 -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-short.c  -O2 -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-short.c  -O3 -g  (thread
simulation test)
FAIL: gcc.dg/simulate-thread/atomic-other-short.c  -Os -g  (thread
simulation test)

With fixed gdb, all tests pass OK.

OK for mainline?

Uros.
Alan Modra - Nov. 17, 2011, 10:49 a.m.
On Thu, Nov 17, 2011 at 10:54:23AM +0100, Uros Bizjak wrote:
> The solution for this problem is to search for "simulate_thread_done"
> in gdb log.

Thanks!  I like this for another reason too:  I've seen these tests
fail due to gdb never reporting simulate_thread_main on any
instruction in that function.
IainS - Nov. 17, 2011, 1:22 p.m.
On 17 Nov 2011, at 10:49, Alan Modra wrote:

> On Thu, Nov 17, 2011 at 10:54:23AM +0100, Uros Bizjak wrote:
>> The solution for this problem is to search for "simulate_thread_done"
>> in gdb log.
>
> Thanks!  I like this for another reason too:  I've seen these tests
> fail due to gdb never reporting simulate_thread_main on any
> instruction in that function.

... works for me on powerpc-darwin9 ...

with a local experimental 7.3.1 port to powerpc-darwin9, some more  
tests pass, but not all ...
... what base version/patch is needed to get all the tests to pass for  
you?

thanks
Iain
Mike Stump - Nov. 17, 2011, 7:33 p.m.
On Nov 17, 2011, at 1:54 AM, Uros Bizjak wrote:
> The problem was, that dejagnu didn't kill gdb in case of timeout (i.e.
> broken LL/SC sequences for alpha).

> The patch also sets timeout to 10 seconds, due to huge amount of
> produced log and improves fail messages a bit.

10 might be a bit low...   (slow targets, simulators, complex remote target setup)   but we can go with that for now until someone has a need for a larger value.

> OK for mainline?

Ok.
Andrew MacLeod - Nov. 17, 2011, 8:08 p.m.
On 11/17/2011 02:33 PM, Mike Stump wrote:
> The patch also sets timeout to 10 seconds, due to huge amount of
>> produced log and improves fail messages a bit.
> 10 might be a bit low...   (slow targets, simulators, complex remote target setup)   but we can go with that for now until someone has a need for a larger value.

I expect the log size could be dramatically reduced.  I think Aldy had 
it set to really verbose so there is a bunch of stuff spit out at each 
instruction.  Much of that probably isn't needed for a normal day to day 
run.   At least I would guess it isn't.   All I was ever looking for was 
whether the run was successful or not.    One could go run it later to 
create the log if there was a failure...  the rest of the time we dont care.

if the log was a lot smaller, increasing the timeout time wouldn't be as 
big a deal.

Andrew

Patch

Index: gcc-simulate-thread.exp
===================================================================
--- gcc-simulate-thread.exp	(revision 181436)
+++ gcc-simulate-thread.exp	(working copy)
@@ -22,15 +22,6 @@ 
 # Call 'fail' if a given test printed "FAIL:", otherwise call 'pass'.
 
 proc simulate-thread { args } {
-
-    # ??? Exit immediately if this is alpha*-*-linux* target, single-stepping
-    # executable between ldl_l and stl_c insns in gdb breaks LL/SC chaining.
-    if { [istarget alpha*-*-linux*] } { return }
-    
-    # GNU gdb 6.3 on powerpc-darwin also  on these (and expect does not appear
-    # to be able to terminate them).
-    if { [istarget powerpc*-*-darwin*] } { return }
-
     if { ![isnative] || [is_remote target] } { return }
 
     if { [llength $args] == 1 } {
@@ -54,35 +45,39 @@ 
 	return
     }
 
+    set message "(thread simulation test)"
+
     send_log "Spawning: $gdb_name -nx -nw -quiet -x $cmd_file ./$exec_file\n"
     set res [remote_spawn target "$gdb_name -nx -nw  -x $cmd_file ./$exec_file"]
     if { $res < 0 || $res == "" } {
-	unsupported "$testcase"
+	unsupported "$testcase $message"
 	return
     }
 
     set gdb_worked 0
-    remote_expect target [timeout_value] {
+
+    # Set timeout to 10 seconds due to huge amount of generated log.
+    remote_expect target 10 {
 	# Too old GDB
 	-re "Unhandled dwarf expression|Error in sourced command file" {
-	    unsupported "$testcase"
+	    unsupported "$testcase $message"
 	    remote_close target
 	    return
 	}
 	-re "FAIL:" {
-	    fail "$testcase"
+	    fail "$testcase $message"
 	    remote_close target
 	    return
 	}
-	# If the gdb output contained simulate_thread_main, assume
+	# If the gdb output contained simulate_thread_done, assume
 	# that at the very least, we had a working gdb that was able
-	# to break in simulate_thread_main.
-	-re "simulate_thread_main" {
+	# to break in simulate_thread_done.
+	-re "simulate_thread_done" {
 	    set gdb_worked 1
 	    exp_continue
 	}
 	timeout {
-	    unsupported "$testcase"
+	    fail "$testcase $message"
 	    remote_close target
 	    return
 	}
@@ -90,10 +85,10 @@ 
 
     remote_close target
     if {$gdb_worked} {
-	pass "$testcase"
+	pass "$testcase $message"
     } else {
-	# Fail in the absence of a sane GDB.
-	fail "$testcase"
+	# Unsupported in the absence of a sane GDB.
+	unsupported "$testcase $message"
     }
     return
 }