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

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