Author: Armin Rigo <[email protected]>
Branch: static-callback-embedding
Changeset: r2504:6239c1250e0b
Date: 2016-01-01 11:20 +0100
http://bitbucket.org/cffi/cffi/changeset/6239c1250e0b/
Log: A test with two modules.
diff --git a/testing/embedding/add2-test.c b/testing/embedding/add2-test.c
new file mode 100644
--- /dev/null
+++ b/testing/embedding/add2-test.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+extern int add1(int, int);
+extern int add2(int, int, int);
+
+
+int main(void)
+{
+ int x, y;
+ x = add1(40, 2);
+ y = add2(100, -5, -20);
+ printf("got: %d %d\n", x, y);
+ return 0;
+}
diff --git a/testing/embedding/add2.py b/testing/embedding/add2.py
new file mode 100644
--- /dev/null
+++ b/testing/embedding/add2.py
@@ -0,0 +1,21 @@
+import cffi
+
+ffi = cffi.FFI()
+
+ffi.cdef("""
+ extern "Python" int add2(int, int, int);
+""", dllexport=True)
+
+ffi.embedding_init_code("""
+ print("preparing ADD2")
+
+ @ffi.def_extern()
+ def add2(x, y, z):
+ print "adding", x, "and", y, "and", z
+ return x + y + z
+""")
+
+ffi.set_source("_add2_cffi", """
+""")
+
+ffi.compile()
diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py
--- a/testing/embedding/test_basic.py
+++ b/testing/embedding/test_basic.py
@@ -56,3 +56,14 @@
"adding 40 and 2\n"
"adding 100 and -5\n"
"got: 42 95\n")
+
+ def test_two_modules(self):
+ self.prepare_module('add1')
+ self.prepare_module('add2')
+ self.compile('add2-test', ['_add1_cffi', '_add2_cffi'])
+ output = self.execute('add2-test')
+ assert output == ("preparing\n"
+ "adding 40 and 2\n"
+ "preparing ADD2\n"
+ "adding 100 and -5 and -20\n"
+ "got: 42 75\n")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit