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

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