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

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