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

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