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

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