Commit ac887af7 authored by qinsoon's avatar qinsoon

[wip] rewrite two rpython_list tests as separated function (loaded as

dylib). cannot do more, since we need rpython runtime to init global
cells (list needs global cells for a template 0-length list)
parent cae72305
<?xml version="1.0" encoding="UTF-8"?>
<module type="RUST_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python">
<configuration sdkName="" />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
......@@ -11,7 +16,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Rust &lt;mu&gt;" level="project" />
<orderEntry type="library" name="Cargo &lt;mu&gt;" level="project" />
<orderEntry type="library" name="Rust &lt;mu&gt;" level="project" />
</component>
</module>
\ No newline at end of file
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rlib.rmu import zebu
from rpython.rlib.rmu import zebu as rmu
from rpython.translator.platform import platform
from util import fncptr_from_rpy_func, fncptr_from_py_script, may_spawn_proc
import ctypes, py, stat
......@@ -11,25 +11,25 @@ c_exit = rffi.llexternal('exit', [rffi.INT], lltype.Void, _nowrapper=True)
@may_spawn_proc
def test_rpython_list_new_empty():
def main(argv):
def new_empty():
a = []
c_exit(rffi.cast(rffi.INT, len(a)))
return 0
res = run_boot_image(main, '/tmp/test_rpython_list_new_empty')
assert res.returncode == 0, res.err
return a
fn, (db, bdlgen) = fncptr_from_rpy_func(new_empty, [], lltype.Void)
bdlgen.mu.current_thread_as_mu_thread(rmu.null(rmu.MuCPtr))
fn()
@may_spawn_proc
def test_rpython_list_new_5():
def main(argv):
def new_5():
a = [1, 2, 3, 4, 5]
c_exit(rffi.cast(rffi.INT, len(a)))
return 0
res = run_boot_image(main, '/tmp/test_rpython_list_new_5')
assert res.returncode == 5, res.err
return len(a)
fn, (db, bdlgen) = fncptr_from_rpy_func(new_5, [], rffi.INT)
bdlgen.mu.current_thread_as_mu_thread(rmu.null(rmu.MuCPtr))
assert fn() == 5
@may_spawn_proc
def test_rpython_list_append():
......@@ -37,12 +37,12 @@ def test_rpython_list_append():
a = []
for i in range(0, 10):
a.append(i)
c_exit(rffi.cast(rffi.INT, len(a)))
return 0
res = run_boot_image(main, '/tmp/test_rpython_list_append')
assert res.returncode == 10, 'returncode = %d\n%s' % (res.returncode, res.err)
@may_spawn_proc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment