summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite/tests/dynlibs/T19350/Makefile26
-rw-r--r--testsuite/tests/dynlibs/T19350/T19350.script3
-rw-r--r--testsuite/tests/dynlibs/T19350/T19350.stdout20
-rw-r--r--testsuite/tests/dynlibs/T19350/all.T16
-rw-r--r--testsuite/tests/dynlibs/T19350/clib/lib.c6
-rw-r--r--testsuite/tests/dynlibs/T19350/lib/Hello.hs3
-rw-r--r--testsuite/tests/dynlibs/T19350/lib/Setup.hs2
-rw-r--r--testsuite/tests/dynlibs/T19350/lib/T19350-lib.cabal11
8 files changed, 87 insertions, 0 deletions
diff --git a/testsuite/tests/dynlibs/T19350/Makefile b/testsuite/tests/dynlibs/T19350/Makefile
new file mode 100644
index 0000000000..6eac01756e
--- /dev/null
+++ b/testsuite/tests/dynlibs/T19350/Makefile
@@ -0,0 +1,26 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+LOCAL_PKGCONF=local.package.conf
+
+T19350:
+ echo "Building libhello..."
+ '$(TEST_HC)' -fPIC -c clib/lib.c -o clib/lib.o
+ '$(TEST_HC)' -shared -no-hs-main clib/lib.o -o clib/libhello$(dllext)
+
+ rm -Rf $(LOCAL_PKGCONF)
+ "$(GHC_PKG)" init $(LOCAL_PKGCONF)
+
+ echo "Building T19350-lib..."
+ cd lib && '$(TEST_HC)' -package Cabal Setup.hs
+ x="$$(pwd)//clib" && cd lib && ./Setup configure -v0 --extra-lib-dirs="$$x" --extra-lib-dirs="$$x-install" --with-compiler="$(TEST_HC)" --with-hc-pkg="$(GHC_PKG)" --package-db=../$(LOCAL_PKGCONF) --disable-library-vanilla --enable-shared
+ cd lib && ./Setup build
+ cd lib && ./Setup register --inplace
+
+ # Move libhello from its original place to ensure it isn't found via RPATH
+ mkdir -p clib-install
+ mv clib/libhello$(dllext) clib-install
+
+ echo "Testing..."
+ '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -package-db '$(LOCAL_PKGCONF)' -package T19350-lib -interactive < T19350.script
diff --git a/testsuite/tests/dynlibs/T19350/T19350.script b/testsuite/tests/dynlibs/T19350/T19350.script
new file mode 100644
index 0000000000..d5b619f7bf
--- /dev/null
+++ b/testsuite/tests/dynlibs/T19350/T19350.script
@@ -0,0 +1,3 @@
+import Hello
+hello
+:q
diff --git a/testsuite/tests/dynlibs/T19350/T19350.stdout b/testsuite/tests/dynlibs/T19350/T19350.stdout
new file mode 100644
index 0000000000..71166bedd8
--- /dev/null
+++ b/testsuite/tests/dynlibs/T19350/T19350.stdout
@@ -0,0 +1,20 @@
+echo "Building libhello..."
+Building libhello...
+'/opt/exp/ghc/ghc-landing/_build/stage1/bin/ghc' -fPIC -c clib/lib.c -o clib/lib.o
+'/opt/exp/ghc/ghc-landing/_build/stage1/bin/ghc' -shared -no-hs-main clib/lib.o -o clib/libhello.so
+rm -Rf local.package.conf
+"/opt/exp/ghc/ghc-landing/_build/stage1/bin/ghc-pkg" init local.package.conf
+echo "Building T19350-lib..."
+Building T19350-lib...
+cd lib && '/opt/exp/ghc/ghc-landing/_build/stage1/bin/ghc' -package Cabal Setup.hs
+cd lib && ./Setup configure -v0 --extra-lib-dirs="$(pwd)/../clib" --with-compiler="/opt/exp/ghc/ghc-landing/_build/stage1/bin/ghc" --with-hc-pkg="/opt/exp/ghc/ghc-landing/_build/stage1/bin/ghc-pkg" --package-db=../local.package.conf --disable-library-vanilla --enable-shared
+cd lib && ./Setup build
+Preprocessing library for T19350-lib-1.0..
+Building library for T19350-lib-1.0..
+[1 of 1] Compiling Hello ( Hello.hs, dist/build/Hello.dyn_o )
+cd lib && ./Setup register --inplace
+Registering library for T19350-lib-1.0..
+echo "Testing..."
+Testing...
+'/opt/exp/ghc/ghc-landing/_build/stage1/bin/ghc' -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output --interactive -v0 -ignore-dot-ghci -fno-ghci-history -package-db 'local.package.conf' -package T19350-lib -interactive < T19350.script
+hello world!
diff --git a/testsuite/tests/dynlibs/T19350/all.T b/testsuite/tests/dynlibs/T19350/all.T
new file mode 100644
index 0000000000..c8915bde1f
--- /dev/null
+++ b/testsuite/tests/dynlibs/T19350/all.T
@@ -0,0 +1,16 @@
+# Test for #19350
+# ================
+#
+# The plan
+# ---------
+# We build a C shared library (`libhello`, contained in ./clib) and then build
+# a Haskell library (`T19350-lib`, in ./lib) which depends upon it via `foreign
+# import`. We make sure that the libhello shared object can only be found via
+# the extra-lib-dirs from the package database registration (which we do by
+# moving libhello.so from its original place).
+#
+# Finally, we enter GHCi, load the Haskell library, and try to use it to call
+# into libhello.
+#
+
+test('T19350', [req_shared_libs, expect_broken(19350), extra_files(['clib', 'lib'])], makefile_test, [])
diff --git a/testsuite/tests/dynlibs/T19350/clib/lib.c b/testsuite/tests/dynlibs/T19350/clib/lib.c
new file mode 100644
index 0000000000..556c1dcb74
--- /dev/null
+++ b/testsuite/tests/dynlibs/T19350/clib/lib.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void hello_world(void) {
+ printf("hello world!");
+}
+
diff --git a/testsuite/tests/dynlibs/T19350/lib/Hello.hs b/testsuite/tests/dynlibs/T19350/lib/Hello.hs
new file mode 100644
index 0000000000..0dd0de66f7
--- /dev/null
+++ b/testsuite/tests/dynlibs/T19350/lib/Hello.hs
@@ -0,0 +1,3 @@
+module Hello (hello) where
+
+foreign import ccall "hello_world" hello :: IO ()
diff --git a/testsuite/tests/dynlibs/T19350/lib/Setup.hs b/testsuite/tests/dynlibs/T19350/lib/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/dynlibs/T19350/lib/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/dynlibs/T19350/lib/T19350-lib.cabal b/testsuite/tests/dynlibs/T19350/lib/T19350-lib.cabal
new file mode 100644
index 0000000000..85c99820de
--- /dev/null
+++ b/testsuite/tests/dynlibs/T19350/lib/T19350-lib.cabal
@@ -0,0 +1,11 @@
+cabal-version: >=1.10
+name: T19350-lib
+version: 1.0
+build-type: Simple
+
+library
+ build-depends: base
+ exposed-modules: Hello
+ default-language: Haskell2010
+ extra-libraries: hello
+