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

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