Blame SOURCES/gdb-6.3-bz202689-exec-from-pthread-test.patch

b2f73e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
b2f73e
From: Jan Kratochvil <jan.kratochvil@redhat.com>
b2f73e
Date: Fri, 27 Oct 2017 21:07:50 +0200
b2f73e
Subject: gdb-6.3-bz202689-exec-from-pthread-test.patch
b2f73e
b2f73e
;; Testcase for exec() from threaded program (BZ 202689).
b2f73e
;;=fedoratest
b2f73e
b2f73e
2007-01-17  Jan Kratochvil <jan.kratochvil@redhat.com>
b2f73e
b2f73e
	* gdb.threads/threaded-exec.exp, gdb.threads/threaded-exec.c: New files.
b2f73e
b2f73e
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.c b/gdb/testsuite/gdb.threads/threaded-exec.c
b2f73e
new file mode 100644
b2f73e
--- /dev/null
b2f73e
+++ b/gdb/testsuite/gdb.threads/threaded-exec.c
b2f73e
@@ -0,0 +1,46 @@
b2f73e
+/* This testcase is part of GDB, the GNU debugger.
b2f73e
+
b2f73e
+   Copyright 2007 Free Software Foundation, Inc.
b2f73e
+
b2f73e
+   This program is free software; you can redistribute it and/or modify
b2f73e
+   it under the terms of the GNU General Public License as published by
b2f73e
+   the Free Software Foundation; either version 2 of the License, or
b2f73e
+   (at your option) any later version.
b2f73e
+
b2f73e
+   This program is distributed in the hope that it will be useful,
b2f73e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
b2f73e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b2f73e
+   GNU General Public License for more details.
b2f73e
+
b2f73e
+   You should have received a copy of the GNU General Public License
b2f73e
+   along with this program; if not, write to the Free Software
b2f73e
+   Foundation, Inc., 59 Temple Place - Suite 330,
b2f73e
+   Boston, MA 02111-1307, USA.  */
b2f73e
+
b2f73e
+#include <stddef.h>
b2f73e
+#include <pthread.h>
b2f73e
+#include <assert.h>
b2f73e
+#include <stdlib.h>
b2f73e
+#include <unistd.h>
b2f73e
+
b2f73e
+
b2f73e
+static void *
b2f73e
+threader (void *arg)
b2f73e
+{
b2f73e
+	return NULL;
b2f73e
+}
b2f73e
+
b2f73e
+int
b2f73e
+main (void)
b2f73e
+{
b2f73e
+	pthread_t t1;
b2f73e
+	int i;
b2f73e
+
b2f73e
+	i = pthread_create (&t1, NULL, threader, (void *) NULL);
b2f73e
+	assert (i == 0);
b2f73e
+	i = pthread_join (t1, NULL);
b2f73e
+	assert (i == 0);
b2f73e
+
b2f73e
+	execl ("/bin/true", "/bin/true", NULL);
b2f73e
+	abort ();
b2f73e
+}
b2f73e
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.exp b/gdb/testsuite/gdb.threads/threaded-exec.exp
b2f73e
new file mode 100644
b2f73e
--- /dev/null
b2f73e
+++ b/gdb/testsuite/gdb.threads/threaded-exec.exp
b2f73e
@@ -0,0 +1,41 @@
b2f73e
+# threaded-exec.exp -- Check reset of the tracked threads on exec*(2)
b2f73e
+# Copyright (C) 2007 Free Software Foundation, Inc.
b2f73e
+
b2f73e
+# This program is free software; you can redistribute it and/or modify
b2f73e
+# it under the terms of the GNU General Public License as published by
b2f73e
+# the Free Software Foundation; either version 2 of the License, or
b2f73e
+# (at your option) any later version.
b2f73e
+# 
b2f73e
+# This program is distributed in the hope that it will be useful,
b2f73e
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b2f73e
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b2f73e
+# GNU General Public License for more details.
b2f73e
+# 
b2f73e
+# You should have received a copy of the GNU General Public License
b2f73e
+# along with this program; if not, write to the Free Software
b2f73e
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
b2f73e
+
b2f73e
+# Please email any bugs, comments, and/or additions to this file to:
b2f73e
+# bug-gdb@prep.ai.mit.edu
b2f73e
+
b2f73e
+set testfile threaded-exec
b2f73e
+set srcfile ${testfile}.c
b2f73e
+set binfile [standard_output_file ${testfile}]
b2f73e
+
b2f73e
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
b2f73e
+    return -1
b2f73e
+}
b2f73e
+
b2f73e
+gdb_exit
b2f73e
+gdb_start
b2f73e
+gdb_reinitialize_dir $srcdir/$subdir
b2f73e
+
b2f73e
+gdb_load ${binfile}
b2f73e
+
b2f73e
+gdb_run_cmd
b2f73e
+
b2f73e
+gdb_test_multiple {} "Program exited" {
b2f73e
+   -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {
b2f73e
+       pass "Program exited"
b2f73e
+   }
b2f73e
+}