[pypy-svn] r47350 - in pypy/dist/pypy/rpython/module: . test
fijal at codespeak.net
fijal at codespeak.net
Tue Oct 9 15:48:46 CEST 2007
Author: fijal
Date: Tue Oct 9 15:48:45 2007
New Revision: 47350
Modified:
pypy/dist/pypy/rpython/module/ll_os_stat.py
pypy/dist/pypy/rpython/module/test/test_posix.py
Log:
whack, whack, until os.fstat works on top of llinterp
Modified: pypy/dist/pypy/rpython/module/ll_os_stat.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os_stat.py (original)
+++ pypy/dist/pypy/rpython/module/ll_os_stat.py Tue Oct 9 15:48:45 2007
@@ -9,6 +9,7 @@
from pypy.rpython import extregistry
from pypy.rpython.extfunc import register_external
from pypy.rpython.lltypesystem import rffi, lltype
+from pypy.rpython.lltypesystem.rtupletype import TUPLE_TYPE
# XXX on Windows, stat() is flawed; see CPython's posixmodule.c for
# an implementation based on the Win32 API
@@ -204,6 +205,28 @@
finally:
lltype.free(stresult, flavor='raw')
+ def fakeimpl(arg):
+ st = getattr(os, name)(arg)
+ tup = [st[i] for i in range(len(st))]
+ extra_zeroes = (0,) * (len(STAT_FIELDS) - len(PORTABLE_STAT_FIELDS))
+ tup = tup + list(extra_zeroes)
+ fields = []
+ for i in range(len(tup)):
+ if i in [1, 2, 6]:
+ fields.append(rffi.LONGLONG)
+ else:
+ fields.append(lltype.Signed)
+ TP = TUPLE_TYPE(fields)
+ ll_tup = lltype.malloc(TP.TO)
+ for i in range(len(tup)):
+ # XXX ARGH!
+ if i in [1, 6, 2]:
+ val = rffi.cast(rffi.LONGLONG, tup[i])
+ else:
+ val = tup[i]
+ setattr(ll_tup, 'item%d' % i, val)
+ return ll_tup
+
if arg_is_path:
s_arg = str
else:
@@ -211,10 +234,11 @@
register_external(getattr(os, name), [s_arg], s_StatResult,
"ll_os.ll_os_%s" % (name,),
llimpl=func_with_new_name(os_mystat_llimpl,
- 'os_%s_llimpl' % (name,)))
+ 'os_%s_llimpl' % (name,)),
+ llfakeimpl=func_with_new_name(fakeimpl,
+ 'os_%s_fake' % (name,)))
# ____________________________________________________________
-
if 0:
XXX - """
disabled for now:
Modified: pypy/dist/pypy/rpython/module/test/test_posix.py
==============================================================================
--- pypy/dist/pypy/rpython/module/test/test_posix.py (original)
+++ pypy/dist/pypy/rpython/module/test/test_posix.py Tue Oct 9 15:48:45 2007
@@ -24,7 +24,6 @@
assert type(func) == int
def test_fstat(self):
- import py; py.test.skip("XXX cannot run os.stat() on the llinterp yet")
def fo(fi):
g = posix.fstat(fi)
return g
@@ -32,8 +31,7 @@
func = self.interpret(fo,[fi])
stat = os.fstat(fi)
for i in range(len(stat)):
- stat0 = getattr(func, 'item%d' % i)
- assert stat0 == stat[i]
+ assert getattr(func, 'item%d' % i) == stat[i]
def test_times(self):
@@ -134,5 +132,6 @@
pass
class TestOOtype(BaseTestPosix, OORtypeMixin):
- pass
+ def test_fstat(self):
+ py.test.skip("not working")
More information about the Pypy-commit
mailing list