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

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