[pypy-commit] cffi default: errno test in test_c.

arigo noreply at buildbot.pypy.org
Sun Jul 8 10:36:13 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r594:3788f3f49af0
Date: 2012-07-07 19:54 +0200
http://bitbucket.org/cffi/cffi/changeset/3788f3f49af0/

Log:	errno test in test_c.

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3508,6 +3508,7 @@
 }
 static void _testfunc5(void)
 {
+    errno = errno + 15;
 }
 static int *_testfunc6(int *x)
 {
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -1388,3 +1388,22 @@
     BUChar = new_primitive_type("unsigned char")
     BArray = new_array_type(new_pointer_type(BUChar), 123)
     assert getcname(BArray, "<-->") == "unsigned char<-->[123]"
+
+def test_errno():
+    BVoid = new_void_type()
+    BFunc5 = new_function_type((), BVoid)
+    f = cast(BFunc5, _testfunc(5))
+    set_errno(50)
+    f()
+    assert get_errno() == 65
+    f(); f()
+    assert get_errno() == 95
+    #
+    def cb():
+        e = get_errno()
+        set_errno(e - 6)
+    f = callback(BFunc5, cb)
+    f()
+    assert get_errno() == 89
+    f(); f()
+    assert get_errno() == 77


More information about the pypy-commit mailing list