GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

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

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