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

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