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

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