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

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