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

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