[pypy-commit] cffi default: A Win32 test
arigo
noreply at buildbot.pypy.org
Sun Nov 4 11:12:45 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r1026:bdfa3c65f051
Date: 2012-11-04 11:12 +0100
http://bitbucket.org/cffi/cffi/changeset/bdfa3c65f051/
Log: A Win32 test
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -2346,3 +2346,22 @@
data = posix.read(fdr, 256)
assert data == b"Xhello\n"
posix.close(fdr)
+
+def test_GetLastError():
+ if sys.platform != "win32":
+ py.test.skip("GetLastError(): only for Windows")
+ #
+ lib = find_and_load_library('KERNEL32')
+ BInt = new_primitive_type("int")
+ BVoid = new_void_type()
+ BFunc1 = new_function_type((BInt,), BVoid, False)
+ BFunc2 = new_function_type((), BInt, False)
+ SetLastError = lib.load_function(BFunc1, "SetLastError")
+ GetLastError = lib.load_function(BFunc2, "GetLastError")
+ #
+ SetLastError(42)
+ # a random function that will reset the real GetLastError() to 0
+ import posix; posix.stat('.')
+ #
+ res = GetLastError()
+ assert res == 42
More information about the pypy-commit
mailing list