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

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