Repository : ssh://darcs.haskell.org//srv/darcs/testsuite On branch : master
http://hackage.haskell.org/trac/ghc/changeset/8ad82a0087b01cf4a6f0a7d7cac35f5749e1cdb0 >--------------------------------------------------------------- commit 8ad82a0087b01cf4a6f0a7d7cac35f5749e1cdb0 Author: Simon Marlow <[email protected]> Date: Tue Aug 2 14:10:54 2011 +0100 add a test for #5289, and various other GHCi linking scenarios >--------------------------------------------------------------- tests/ghci/linking/Makefile | 118 ++++++++++++++++++++ tests/ghci/linking/TestLink.hs | 8 ++ tests/ghci/linking/all.T | 37 ++++++ tests/ghci/linking/f.c | 4 + tests/ghci/linking/ghcilink001.stdout | 1 + .../ghcilink002.stderr-i386-unknown-mingw32 | 1 + tests/ghci/linking/ghcilink002.stdout | 1 + .../linking/ghcilink003.stdout} | 0 tests/ghci/linking/ghcilink004.stdout | 1 + .../ghcilink005.stderr-i386-unknown-mingw32 | 1 + tests/ghci/linking/ghcilink005.stdout | 1 + 11 files changed, 173 insertions(+), 0 deletions(-) diff --git a/tests/ghci/linking/Makefile b/tests/ghci/linking/Makefile new file mode 100644 index 0000000..31ac289 --- /dev/null +++ b/tests/ghci/linking/Makefile @@ -0,0 +1,118 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +LOCAL_GHC_PKG = '$(GHC_PKG)' --no-user-package-conf -f $(LOCAL_PKGCONF) + +# Test 1: ghci -Ldir -lfoo +# with dir/libfoo.a + +.PHONY: ghcilink001 +ghcilink001 : + $(RM) -rf dir001 + mkdir dir001 + "$(TEST_HC)" -c f.c -o dir001/foo.o + ar cqs dir001/libfoo.a dir001/foo.o + echo "test" | "$(TEST_HC)" --interactive -v0 -Ldir001 -lfoo TestLink.hs + +# Test 2: ghci -Ldir -lfoo +# with dir/libfoo.so + +ifeq "$(WINDOWS)" "YES" +DLL = $1.dll +else +DLL = lib$1.so +endif + +.PHONY: ghcilink002 +ghcilink002 : + $(RM) -rf dir002 + mkdir dir002 + "$(TEST_HC)" -c -dynamic f.c -o dir002/foo.o + "$(TEST_HC)" -shared -v0 -o dir002/$(call DLL,foo) dir002/foo.o + echo "test" | "$(TEST_HC)" --interactive -v0 -Ldir002 -lfoo TestLink.hs + +# Test 3: ghci -lstdc++ +# where libstdc++.so is normally found in a directory private to gcc, +# so only gcc can find it (see #5289) + +.PHONY: ghcilink003 +ghcilink003 : + echo ":q" | "$(TEST_HC)" --interactive -v0 -lstdc++ + +# Test 4: +# package P +# library-dirs: `pwd`/dir004 +# extra-libraries: foo +# with +# dir004/libfoo.a + +LOCAL_PKGCONF004=dir004/local.package.conf +PKG004=dir004/pkg.conf + +ghcilink004 : + $(RM) -rf dir004 + mkdir dir004 + # + rm -f $(PKG004) + echo "name: test" >>$(PKG004) + echo "version: 1.0" >>$(PKG004) + echo "id: test-XXX" >>$(PKG004) + echo "library-dirs: `pwd`/dir004" >>$(PKG004) + echo "extra-libraries: foo" >>$(PKG004) + echo "[]" >$(LOCAL_PKGCONF004) + '$(GHC_PKG)' --no-user-package-conf -f $(LOCAL_PKGCONF004) register $(PKG004) -v0 + # + "$(TEST_HC)" -c f.c -o dir004/foo.o + ar cqs dir004/libfoo.a dir004/foo.o + echo "test" | "$(TEST_HC)" --interactive -v0 -package-conf $(LOCAL_PKGCONF004) -package test TestLink.hs + + +# Test 5: +# package P +# library-dirs: `pwd`/dir005 +# extra-libraries: foo +# with +# dir005/libfoo.so + +LOCAL_PKGCONF005=dir005/ghcilink005.package.conf +PKG005=dir005/pkg.conf + +ghcilink005 : + $(RM) -rf dir005 + mkdir dir005 + # + rm -f $(PKG005) + echo "name: test" >>$(PKG005) + echo "version: 1.0" >>$(PKG005) + echo "id: test-XXX" >>$(PKG005) + echo "library-dirs: `pwd`/dir005" >>$(PKG005) + echo "extra-libraries: foo" >>$(PKG005) + echo "[]" >$(LOCAL_PKGCONF005) + '$(GHC_PKG)' --no-user-package-conf -f $(LOCAL_PKGCONF005) register $(PKG005) -v0 + # + "$(TEST_HC)" -c -dynamic f.c -o dir005/foo.o + "$(TEST_HC)" -shared -o dir005/$(call DLL,foo) dir005/foo.o + echo "test" | "$(TEST_HC)" --interactive -v0 -package-conf $(LOCAL_PKGCONF005) -package test TestLink.hs + +# Test 6: +# package P +# extra-libraries: stdc++ + +LOCAL_PKGCONF006=dir006/ghcilink006.package.conf +PKG006=dir006/pkg.conf + +ghcilink006 : + $(RM) -rf dir006 + mkdir dir006 + # + rm -f $(PKG006) + echo "name: test" >>$(PKG006) + echo "version: 1.0" >>$(PKG006) + echo "id: test-XXX" >>$(PKG006) + echo "extra-libraries: stdc++" >>$(PKG006) + echo "[]" >$(LOCAL_PKGCONF006) + '$(GHC_PKG)' --no-user-package-conf -f $(LOCAL_PKGCONF006) register $(PKG006) -v0 + # + echo ":q" | "$(TEST_HC)" --interactive -v0 -package-conf $(LOCAL_PKGCONF006) -package test + diff --git a/tests/ghci/linking/TestLink.hs b/tests/ghci/linking/TestLink.hs new file mode 100644 index 0000000..808f6e3 --- /dev/null +++ b/tests/ghci/linking/TestLink.hs @@ -0,0 +1,8 @@ +module TestLink where + +import Foreign.C + +foreign import ccall "f" f :: CInt -> IO CInt + +test :: IO () +test = f 42 >>= print diff --git a/tests/ghci/linking/all.T b/tests/ghci/linking/all.T new file mode 100644 index 0000000..8c2e821 --- /dev/null +++ b/tests/ghci/linking/all.T @@ -0,0 +1,37 @@ +test('ghcilink001', + [ if_os('mingw32', skip), # crashes; see #5371 + extra_clean(['dir001/*','dir001']) + ], + run_command, + ['$MAKE -s --no-print-directory ghcilink001']) + +test('ghcilink002', + extra_clean(['dir002/*','dir002']), + run_command, + ['$MAKE -s --no-print-directory ghcilink002']) + +test('ghcilink003', + [ + if_os('mingw32', expect_broken(5289)), # still cannot load libstdc++ + # on Windows. See also #4468. + extra_clean(['dir003/*','dir003']) + ], + run_command, + ['$MAKE -s --no-print-directory ghcilink003']) + +test('ghcilink004', + [ if_os('mingw32', skip), # crashes; see #5371 + extra_clean(['dir004/*','dir004']) + ], + run_command, + ['$MAKE -s --no-print-directory ghcilink004']) + +test('ghcilink005', + extra_clean(['dir005/*','dir005']), + run_command, + ['$MAKE -s --no-print-directory ghcilink005']) + +test('ghcilink006', + extra_clean(['dir006/*','dir006']), + run_command, + ['$MAKE -s --no-print-directory ghcilink006']) diff --git a/tests/ghci/linking/f.c b/tests/ghci/linking/f.c new file mode 100644 index 0000000..caf249d --- /dev/null +++ b/tests/ghci/linking/f.c @@ -0,0 +1,4 @@ +int f(int x) +{ + return x*2; +} diff --git a/tests/ghci/linking/ghcilink001.stdout b/tests/ghci/linking/ghcilink001.stdout new file mode 100644 index 0000000..871727d --- /dev/null +++ b/tests/ghci/linking/ghcilink001.stdout @@ -0,0 +1 @@ +84 diff --git a/tests/ghci/linking/ghcilink002.stderr-i386-unknown-mingw32 b/tests/ghci/linking/ghcilink002.stderr-i386-unknown-mingw32 new file mode 100644 index 0000000..c0649da --- /dev/null +++ b/tests/ghci/linking/ghcilink002.stderr-i386-unknown-mingw32 @@ -0,0 +1 @@ +Creating library file: dir002/foo.dll.a diff --git a/tests/ghci/linking/ghcilink002.stdout b/tests/ghci/linking/ghcilink002.stdout new file mode 100644 index 0000000..871727d --- /dev/null +++ b/tests/ghci/linking/ghcilink002.stdout @@ -0,0 +1 @@ +84 diff --git a/tests/annotations/should_compile/ann01.stderr b/tests/ghci/linking/ghcilink003.stdout similarity index 100% copy from tests/annotations/should_compile/ann01.stderr copy to tests/ghci/linking/ghcilink003.stdout diff --git a/tests/ghci/linking/ghcilink004.stdout b/tests/ghci/linking/ghcilink004.stdout new file mode 100644 index 0000000..871727d --- /dev/null +++ b/tests/ghci/linking/ghcilink004.stdout @@ -0,0 +1 @@ +84 diff --git a/tests/ghci/linking/ghcilink005.stderr-i386-unknown-mingw32 b/tests/ghci/linking/ghcilink005.stderr-i386-unknown-mingw32 new file mode 100644 index 0000000..7929095 --- /dev/null +++ b/tests/ghci/linking/ghcilink005.stderr-i386-unknown-mingw32 @@ -0,0 +1 @@ +Creating library file: dir005/foo.dll.a diff --git a/tests/ghci/linking/ghcilink005.stdout b/tests/ghci/linking/ghcilink005.stdout new file mode 100644 index 0000000..871727d --- /dev/null +++ b/tests/ghci/linking/ghcilink005.stdout @@ -0,0 +1 @@ +84 _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
