[pypy-commit] cffi split-verify: Add verifier_distutils_module, so that we can transition all the other zintegration tests to FFIBuilder
stefanor
noreply at buildbot.pypy.org
Sun Oct 6 19:28:25 CEST 2013
Author: Stefano Rivera <stefano at rivera.za.net>
Branch: split-verify
Changeset: r1360:e898f9567c25
Date: 2013-10-06 19:04 +0200
http://bitbucket.org/cffi/cffi/changeset/e898f9567c25/
Log: Add verifier_distutils_module, so that we can transition all the
other zintegration tests to FFIBuilder
diff --git a/testing/snippets/verifier_distutils_module/setup.py b/testing/snippets/verifier_distutils_module/setup.py
new file mode 100644
--- /dev/null
+++ b/testing/snippets/verifier_distutils_module/setup.py
@@ -0,0 +1,7 @@
+
+from distutils.core import setup
+import snip_basic_verify
+
+setup(
+ py_modules=['snip_basic_verify'],
+ ext_modules=[snip_basic_verify.ffi.verifier.get_extension()])
diff --git a/testing/snippets/verifier_distutils_module/snip_basic_verify.py b/testing/snippets/verifier_distutils_module/snip_basic_verify.py
new file mode 100644
--- /dev/null
+++ b/testing/snippets/verifier_distutils_module/snip_basic_verify.py
@@ -0,0 +1,17 @@
+
+from cffi import FFI
+import sys
+
+ffi = FFI()
+ffi.cdef(""" // some declarations from the man page
+ struct passwd {
+ char *pw_name;
+ ...;
+ };
+ struct passwd *getpwuid(int uid);
+""")
+C = ffi.verify(""" // passed to the real C compiler
+#include <sys/types.h>
+#include <pwd.h>
+""", libraries=[], # or a list of libraries to link with
+ force_generic_engine=hasattr(sys, '_force_generic_engine_'))
diff --git a/testing/test_zintegration.py b/testing/test_zintegration.py
--- a/testing/test_zintegration.py
+++ b/testing/test_zintegration.py
@@ -83,6 +83,13 @@
assert snip_infrastructure.func() == 42
''')
+def test_verifier_distutils_module():
+ run_setup_and_program("verifier_distutils_module", '''
+ import snip_basic_verify
+ p = snip_basic_verify.C.getpwuid(0)
+ assert snip_basic_verify.ffi.string(p.pw_name) == b"root"
+ ''')
+
def test_distutils_module():
run_setup_and_program("distutils_module", '''
import snip_basic_verify
More information about the pypy-commit
mailing list