summaryrefslogtreecommitdiff
path: root/test-suite/standalone
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-04-28 15:53:35 +0200
committerAndy Wingo <wingo@pobox.com>2011-04-28 15:53:35 +0200
commit1903eae4c9ab97b575dad4ab1f5cf05436d84ab3 (patch)
treedbb5a83c4dce6f6f10642b3d39ec76ee63dd77a5 /test-suite/standalone
parent0c81a0c13ad39c381e4ff4d073e3158bcfd51a7a (diff)
parent91956a94fe6363cf69d574b56397962ec6ef4468 (diff)
downloadguile-1903eae4c9ab97b575dad4ab1f5cf05436d84ab3.tar.gz
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts: GUILE-VERSION
Diffstat (limited to 'test-suite/standalone')
-rw-r--r--test-suite/standalone/Makefile.am15
-rw-r--r--test-suite/standalone/test-asmobs-lib.c2
-rw-r--r--test-suite/standalone/test-extensions-lib.c2
-rw-r--r--test-suite/standalone/test-ffi-lib.c2
-rw-r--r--test-suite/standalone/test-list.c2
-rw-r--r--test-suite/standalone/test-num2integral.c2
-rw-r--r--test-suite/standalone/test-pthread-create-secondary.c85
-rw-r--r--test-suite/standalone/test-pthread-create.c69
-rw-r--r--test-suite/standalone/test-scm-spawn-thread.c62
-rw-r--r--test-suite/standalone/test-with-guile-module.c2
10 files changed, 237 insertions, 6 deletions
diff --git a/test-suite/standalone/Makefile.am b/test-suite/standalone/Makefile.am
index b21edd20d..cf1fc4fe3 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -198,6 +198,21 @@ test_scm_with_guile_LDADD = $(LIBGUILE_LDADD)
check_PROGRAMS += test-scm-with-guile
TESTS += test-scm-with-guile
+test_scm_spawn_thread_CFLAGS = ${test_cflags}
+test_scm_spawn_thread_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-scm-spawn-thread
+TESTS += test-scm-spawn-thread
+
+test_pthread_create_CFLAGS = ${test_cflags}
+test_pthread_create_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-pthread-create
+TESTS += test-pthread-create
+
+test_pthread_create_secondary_CFLAGS = ${test_cflags} $(BDW_GC_CFLAGS)
+test_pthread_create_secondary_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-pthread-create-secondary
+TESTS += test-pthread-create-secondary
+
else
EXTRA_DIST += test-with-guile-module.c test-scm-with-guile.c
diff --git a/test-suite/standalone/test-asmobs-lib.c b/test-suite/standalone/test-asmobs-lib.c
index c88556ab2..03ac76447 100644
--- a/test-suite/standalone/test-asmobs-lib.c
+++ b/test-suite/standalone/test-asmobs-lib.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/test-suite/standalone/test-extensions-lib.c b/test-suite/standalone/test-extensions-lib.c
index 7c8678895..cc03a9eba 100644
--- a/test-suite/standalone/test-extensions-lib.c
+++ b/test-suite/standalone/test-extensions-lib.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/test-suite/standalone/test-ffi-lib.c b/test-suite/standalone/test-ffi-lib.c
index 364e6a684..a89b6aa94 100644
--- a/test-suite/standalone/test-ffi-lib.c
+++ b/test-suite/standalone/test-ffi-lib.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/test-suite/standalone/test-list.c b/test-suite/standalone/test-list.c
index 2efaf5c88..b51a2a18e 100644
--- a/test-suite/standalone/test-list.c
+++ b/test-suite/standalone/test-list.c
@@ -18,7 +18,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/test-suite/standalone/test-num2integral.c b/test-suite/standalone/test-num2integral.c
index af995ecd8..6a44fb75a 100644
--- a/test-suite/standalone/test-num2integral.c
+++ b/test-suite/standalone/test-num2integral.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/test-suite/standalone/test-pthread-create-secondary.c b/test-suite/standalone/test-pthread-create-secondary.c
new file mode 100644
index 000000000..fe39c2a26
--- /dev/null
+++ b/test-suite/standalone/test-pthread-create-secondary.c
@@ -0,0 +1,85 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* Test whether threads created with `pthread_create' work, and whether
+ a secondary thread can call `scm_with_guile'. (bug #32436). */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <libguile.h>
+
+#include <gc/gc_version.h>
+
+
+/* Up to GC 7.2alpha5, calling `GC_INIT' from a secondary thread would
+ lead to a segfault. This was fixed in BDW-GC on 2011-04-16 by Ivan
+ Maidanski. See <http://thread.gmane.org/gmane.lisp.guile.bugs/5340>
+ for details. */
+
+#if (GC_VERSION_MAJOR > 7) \
+ || ((GC_VERSION_MAJOR == 7) && (GC_VERSION_MINOR > 2)) \
+ || ((GC_VERSION_MAJOR == 7) && (GC_VERSION_MINOR == 2) \
+ && (GC_ALPHA_VERSION > 5))
+
+static void *
+do_something (void *arg)
+{
+ scm_list_copy (scm_make_list (scm_from_int (1234), SCM_BOOL_T));
+ scm_gc ();
+ return NULL;
+}
+
+static void *
+thread (void *arg)
+{
+ scm_with_guile (do_something, NULL);
+ return NULL;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int i;
+
+ for (i = 0; i < 77; i++)
+ {
+ pthread_t thr;
+
+ pthread_create (&thr, NULL, thread, NULL);
+ pthread_join (thr, NULL);
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
+#else /* GC < 7.2 */
+
+int
+main (int argc, char *argv[])
+{
+ /* Skip. */
+ return 77;
+}
+
+#endif /* GC < 7.2 */
diff --git a/test-suite/standalone/test-pthread-create.c b/test-suite/standalone/test-pthread-create.c
new file mode 100644
index 000000000..cf3771f07
--- /dev/null
+++ b/test-suite/standalone/test-pthread-create.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* Test whether threads created with `pthread_create' work (bug #32436)
+ when then main thread is the one that initializes Guile. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <libguile.h>
+
+static void *
+do_something (void *arg)
+{
+ scm_list_copy (scm_make_list (scm_from_int (1234), SCM_BOOL_T));
+ scm_gc ();
+ return NULL;
+}
+
+static void *
+thread (void *arg)
+{
+ scm_with_guile (do_something, NULL);
+ return NULL;
+}
+
+static void *
+inner_main (void *data)
+{
+ int i;
+ pthread_t thr;
+
+ do_something (NULL);
+
+ for (i = 0; i < 77; i++)
+ {
+ pthread_create (&thr, NULL, thread, NULL);
+ pthread_join (thr, NULL);
+ }
+
+ return NULL;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ scm_with_guile (inner_main, NULL);
+
+ return EXIT_SUCCESS;
+}
diff --git a/test-suite/standalone/test-scm-spawn-thread.c b/test-suite/standalone/test-scm-spawn-thread.c
new file mode 100644
index 000000000..b632ab0fe
--- /dev/null
+++ b/test-suite/standalone/test-scm-spawn-thread.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* Test whether a thread created with `scm_spawn_thread' can be joined.
+ See <http://thread.gmane.org/gmane.lisp.guile.devel/11804> for the
+ original report. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libguile.h>
+
+#include <time.h>
+#include <stdlib.h>
+
+static SCM
+thread_main (void *data)
+{
+ return SCM_BOOL_T;
+}
+
+static SCM
+thread_handler (void *data, SCM key, SCM args)
+{
+ return SCM_BOOL_T;
+}
+
+static void *
+inner_main (void *data)
+{
+ SCM thread, timeout;
+
+ thread = scm_spawn_thread (thread_main, 0, thread_handler, 0);
+ timeout = scm_from_unsigned_integer (time (NULL) + 10);
+ return (void *) scm_join_thread_timed (thread, timeout, SCM_BOOL_F);
+}
+
+
+int
+main (int argc, char **argv)
+{
+ SCM result;
+
+ result = PTR2SCM (scm_with_guile (inner_main, 0));
+ return scm_is_true (result) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/test-suite/standalone/test-with-guile-module.c b/test-suite/standalone/test-with-guile-module.c
index 154f4f23f..4e22ff5da 100644
--- a/test-suite/standalone/test-with-guile-module.c
+++ b/test-suite/standalone/test-with-guile-module.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif