[pypy-commit] pypy default: merged upstream
alex_gaynor
noreply at buildbot.pypy.org
Sat Nov 9 17:38:17 CET 2013
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r67903:040be31ca85a
Date: 2013-11-09 08:37 -0800
http://bitbucket.org/pypy/pypy/changeset/040be31ca85a/
Log: merged upstream
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -131,6 +131,11 @@
if hasattr(os, 'fpathconf'):
interpleveldefs['fpathconf'] = 'interp_posix.fpathconf'
interpleveldefs['pathconf_names'] = 'space.wrap(os.pathconf_names)'
+ if hasattr(os, 'pathconf'):
+ interpleveldefs['pathconf'] = 'interp_posix.pathconf'
+ if hasattr(os, 'confstr'):
+ interpleveldefs['confstr'] = 'interp_posix.confstr'
+ interpleveldefs['confstr_names'] = 'space.wrap(os.confstr_names)'
if hasattr(os, 'ttyname'):
interpleveldefs['ttyname'] = 'interp_posix.ttyname'
if hasattr(os, 'getloadavg'):
@@ -155,7 +160,9 @@
for name in ['setsid', 'getuid', 'geteuid', 'getgid', 'getegid', 'setuid',
'seteuid', 'setgid', 'setegid', 'getgroups', 'getpgrp',
'setpgrp', 'getppid', 'getpgid', 'setpgid', 'setreuid',
- 'setregid', 'getsid', 'setsid', 'fstatvfs', 'statvfs']:
+ 'setregid', 'getsid', 'setsid', 'fstatvfs', 'statvfs',
+ 'setgroups', 'initgroups', 'tcgetpgrp', 'tcsetpgrp',
+ 'getresuid', 'getresgid', 'setresuid', 'setresgid']:
if hasattr(os, name):
interpleveldefs[name] = 'interp_posix.%s' % (name,)
# not visible via os, inconsistency in nt:
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -987,7 +987,39 @@
Return list of supplemental group IDs for the process.
"""
- return space.newlist([space.wrap(e) for e in os.getgroups()])
+ try:
+ list = os.getgroups()
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.newlist([space.wrap(e) for e in list])
+
+def setgroups(space, w_list):
+ """ setgroups(list)
+
+ Set the groups of the current process to list.
+ """
+ list = []
+ for w_gid in space.unpackiterable(w_list):
+ gid = space.int_w(w_gid)
+ check_uid_range(space, gid)
+ list.append(gid)
+ try:
+ os.setgroups(list[:])
+ except OSError, e:
+ raise wrap_oserror(space, e)
+
+ at unwrap_spec(username=str, gid=c_gid_t)
+def initgroups(space, username, gid):
+ """ initgroups(username, gid) -> None
+
+ Call the system initgroups() to initialize the group access list with all of
+ the groups of which the specified username is a member, plus the specified
+ group id.
+ """
+ try:
+ os.initgroups(username, gid)
+ except OSError, e:
+ raise wrap_oserror(space, e)
def getpgrp(space):
""" getpgrp() -> pgrp
@@ -1089,6 +1121,77 @@
raise wrap_oserror(space, e)
return space.w_None
+ at unwrap_spec(fd=c_int)
+def tcgetpgrp(space, fd):
+ """ tcgetpgrp(fd) -> pgid
+
+ Return the process group associated with the terminal given by a fd.
+ """
+ try:
+ pgid = os.tcgetpgrp(fd)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.wrap(pgid)
+
+ at unwrap_spec(fd=c_int, pgid=c_gid_t)
+def tcsetpgrp(space, fd, pgid):
+ """ tcsetpgrp(fd, pgid)
+
+ Set the process group associated with the terminal given by a fd.
+ """
+ try:
+ os.tcsetpgrp(fd, pgid)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+
+def getresuid(space):
+ """ getresuid() -> (ruid, euid, suid)
+
+ Get tuple of the current process's real, effective, and saved user ids.
+ """
+ try:
+ (ruid, euid, suid) = os.getresuid()
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.newtuple([space.wrap(ruid),
+ space.wrap(euid),
+ space.wrap(suid)])
+
+def getresgid(space):
+ """ getresgid() -> (rgid, egid, sgid)
+
+ Get tuple of the current process's real, effective, and saved group ids.
+ """
+ try:
+ (rgid, egid, sgid) = os.getresgid()
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.newtuple([space.wrap(rgid),
+ space.wrap(egid),
+ space.wrap(sgid)])
+
+ at unwrap_spec(ruid=c_uid_t, euid=c_uid_t, suid=c_uid_t)
+def setresuid(space, ruid, euid, suid):
+ """ setresuid(ruid, euid, suid)
+
+ Set the current process's real, effective, and saved user ids.
+ """
+ try:
+ os.setresuid(ruid, euid, suid)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+
+ at unwrap_spec(rgid=c_gid_t, egid=c_gid_t, sgid=c_gid_t)
+def setresgid(space, rgid, egid, sgid):
+ """ setresgid(rgid, egid, sgid)
+
+ Set the current process's real, effective, and saved group ids.
+ """
+ try:
+ os.setresgid(rgid, egid, sgid)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+
def declare_new_w_star(name):
if name in RegisterOs.w_star_returning_int:
@unwrap_spec(status=c_int)
@@ -1130,15 +1233,37 @@
def sysconf(space, w_name):
num = confname_w(space, w_name, os.sysconf_names)
- return space.wrap(os.sysconf(num))
+ try:
+ res = os.sysconf(num)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.wrap(res)
@unwrap_spec(fd=c_int)
def fpathconf(space, fd, w_name):
num = confname_w(space, w_name, os.pathconf_names)
try:
- return space.wrap(os.fpathconf(fd, num))
+ res = os.fpathconf(fd, num)
except OSError, e:
raise wrap_oserror(space, e)
+ return space.wrap(res)
+
+ at unwrap_spec(path='str0')
+def pathconf(space, path, w_name):
+ num = confname_w(space, w_name, os.pathconf_names)
+ try:
+ res = os.pathconf(path, num)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.wrap(res)
+
+def confstr(space, w_name):
+ num = confname_w(space, w_name, os.confstr_names)
+ try:
+ res = os.confstr(num)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.wrap(res)
@unwrap_spec(path='str0', uid=c_uid_t, gid=c_gid_t)
def chown(space, path, uid, gid):
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -78,6 +78,11 @@
cls.w_sysconf_name = space.wrap(sysconf_name)
cls.w_sysconf_value = space.wrap(os.sysconf_names[sysconf_name])
cls.w_sysconf_result = space.wrap(os.sysconf(sysconf_name))
+ if hasattr(os, 'confstr'):
+ confstr_name = os.confstr_names.keys()[0]
+ cls.w_confstr_name = space.wrap(confstr_name)
+ cls.w_confstr_value = space.wrap(os.confstr_names[confstr_name])
+ cls.w_confstr_result = space.wrap(os.confstr(confstr_name))
cls.w_SIGABRT = space.wrap(signal.SIGABRT)
cls.w_python = space.wrap(sys.executable)
if hasattr(os, 'major'):
@@ -616,6 +621,30 @@
os = self.posix
assert os.getgroups() == self.getgroups
+ if hasattr(os, 'setgroups'):
+ def test_os_setgroups(self):
+ os = self.posix
+ raises(TypeError, os.setgroups, [2, 5, "hello"])
+ try:
+ os.setgroups(os.getgroups())
+ except OSError:
+ pass
+
+ if hasattr(os, 'initgroups'):
+ def test_os_initgroups(self):
+ os = self.posix
+ raises(OSError, os.initgroups, "crW2hTQC", 100)
+
+ if hasattr(os, 'tcgetpgrp'):
+ def test_os_tcgetpgrp(self):
+ os = self.posix
+ raises(OSError, os.tcgetpgrp, 9999)
+
+ if hasattr(os, 'tcsetpgrp'):
+ def test_os_tcsetpgrp(self):
+ os = self.posix
+ raises(OSError, os.tcsetpgrp, 9999, 1)
+
if hasattr(os, 'getpgid'):
def test_os_getpgid(self):
os = self.posix
@@ -634,6 +663,30 @@
assert os.getsid(0) == self.getsid0
raises(OSError, os.getsid, -100000)
+ if hasattr(os, 'getresuid'):
+ def test_os_getresuid(self):
+ os = self.posix
+ res = os.getresuid()
+ assert len(res) == 3
+
+ if hasattr(os, 'getresgid'):
+ def test_os_getresgid(self):
+ os = self.posix
+ res = os.getresgid()
+ assert len(res) == 3
+
+ if hasattr(os, 'setresuid'):
+ def test_os_setresuid(self):
+ os = self.posix
+ a, b, c = os.getresuid()
+ os.setresuid(a, b, c)
+
+ if hasattr(os, 'setresgid'):
+ def test_os_setresgid(self):
+ os = self.posix
+ a, b, c = os.getresgid()
+ os.setresgid(a, b, c)
+
if hasattr(os, 'sysconf'):
def test_os_sysconf(self):
os = self.posix
@@ -652,6 +705,25 @@
raises(OSError, os.fpathconf, -1, "PC_PIPE_BUF")
raises(ValueError, os.fpathconf, 1, "##")
+ if hasattr(os, 'pathconf'):
+ def test_os_pathconf(self):
+ os = self.posix
+ assert os.pathconf("/tmp", "PC_NAME_MAX") >= 31
+ # Linux: the following gets 'No such file or directory'
+ raises(OSError, os.pathconf, "", "PC_PIPE_BUF")
+ raises(ValueError, os.pathconf, "/tmp", "##")
+
+ if hasattr(os, 'confstr'):
+ def test_os_confstr(self):
+ os = self.posix
+ assert os.confstr(self.confstr_value) == self.confstr_result
+ assert os.confstr(self.confstr_name) == self.confstr_result
+ assert os.confstr_names[self.confstr_name] == self.confstr_value
+
+ def test_os_confstr_error(self):
+ os = self.posix
+ raises(ValueError, os.confstr, "!@#$%!#$!@#")
+
if hasattr(os, 'wait'):
def test_os_wait(self):
os = self.posix
diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -1162,10 +1162,19 @@
v_result)
def rewrite_op_direct_ptradd(self, op):
- # xxx otherwise, not implemented:
- assert op.args[0].concretetype == rffi.CCHARP
+ v_shift = op.args[1]
+ assert v_shift.concretetype == lltype.Signed
+ ops = []
#
- return SpaceOperation('int_add', [op.args[0], op.args[1]], op.result)
+ if op.args[0].concretetype != rffi.CCHARP:
+ v_prod = varoftype(lltype.Signed)
+ by = llmemory.sizeof(op.args[0].concretetype.TO.OF)
+ c_by = Constant(by, lltype.Signed)
+ ops.append(SpaceOperation('int_mul', [v_shift, c_by], v_prod))
+ v_shift = v_prod
+ #
+ ops.append(SpaceOperation('int_add', [op.args[0], v_shift], op.result))
+ return ops
# ----------
# Long longs, for 32-bit only. Supported operations are left unmodified,
diff --git a/rpython/jit/codewriter/test/test_flatten.py b/rpython/jit/codewriter/test/test_flatten.py
--- a/rpython/jit/codewriter/test/test_flatten.py
+++ b/rpython/jit/codewriter/test/test_flatten.py
@@ -993,6 +993,16 @@
int_return %i2
""", transform=True)
+ def test_direct_ptradd_2(self):
+ def f(p, n):
+ return lltype.direct_ptradd(p, n + 2)
+ self.encoding_test(f, [lltype.nullptr(rffi.SHORTP.TO), 123], """
+ int_add %i1, $2 -> %i2
+ int_mul %i2, $<ItemOffset <SHORT> 1> -> %i3
+ int_add %i0, %i3 -> %i4
+ int_return %i4
+ """, transform=True)
+
def test_convert_float_bytes(self):
from rpython.rlib.longlong2float import float2longlong, longlong2float
def f(x):
diff --git a/rpython/rtyper/module/ll_os.py b/rpython/rtyper/module/ll_os.py
--- a/rpython/rtyper/module/ll_os.py
+++ b/rpython/rtyper/module/ll_os.py
@@ -129,10 +129,6 @@
('tms_cutime', rffi.INT),
('tms_cstime', rffi.INT)])
- GID_T = platform.SimpleType('gid_t', rffi.INT)
- #TODO right now is used only in getgroups, may need to update other
- #functions like setgid
-
# For now we require off_t to be the same size as LONGLONG, which is the
# interface required by callers of functions that thake an argument of type
# off_t
@@ -655,6 +651,46 @@
return extdef([int, int], int, "ll_os.ll_fpathconf",
llimpl=fpathconf_llimpl)
+ @registering_if(os, 'pathconf')
+ def register_os_pathconf(self):
+ c_pathconf = self.llexternal('pathconf',
+ [rffi.CCHARP, rffi.INT], rffi.LONG)
+
+ def pathconf_llimpl(path, i):
+ rposix.set_errno(0)
+ res = c_pathconf(path, i)
+ if res == -1:
+ errno = rposix.get_errno()
+ if errno != 0:
+ raise OSError(errno, "pathconf failed")
+ return res
+ return extdef([str0, int], int, "ll_os.ll_pathconf",
+ llimpl=pathconf_llimpl)
+
+ @registering_if(os, 'confstr')
+ def register_os_confstr(self):
+ c_confstr = self.llexternal('confstr', [rffi.INT, rffi.CCHARP,
+ rffi.SIZE_T], rffi.SIZE_T)
+
+ def confstr_llimpl(i):
+ rposix.set_errno(0)
+ n = c_confstr(i, lltype.nullptr(rffi.CCHARP.TO), 0)
+ n = rffi.cast(lltype.Signed, n)
+ if n > 0:
+ buf = lltype.malloc(rffi.CCHARP.TO, n, flavor='raw')
+ try:
+ c_confstr(i, buf, n)
+ return rffi.charp2strn(buf, n)
+ finally:
+ lltype.free(buf, flavor='raw')
+ else:
+ errno = rposix.get_errno()
+ if errno != 0:
+ raise OSError(errno, "confstr failed")
+ return None
+ return extdef([int], SomeString(can_be_None=True),
+ "ll_os.ll_confstr", llimpl=confstr_llimpl)
+
@registering_if(os, 'getuid')
def register_os_getuid(self):
return self.extdef_for_os_function_returning_int('getuid')
@@ -693,7 +729,7 @@
@registering_if(os, 'getgroups')
def register_os_getgroups(self):
- GP = rffi.CArrayPtr(self.GID_T)
+ GP = rffi.CArrayPtr(rffi.PID_T)
c_getgroups = self.llexternal('getgroups', [rffi.INT, GP], rffi.INT)
def getgroups_llimpl():
@@ -702,16 +738,50 @@
groups = lltype.malloc(GP.TO, n, flavor='raw')
try:
n = c_getgroups(n, groups)
- result = [groups[i] for i in range(n)]
+ result = [rffi.cast(lltype.Signed, groups[i])
+ for i in range(n)]
finally:
lltype.free(groups, flavor='raw')
if n >= 0:
return result
raise OSError(rposix.get_errno(), "os_getgroups failed")
- return extdef([], [self.GID_T], llimpl=getgroups_llimpl,
+ return extdef([], [int], llimpl=getgroups_llimpl,
export_name="ll_os.ll_getgroups")
+ @registering_if(os, 'setgroups')
+ def register_os_setgroups(self):
+ GP = rffi.CArrayPtr(rffi.PID_T)
+ c_setgroups = self.llexternal('setgroups', [rffi.SIZE_T, GP], rffi.INT)
+
+ def setgroups_llimpl(list):
+ n = len(list)
+ groups = lltype.malloc(GP.TO, n, flavor='raw')
+ try:
+ for i in range(n):
+ groups[i] = rffi.cast(rffi.PID_T, list[i])
+ n = c_setgroups(rffi.cast(rffi.SIZE_T, n), groups)
+ finally:
+ lltype.free(groups, flavor='raw')
+ if n != 0:
+ raise OSError(rposix.get_errno(), "os_setgroups failed")
+
+ return extdef([[int]], None, llimpl=setgroups_llimpl,
+ export_name="ll_os.ll_setgroups")
+
+ @registering_if(os, 'initgroups')
+ def register_os_initgroups(self):
+ c_initgroups = self.llexternal('initgroups',
+ [rffi.CCHARP, rffi.PID_T], rffi.INT)
+
+ def initgroups_llimpl(user, group):
+ n = c_initgroups(user, rffi.cast(rffi.PID_T, group))
+ if n != 0:
+ raise OSError(rposix.get_errno(), "os_initgroups failed")
+
+ return extdef([str, int], None, llimpl=initgroups_llimpl,
+ export_name="ll_os.ll_initgroups")
+
@registering_if(os, 'getpgrp')
def register_os_getpgrp(self):
name = 'getpgrp'
@@ -747,6 +817,35 @@
else:
return self.extdef_for_os_function_accepting_0int(name)
+ @registering_if(os, 'tcgetpgrp')
+ def register_os_tcgetpgrp(self):
+ c_tcgetpgrp = self.llexternal('tcgetpgrp', [rffi.INT], rffi.PID_T)
+
+ def c_tcgetpgrp_llimpl(fd):
+ res = c_tcgetpgrp(rffi.cast(rffi.INT, fd))
+ res = rffi.cast(lltype.Signed, res)
+ if res == -1:
+ raise OSError(rposix.get_errno(), "tcgetpgrp failed")
+ return res
+
+ return extdef([int], int, llimpl=c_tcgetpgrp_llimpl,
+ export_name='ll_os.ll_os_tcgetpgrp')
+
+ @registering_if(os, 'tcsetpgrp')
+ def register_os_tcsetpgrp(self):
+ c_tcsetpgrp = self.llexternal('tcsetpgrp', [rffi.INT, rffi.PID_T],
+ rffi.INT)
+
+ def c_tcsetpgrp_llimpl(fd, pgrp):
+ res = c_tcsetpgrp(rffi.cast(rffi.INT, fd),
+ rffi.cast(rffi.PID_T, pgrp))
+ res = rffi.cast(lltype.Signed, res)
+ if res == -1:
+ raise OSError(rposix.get_errno(), "tcsetpgrp failed")
+
+ return extdef([int, int], None, llimpl=c_tcsetpgrp_llimpl,
+ export_name='ll_os.ll_os_tcsetpgrp')
+
@registering_if(os, 'getppid')
def register_os_getppid(self):
return self.extdef_for_os_function_returning_int('getppid')
@@ -775,6 +874,76 @@
def register_os_setsid(self):
return self.extdef_for_os_function_returning_int('setsid')
+ @registering_if(os, 'getresuid')
+ def register_os_getresuid(self):
+ c_getresuid = self.llexternal('getresuid', [rffi.INTP] * 3, rffi.INT)
+
+ def c_getresuid_llimpl():
+ out = lltype.malloc(rffi.INTP.TO, 3, flavor='raw')
+ try:
+ res = c_getresuid(rffi.ptradd(out, 0),
+ rffi.ptradd(out, 1),
+ rffi.ptradd(out, 2))
+ res = rffi.cast(lltype.Signed, res)
+ if res == -1:
+ raise OSError(rposix.get_errno(), "getresuid failed")
+ return (rffi.cast(lltype.Signed, out[0]),
+ rffi.cast(lltype.Signed, out[1]),
+ rffi.cast(lltype.Signed, out[2]))
+ finally:
+ lltype.free(out, flavor='raw')
+
+ return extdef([], (int, int, int), llimpl=c_getresuid_llimpl,
+ export_name='ll_os.ll_os_getresuid')
+
+ @registering_if(os, 'getresgid')
+ def register_os_getresgid(self):
+ c_getresgid = self.llexternal('getresgid', [rffi.INTP] * 3, rffi.INT)
+
+ def c_getresgid_llimpl():
+ out = lltype.malloc(rffi.INTP.TO, 3, flavor='raw')
+ try:
+ res = c_getresgid(rffi.ptradd(out, 0),
+ rffi.ptradd(out, 1),
+ rffi.ptradd(out, 2))
+ res = rffi.cast(lltype.Signed, res)
+ if res == -1:
+ raise OSError(rposix.get_errno(), "getresgid failed")
+ return (rffi.cast(lltype.Signed, out[0]),
+ rffi.cast(lltype.Signed, out[1]),
+ rffi.cast(lltype.Signed, out[2]))
+ finally:
+ lltype.free(out, flavor='raw')
+
+ return extdef([], (int, int, int), llimpl=c_getresgid_llimpl,
+ export_name='ll_os.ll_os_getresgid')
+
+ @registering_if(os, 'setresuid')
+ def register_os_setresuid(self):
+ c_setresuid = self.llexternal('setresuid', [rffi.INT] * 3, rffi.INT)
+
+ def c_setresuid_llimpl(ruid, euid, suid):
+ res = c_setresuid(ruid, euid, suid)
+ res = rffi.cast(lltype.Signed, res)
+ if res == -1:
+ raise OSError(rposix.get_errno(), "setresuid failed")
+
+ return extdef([int, int, int], None, llimpl=c_setresuid_llimpl,
+ export_name='ll_os.ll_os_setresuid')
+
+ @registering_if(os, 'setresgid')
+ def register_os_setresgid(self):
+ c_setresgid = self.llexternal('setresgid', [rffi.INT] * 3, rffi.INT)
+
+ def c_setresgid_llimpl(rgid, egid, sgid):
+ res = c_setresgid(rgid, egid, sgid)
+ res = rffi.cast(lltype.Signed, res)
+ if res == -1:
+ raise OSError(rposix.get_errno(), "setresgid failed")
+
+ return extdef([int, int, int], None, llimpl=c_setresgid_llimpl,
+ export_name='ll_os.ll_os_setresgid')
+
@registering_str_unicode(os.open)
def register_os_open(self, traits):
os_open = self.llexternal(traits.posix_function_name('open'),
diff --git a/rpython/rtyper/module/test/test_posix.py b/rpython/rtyper/module/test/test_posix.py
--- a/rpython/rtyper/module/test/test_posix.py
+++ b/rpython/rtyper/module/test/test_posix.py
@@ -1,5 +1,6 @@
import py
from rpython.rtyper.test.tool import BaseRtypingTest
+from rpython.rtyper.annlowlevel import hlstr
from rpython.tool.udir import udir
from rpython.rlib.rarithmetic import is_valid_int
@@ -176,6 +177,27 @@
return os.sysconf(i)
assert self.interpret(f, [13]) == f(13)
+ if hasattr(os, 'confstr'):
+ def test_os_confstr(self):
+ def f(i):
+ try:
+ return os.confstr(i)
+ except OSError:
+ return "oooops!!"
+ some_value = os.confstr_names.values()[-1]
+ res = self.interpret(f, [some_value])
+ assert hlstr(res) == f(some_value)
+ res = self.interpret(f, [94781413])
+ assert hlstr(res) == "oooops!!"
+
+ if hasattr(os, 'pathconf'):
+ def test_os_pathconf(self):
+ def f(i):
+ return os.pathconf("/tmp", i)
+ i = os.pathconf_names["PC_NAME_MAX"]
+ some_value = self.interpret(f, [i])
+ assert some_value >= 31
+
if hasattr(os, 'chroot'):
def test_os_chroot(self):
def f():
@@ -205,3 +227,78 @@
return os.getgroups()
ll_a = self.interpret(f, [])
assert self.ll_to_list(ll_a) == f()
+
+ if hasattr(os, 'setgroups'):
+ def test_setgroups(self):
+ def f():
+ try:
+ os.setgroups(os.getgroups())
+ except OSError:
+ pass
+ self.interpret(f, [])
+
+ if hasattr(os, 'initgroups'):
+ def test_initgroups(self):
+ def f():
+ try:
+ os.initgroups('sUJJeumz', 4321)
+ except OSError:
+ return 1
+ return 0
+ res = self.interpret(f, [])
+ assert res == 1
+
+ if hasattr(os, 'tcgetpgrp'):
+ def test_tcgetpgrp(self):
+ def f(fd):
+ try:
+ return os.tcgetpgrp(fd)
+ except OSError:
+ return 42
+ res = self.interpret(f, [9999])
+ assert res == 42
+
+ if hasattr(os, 'tcsetpgrp'):
+ def test_tcsetpgrp(self):
+ def f(fd, pgrp):
+ try:
+ os.tcsetpgrp(fd, pgrp)
+ except OSError:
+ return 1
+ return 0
+ res = self.interpret(f, [9999, 1])
+ assert res == 1
+
+ if hasattr(os, 'getresuid'):
+ def test_getresuid(self):
+ def f():
+ a, b, c = os.getresuid()
+ return a + b * 37 + c * 1291
+ res = self.interpret(f, [])
+ a, b, c = os.getresuid()
+ assert res == a + b * 37 + c * 1291
+
+ if hasattr(os, 'getresgid'):
+ def test_getresgid(self):
+ def f():
+ a, b, c = os.getresgid()
+ return a + b * 37 + c * 1291
+ res = self.interpret(f, [])
+ a, b, c = os.getresgid()
+ assert res == a + b * 37 + c * 1291
+
+ if hasattr(os, 'setresuid'):
+ def test_setresuid(self):
+ def f():
+ a, b, c = os.getresuid()
+ a = (a + 1) - 1
+ os.setresuid(a, b, c)
+ self.interpret(f, [])
+
+ if hasattr(os, 'setresgid'):
+ def test_setresgid(self):
+ def f():
+ a, b, c = os.getresgid()
+ a = (a + 1) - 1
+ os.setresgid(a, b, c)
+ self.interpret(f, [])
More information about the pypy-commit
mailing list