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.

Commit 7d1fb272 authored by John Zhang's avatar John Zhang
Browse files

tests involving RPython added

parent 5b723a45
......@@ -67,4 +67,20 @@ testjit:cmpops:
testjit:convops:
stage: test
script:
- RUST_BACKTRACE=1 pytest tests/test_jit/test_convops.py
\ No newline at end of file
- RUST_BACKTRACE=1 pytest tests/test_jit/test_convops.py
testjit:rpython:
stage: test
script:
- git clone https://gitlab.anu.edu.au/mu/mu-client-pypy.git tests/test_jit/mu-client-pypy
- cd tests/test_jit/mu-client-pypy/rpython/translator/mu/rpyc; make
- cd ../../../../
- RUST_BACKTRACE=1 PYTHONPATH=mu-client-pypy python test_rpython.py
cache:
key: "$CI_BUILD_STAGE/$CI_BUILD_REF_NAME"
paths:
- .cargo/registry/cache
- .cargo/registry/index
- target
- Cargo.lock
- tests/test_jit/mu-client-pypy
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.translator.interactive import Translation
import ctypes
def test_add():
def add(a, b):
return a + b
t = Translation(add, [rffi.ULONGLONG, rffi.ULONGLONG],
backend='mu', muimpl='fast', mucodegen='api', mutestjit=True)
db, bdlgen, fnc_name = t.compile_mu()
bdlgen.mu.compile_to_sharedlib('libtesting.dylib', [])
lib = ctypes.CDLL('emit/libtesting.dylib')
fnc = getattr(lib, fnc_name)
assert fnc(1, 2) == 3
def test_find_min():
def find_min(xs, sz):
m = xs[0]
for i in range(1, sz):
x = xs[i]
if x < m:
m = x
return m
t = Translation(find_min, [rffi.CArrayPtr(rffi.LONGLONG), rffi.INT],
backend='mu', muimpl='fast', mucodegen='api', mutestjit=True)
db, bdlgen, fnc_name = t.compile_mu()
bdlgen.mu.compile_to_sharedlib('libtesting.dylib', [])
lib = ctypes.CDLL('emit/libtesting.dylib')
fnc = getattr(lib, fnc_name)
lst = [23, 100, 0, 78, -5]
arr = lltype.malloc(rffi.CArray(rffi.LONGLONG), 5, flavor='raw')
for i, n in enumerate(lst):
arr[i] = n
assert fnc(arr, 5) == -5
lltype.free(arr, flavor='raw')
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('testfnc', help="Test function name")
opts = parser.parse_args()
globals()[opts.testfnc]()
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