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

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