[Git][ghc/ghc][wip/T24634] testsuite: Add broken test for CApiFFI with -fprefer-bytecode

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Fri Apr 5 21:39:01 UTC 2024



Ben Gamari pushed to branch wip/T24634 at Glasgow Haskell Compiler / GHC


Commits:
6f7bdec2 by Ben Gamari at 2024-04-05T17:38:52-04:00
testsuite: Add broken test for CApiFFI with -fprefer-bytecode

See #24634.

- - - - -


6 changed files:

- + testsuite/tests/bytecode/T24634/Hello.hs
- + testsuite/tests/bytecode/T24634/Main.hs
- + testsuite/tests/bytecode/T24634/Makefile
- + testsuite/tests/bytecode/T24634/all.T
- + testsuite/tests/bytecode/T24634/hello.c
- + testsuite/tests/bytecode/T24634/hello.h


Changes:

=====================================
testsuite/tests/bytecode/T24634/Hello.hs
=====================================
@@ -0,0 +1,16 @@
+{-# LANGUAGE CApiFFI #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+module Hello where
+
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+
+foreign import capi "hello.h say_hello" say_hello :: IO Int
+
+mkHello :: DecsQ
+mkHello = do
+  n <- runIO say_hello
+  [d| hello :: IO Int
+      hello = return $(lift n) |]


=====================================
testsuite/tests/bytecode/T24634/Main.hs
=====================================
@@ -0,0 +1,10 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Main where
+
+import Hello
+
+$(mkHello)
+
+main :: IO ()
+main = hello >>= print


=====================================
testsuite/tests/bytecode/T24634/Makefile
=====================================
@@ -0,0 +1,9 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+bytecode-capi:
+	$(TEST_HC) -c hello.c
+	$(TEST_HC) -c -fbyte-code-and-object-code Hello.hs
+	$(TEST_HC) -fprefer-byte-code hello.o Main.hs
+	./Main


=====================================
testsuite/tests/bytecode/T24634/all.T
=====================================
@@ -0,0 +1,7 @@
+test('T24634',
+     [extra_files(['hello.h', 'hello.c', 'Hello.hs', 'Main.hs']),
+      req_interp,
+      expect_broken(24634),
+      ],
+     makefile_test,
+     [''])


=====================================
testsuite/tests/bytecode/T24634/hello.c
=====================================
@@ -0,0 +1,5 @@
+#include "hello.h"
+
+int say_hello() {
+  return 42;
+}


=====================================
testsuite/tests/bytecode/T24634/hello.h
=====================================
@@ -0,0 +1 @@
+int say_hello(void);



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f7bdec20ccba366bc5e677ce16406f3311fd038

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f7bdec20ccba366bc5e677ce16406f3311fd038
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240405/a9122ee9/attachment-0001.html>


More information about the ghc-commits mailing list