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

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