Skip attach-many-short-lived-threads.exp on known-broken DejaGnu versions
authorPedro Alves <palves@redhat.com>
Fri, 27 May 2016 15:18:28 +0000 (16:18 +0100)
committerPedro Alves <palves@redhat.com>
Fri, 27 May 2016 15:18:28 +0000 (16:18 +0100)
If the testsuite is run with a DejaGnu version that predates the fix
from last year:

  [PATCH] DejaGnu kills the wrong process due to PID-reuse races
  http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00005.html

... gdb.threads/attach-many-short-lived-threads.exp fails randomly,
often.  Other tests randomly fail due to that issue too, but this one
is _much_ more exposed.

DejaGnu 1.6 was released meanwhile, which includes that DejaGnu fix,
and also some distros backported the fix too.

So skip the test when run with older/broken DejaGnus.

gdb/testsuite/ChangeLog:
2016-05-27  Pedro Alves  <palves@redhat.com>

* gdb.threads/attach-many-short-lived-threads.exp (bad_dejagnu):
New procedure.
(top level): Call it, and bail out of DejaGnu is known to be bad.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp

index cac628d..4819203 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-27  Pedro Alves  <palves@redhat.com>
+
+       * gdb.threads/attach-many-short-lived-threads.exp (bad_dejagnu):
+       New procedure.
+       (top level): Call it, and bail out of DejaGnu is known to be bad.
+
 2016-05-27  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gdb.base/whatis.c: Extend the test case.
index ccb5e9b..3bac28d 100644 (file)
 # end up leaving stale state behind that confuse the following
 # attach).
 
+# Return true if the running version of DejaGnu is known to not be
+# able to run this test.
+proc bad_dejagnu {} {
+    global frame_version
+
+    verbose -log "DejaGnu version: $frame_version"
+    verbose -log "Expect version: [exp_version]"
+    verbose -log "Tcl version: [info tclversion]"
+
+    set dj_ver [split $frame_version .]
+    set dj_ver_major [lindex $dj_ver 0]
+    set dj_ver_minor [lindex $dj_ver 1]
+
+    # DejaGnu versions prior to 1.6 manage to kill the wrong process
+    # due to PID-reuse races.  Since this test spawns many threads, it
+    # widens the race window a whole lot, enough that the inferior is
+    # often killed, and thus the test randomly fails.  See:
+    # http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00005.html
+    # The fix added a close_wait_program procedure.  If that procedure
+    # is defined, and DejaGnu is older than 1.6, assume that means the
+    # fix was backported.
+    if {$dj_ver_major == 1
+       && ($dj_ver_minor < 6 && [info procs close_wait_program] == "")} {
+       return 1
+    }
+
+    return 0
+}
+
+if {[bad_dejagnu]} {
+    unsupported "broken DejaGnu"
+    return 0
+}
+
 if {![can_spawn_for_attach]} {
     return 0
 }