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

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