[pypy-svn] r29958 - in pypy/dist/pypy/module/fcntl: . test
rhymes at codespeak.net
rhymes at codespeak.net
Tue Jul 11 20:11:10 CEST 2006
Author: rhymes
Date: Tue Jul 11 20:11:05 2006
New Revision: 29958
Modified:
pypy/dist/pypy/module/fcntl/interp_fcntl.py
pypy/dist/pypy/module/fcntl/test/test_fcntl.py
Log:
more tests for fcntl, added some constants missing in linux
Modified: pypy/dist/pypy/module/fcntl/interp_fcntl.py
==============================================================================
--- pypy/dist/pypy/module/fcntl/interp_fcntl.py (original)
+++ pypy/dist/pypy/module/fcntl/interp_fcntl.py Tue Jul 11 20:11:05 2006
@@ -5,6 +5,7 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter.baseobjspace import W_Root, ObjSpace
from ctypes import *
+import sys
class CConfig:
_header_ = """
@@ -40,6 +41,12 @@
cConfig.__dict__.update(ctypes_platform.configure(CConfig))
cConfig.flock.__name__ = "_flock"
+if "linux" in sys.platform:
+ cConfig.F_GETSIG = 11
+ cConfig.F_SETSIG = 10
+ cConfig.F_GETLEASE = 1025
+ cConfig.F_SETLEASE = 1024
+
# needed to export the constants outside. see __init__.py
for name in constant_names:
value = getattr(cConfig, name)
Modified: pypy/dist/pypy/module/fcntl/test/test_fcntl.py
==============================================================================
--- pypy/dist/pypy/module/fcntl/test/test_fcntl.py (original)
+++ pypy/dist/pypy/module/fcntl/test/test_fcntl.py Tue Jul 11 20:11:05 2006
@@ -82,27 +82,27 @@
assert fcntl.fcntl(f.fileno(), fcntl.F_SETFL, os.O_NDELAY) == 0
assert fcntl.fcntl(f, fcntl.F_SETFL, os.O_NONBLOCK) == 0
assert fcntl.fcntl(f, fcntl.F_SETFL, os.O_NDELAY) == 0
-#
-# if "linux" in sys.platform:
-# # test managing signals
-# assert fcntl.fcntl(f, fcntl.F_GETOWN) == 0
-# fcntl.fcntl(f, fcntl.F_SETOWN, 20)
-# assert fcntl.fcntl(f, fcntl.F_GETOWN) == 20
-# assert fcntl.fcntl(f, fcntl.F_GETSIG) == 0
-# fcntl.fcntl(f, fcntl.F_SETSIG, 20)
-# assert fcntl.fcntl(f, fcntl.F_GETSIG) == 20
-#
-# # test leases
-# assert fcntl.fcntl(f, fcntl.F_GETLEASE) == fcntl.F_UNLCK
-# fcntl.fcntl(f, fcntl.F_SETLEASE, fcntl.F_WRLCK)
-# assert fcntl.fcntl(f, fcntl.F_GETLEASE) == fcntl.F_WRLCK
-# else:
-# # this tests should fail under BSD
-# # with "Inappropriate ioctl for device"
-# py.test.raises(IOError, fcntl.fcntl, f, fcntl.F_GETOWN)
-# py.test.raises(IOError, fcntl.fcntl, f, fcntl.F_SETOWN, 20)
-#
-#
+
+ if "linux" in sys.platform:
+ # test managing signals
+ assert fcntl.fcntl(f, fcntl.F_GETOWN) == 0
+ fcntl.fcntl(f, fcntl.F_SETOWN, 20)
+ assert fcntl.fcntl(f, fcntl.F_GETOWN) == 20
+ assert fcntl.fcntl(f, fcntl.F_GETSIG) == 0
+ fcntl.fcntl(f, fcntl.F_SETSIG, 20)
+ assert fcntl.fcntl(f, fcntl.F_GETSIG) == 20
+
+ # test leases
+ assert fcntl.fcntl(f, fcntl.F_GETLEASE) == fcntl.F_UNLCK
+ fcntl.fcntl(f, fcntl.F_SETLEASE, fcntl.F_WRLCK)
+ assert fcntl.fcntl(f, fcntl.F_GETLEASE) == fcntl.F_WRLCK
+ else:
+ # this tests should fail under BSD
+ # with "Inappropriate ioctl for device"
+ raises(IOError, fcntl.fcntl, f, fcntl.F_GETOWN)
+ raises(IOError, fcntl.fcntl, f, fcntl.F_SETOWN, 20)
+
+
# def test_flock():
# if "linux" in sys.platform:
# cfcntl.flock(f, cfcntl.LOCK_SH)
More information about the Pypy-commit
mailing list