summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-07-25 18:27:55 -0400
committerBen Gamari <ben@smart-cactus.org>2021-07-29 09:08:14 -0400
commit4fbb535d0a49f9ad7478f70b4e343c9909f68b9a (patch)
treeb8281462105c6dbd66dc43ad568d4f80f29903cf
parent37d51e88e34172f7c7927eda0353e5d2d649be17 (diff)
downloadhaskell-wip/angerman/fix-aarch64-cc.tar.gz
testsuite: Add test for #20137wip/angerman/fix-aarch64-cc
-rw-r--r--testsuite/tests/codeGen/should_run/T20137/T20137.hs57
-rw-r--r--testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-3213
-rw-r--r--testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-6413
-rw-r--r--testsuite/tests/codeGen/should_run/T20137/T20137C.c34
-rw-r--r--testsuite/tests/codeGen/should_run/T20137/all.T1
5 files changed, 118 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T20137/T20137.hs b/testsuite/tests/codeGen/should_run/T20137/T20137.hs
new file mode 100644
index 0000000000..4786e27778
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20137/T20137.hs
@@ -0,0 +1,57 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE CApiFFI #-}
+
+module Main where
+
+import Data.List
+import Data.Bits
+import GHC.Ptr
+import Foreign.Ptr
+import Foreign.C.Types
+
+type FD = CInt
+type CString = Ptr CChar
+
+foreign import ccall unsafe "runInteractiveProcess"
+ c_runInteractiveProcess
+ :: Ptr CString
+ -> CString
+ -> Ptr CString
+ -> FD
+ -> FD
+ -> FD
+ -> Ptr FD
+ -> Ptr FD
+ -> Ptr FD
+ -> Ptr CInt
+ -> Ptr CInt
+ -> CInt -- flags
+ -> Ptr CString
+ -> IO CInt
+
+main = do
+ c_runInteractiveProcess
+ (f 0x1)
+ (f 0x2)
+ (f 0x3)
+
+ 0x4 0x5 0x6
+
+ (f 0x7)
+ (f 0x8)
+ (f 0x9)
+
+ (f 0xa)
+ (f 0xb)
+
+ 0xcccccccc
+
+ (f 0xd)
+
+-- | Fill a word with a nibble.
+-- e.g. @f 1 == 0x1111111111111111@.
+f :: Int -> Ptr a
+f n = intPtrToPtr $ fromIntegral $ foldl' (.|.) 0 (map (n `shiftL`) [0,4..60])
+
diff --git a/testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-32 b/testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-32
new file mode 100644
index 0000000000..85408b75a5
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-32
@@ -0,0 +1,13 @@
+11111111
+22222222
+33333333
+4
+5
+6
+77777777
+ffffffff88888888
+ffffffff99999999
+ffffffffaaaaaaaa
+ffffffffbbbbbbbb
+cccccccc
+ffffffffdddddddd
diff --git a/testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-64 b/testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-64
new file mode 100644
index 0000000000..f76acf4ae5
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-64
@@ -0,0 +1,13 @@
+1111111111111111
+2222222222222222
+3333333333333333
+4
+5
+6
+7777777777777777
+8888888888888888
+9999999999999999
+aaaaaaaaaaaaaaaa
+bbbbbbbbbbbbbbbb
+cccccccc
+dddddddddddddddd
diff --git a/testsuite/tests/codeGen/should_run/T20137/T20137C.c b/testsuite/tests/codeGen/should_run/T20137/T20137C.c
new file mode 100644
index 0000000000..f68d88a054
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20137/T20137C.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+int
+runInteractiveProcess (char *const * args,
+ char *workingDirectory, char **environment,
+ // handles to use for the standard handles. -1 indicates
+ // create pipe, -2 indicates close.
+ int fdStdIn, int fdStdOut, int fdStdErr,
+ // output arguments to return created pipe handle to caller
+ int *pfdStdInput, int *pfdStdOutput, int *pfdStdError,
+ int *childGroup, int *childUser,
+ int flags,
+ char **failed_doing)
+{
+ // N.B. We don't use %p here since the rendering of this varies across
+ // libc implementations
+ printf("%" PRIx64 "\n", (uint64_t) args);
+ printf("%" PRIx64 "\n", (uint64_t) workingDirectory);
+ printf("%" PRIx64 "\n", (uint64_t) environment);
+ printf("%x\n", fdStdIn);
+ printf("%x\n", fdStdOut);
+ printf("%x\n", fdStdErr);
+ printf("%" PRIx64 "\n", (uint64_t) pfdStdInput);
+ printf("%" PRIx64 "\n", (uint64_t) pfdStdOutput);
+ printf("%" PRIx64 "\n", (uint64_t) pfdStdError);
+ printf("%" PRIx64 "\n", (uint64_t) childGroup);
+ printf("%" PRIx64 "\n", (uint64_t) childUser);
+ printf("%x\n", flags);
+ printf("%" PRIx64 "\n", (uint64_t) failed_doing);
+ return 0;
+}
+
diff --git a/testsuite/tests/codeGen/should_run/T20137/all.T b/testsuite/tests/codeGen/should_run/T20137/all.T
new file mode 100644
index 0000000000..33e1975bbb
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20137/all.T
@@ -0,0 +1 @@
+test('T20137', normal, compile_and_run, ['T20137C.c'])