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

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