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

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