summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts/T12031
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/rts/T12031')
-rw-r--r--testsuite/tests/rts/T12031/ExternBug.hs9
-rw-r--r--testsuite/tests/rts/T12031/Makefile8
-rw-r--r--testsuite/tests/rts/T12031/T12031.stdout1
-rw-r--r--testsuite/tests/rts/T12031/all.T4
-rw-r--r--testsuite/tests/rts/T12031/bar.c11
-rw-r--r--testsuite/tests/rts/T12031/baz.c9
-rw-r--r--testsuite/tests/rts/T12031/foo.h11
7 files changed, 53 insertions, 0 deletions
diff --git a/testsuite/tests/rts/T12031/ExternBug.hs b/testsuite/tests/rts/T12031/ExternBug.hs
new file mode 100644
index 0000000000..5c28aede00
--- /dev/null
+++ b/testsuite/tests/rts/T12031/ExternBug.hs
@@ -0,0 +1,9 @@
+-- Copyright (c) 2016, Ryan Scott
+-- ExternBug.hs
+{-# LANGUAGE ForeignFunctionInterface #-}
+module ExternBug (bar) where
+
+{-# INCLUDE foo.h #-}
+
+foreign import ccall "bar"
+ bar :: IO ()
diff --git a/testsuite/tests/rts/T12031/Makefile b/testsuite/tests/rts/T12031/Makefile
new file mode 100644
index 0000000000..0a9420692a
--- /dev/null
+++ b/testsuite/tests/rts/T12031/Makefile
@@ -0,0 +1,8 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+T12031:
+ '$(TEST_HC)' -c bar.c -o bar.o
+ '$(TEST_HC)' -c baz.c -o baz.o
+ echo bar | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) bar.o baz.o ExternBug.hs
diff --git a/testsuite/tests/rts/T12031/T12031.stdout b/testsuite/tests/rts/T12031/T12031.stdout
new file mode 100644
index 0000000000..e5cc126783
--- /dev/null
+++ b/testsuite/tests/rts/T12031/T12031.stdout
@@ -0,0 +1 @@
+The value of foo is 1
diff --git a/testsuite/tests/rts/T12031/all.T b/testsuite/tests/rts/T12031/all.T
new file mode 100644
index 0000000000..b051514109
--- /dev/null
+++ b/testsuite/tests/rts/T12031/all.T
@@ -0,0 +1,4 @@
+test('T12031', [ extra_clean(['bar.o', 'baz.o', 'ExternBug.o'])
+ , extra_files(['bar.c', 'baz.c', 'ExternBug.hs', 'foo.h'])
+ ],
+ run_command, ['$MAKE -s --no-print-directory T12031'])
diff --git a/testsuite/tests/rts/T12031/bar.c b/testsuite/tests/rts/T12031/bar.c
new file mode 100644
index 0000000000..257cc198f4
--- /dev/null
+++ b/testsuite/tests/rts/T12031/bar.c
@@ -0,0 +1,11 @@
+// Copyright (c) 2016, Ryan Scott
+// bar.c
+#include "foo.h"
+
+int foo = 0;
+
+void bar(void) {
+ foo = 1;
+
+ baz();
+}
diff --git a/testsuite/tests/rts/T12031/baz.c b/testsuite/tests/rts/T12031/baz.c
new file mode 100644
index 0000000000..d710148736
--- /dev/null
+++ b/testsuite/tests/rts/T12031/baz.c
@@ -0,0 +1,9 @@
+// Copyright (c) 2016, Ryan Scott
+// baz.c
+#include "foo.h"
+#include <stdio.h>
+
+void baz(void) {
+ printf("The value of foo is %d\n", foo); // Segfaults on this line
+ fflush(stdout);
+}
diff --git a/testsuite/tests/rts/T12031/foo.h b/testsuite/tests/rts/T12031/foo.h
new file mode 100644
index 0000000000..d3ca4aad2d
--- /dev/null
+++ b/testsuite/tests/rts/T12031/foo.h
@@ -0,0 +1,11 @@
+// Copyright (c) 2016, Ryan Scott
+// foo.h
+#ifndef FOO_H
+#define FOO_H
+
+extern int foo;
+
+void bar(void);
+void baz(void);
+
+#endif