Blame SOURCES/gdb-6.5-bz243845-stale-testing-zombie-test.patch

b2f73e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
b2f73e
From: Fedora GDB patches <invalid@email.com>
b2f73e
Date: Fri, 27 Oct 2017 21:07:50 +0200
b2f73e
Subject: gdb-6.5-bz243845-stale-testing-zombie-test.patch
b2f73e
b2f73e
;; Test leftover zombie process (BZ 243845).
b2f73e
;;=fedoratest
b2f73e
b2f73e
diff --git a/gdb/testsuite/gdb.base/tracefork-zombie.exp b/gdb/testsuite/gdb.base/tracefork-zombie.exp
b2f73e
new file mode 100644
b2f73e
--- /dev/null
b2f73e
+++ b/gdb/testsuite/gdb.base/tracefork-zombie.exp
b2f73e
@@ -0,0 +1,75 @@
b2f73e
+# Copyright 2007 Free Software Foundation, Inc.
b2f73e
+
b2f73e
+# This program is free software; you can redistribute it and/or modify
b2f73e
+# it under the terms of the GNU General Public License as published by
b2f73e
+# the Free Software Foundation; either version 2 of the License, or
b2f73e
+# (at your option) any later version.
b2f73e
+# 
b2f73e
+# This program is distributed in the hope that it will be useful,
b2f73e
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b2f73e
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b2f73e
+# GNU General Public License for more details.
b2f73e
+# 
b2f73e
+# You should have received a copy of the GNU General Public License
b2f73e
+# along with this program; if not, write to the Free Software
b2f73e
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
b2f73e
+
b2f73e
+# are we on a target board
b2f73e
+if [is_remote target] then {
b2f73e
+    return 0
b2f73e
+}
b2f73e
+
b2f73e
+# Start the program running and then wait for a bit, to be sure
b2f73e
+# that it can be attached to.
b2f73e
+
b2f73e
+gdb_exit
b2f73e
+gdb_start
b2f73e
+gdb_load sleep
b2f73e
+
b2f73e
+set gdb_pid [exp_pid -i [board_info host fileid]]
b2f73e
+set test "identified the child GDB"
b2f73e
+if {$gdb_pid != "" && $gdb_pid > 0} {
b2f73e
+    pass $test
b2f73e
+    verbose -log "Child GDB PID $gdb_pid"
b2f73e
+} else {
b2f73e
+    fail $test
b2f73e
+}
b2f73e
+
b2f73e
+set testpid [eval exec sleep 10 &]
b2f73e
+exec sleep 2
b2f73e
+
b2f73e
+set test "attach"
b2f73e
+gdb_test_multiple "attach $testpid" "$test" {
b2f73e
+    -re "Attaching to program.*`?.*'?, process $testpid..*$gdb_prompt $" {
b2f73e
+	pass "$test"
b2f73e
+    }
b2f73e
+    -re "Attaching to program.*`?.*\.exe'?, process $testpid.*\[Switching to thread $testpid\..*\].*$gdb_prompt $" {
b2f73e
+	# Response expected on Cygwin
b2f73e
+	pass "$test"
b2f73e
+    }
b2f73e
+}
b2f73e
+
b2f73e
+# Some time to let GDB spawn its testing child.
b2f73e
+exec sleep 2
b2f73e
+
b2f73e
+set found none
b2f73e
+foreach procpid [glob -directory /proc -type d {[0-9]*}] {
b2f73e
+    if {[catch {open $procpid/status} statusfi]} {
b2f73e
+	continue
b2f73e
+    }
b2f73e
+    set status [read $statusfi]
b2f73e
+    close $statusfi
b2f73e
+    if {1
b2f73e
+         && [regexp -line {^Name:\tgdb$} $status]
b2f73e
+         && [regexp -line {^PPid:\t1$} $status]
b2f73e
+         && [regexp -line "^TracerPid:\t$gdb_pid$" $status]} {
b2f73e
+	set found $procpid
b2f73e
+	verbose -log "Found linux_test_for_tracefork zombie PID $procpid"
b2f73e
+    }
b2f73e
+}
b2f73e
+set test "linux_test_for_tracefork leaves no zombie"
b2f73e
+if {$found eq {none}} {
b2f73e
+    pass $test
b2f73e
+} else {
b2f73e
+    fail $test
b2f73e
+}