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

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