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

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