WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.3% of users enabled 2FA.

Commit ac887af7 authored by qinsoon's avatar qinsoon
Browse files

[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