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.2% of users enabled 2FA.

Commit 048f3b98 authored by John Zhang's avatar John Zhang
Browse files

modified how things are compiled, where to find the dynamic library; back to using pytest

parent 8b156b16
......@@ -88,8 +88,7 @@ impl MuVM {
func_names.push(func.name().unwrap());
}
backend::emit_context(&self.vm);
let libname = &format!("lib{}.dylib", lib_name);
aot::link_dylib(func_names, libname);
aot::link_dylib(func_names, lib_name);
}
}
......
from test_harness import get_fncptr
from test_milestones import get_fncptr
def test_add():
fn = get_fncptr("suite/test_add.c", "test_fnc")
fn = get_fncptr("test_add", "test_fnc")
assert fn() == 9
def test_sub():
fn = get_fncptr("suite/test_sub.c", "test_fnc")
fn = get_fncptr("test_sub", "test_fnc")
assert fn() == 11
def test_mul():
fn = get_fncptr("suite/test_mul.c", "test_fnc")
fn = get_fncptr("test_mul", "test_fnc")
assert fn() == 0xf6
def test_sdiv():
fn = get_fncptr("suite/test_sdiv.c", "test_fnc")
fn = get_fncptr("test_sdiv", "test_fnc")
assert fn() == 0xf4
def test_urem():
fn = get_fncptr("suite/test_urem.c", "test_fnc")
fn = get_fncptr("test_urem", "test_fnc")
assert fn() == 5
def test_shl():
fn = get_fncptr("suite/test_shl.c", "test_fnc")
fn = get_fncptr("test_shl", "test_fnc")
assert fn() == 0x7e707560c92d5400
def test_lshr():
fn = get_fncptr("suite/test_lshr.c", "test_fnc")
fn = get_fncptr("test_lshr", "test_fnc")
assert fn() == 0x2367e707560c92
def test_and():
fn = get_fncptr("suite/test_and.c", "test_fnc")
fn = get_fncptr("test_and", "test_fnc")
assert fn() == 0x8588901c10004b14
def test_xor():
fn = get_fncptr("suite/test_xor.c", "test_fnc")
fn = get_fncptr("test_xor", "test_fnc")
assert fn() == 0x58376ec3e83fa0e1
from test_harness import get_fncptr
from test_milestones import get_fncptr
def test_eq_int():
fn = get_fncptr("suite/test_eq_int.c", "test_fnc")
fn = get_fncptr("test_eq_int", "test_fnc")
assert fn() == 0
def test_eq_ref():
fn = get_fncptr("suite/test_eq_ref.c", "test_fnc")
fn = get_fncptr("test_eq_ref", "test_fnc")
assert fn() == 0
def test_ne_int():
fn = get_fncptr("suite/test_ne_int.c", "test_fnc")
fn = get_fncptr("test_ne_int", "test_fnc")
assert fn() == 1
def test_ne_ref():
fn = get_fncptr("suite/test_ne_ref.c", "test_fnc")
fn = get_fncptr("test_ne_ref", "test_fnc")
assert fn() == 1
def test_sge():
fn = get_fncptr("suite/test_sge.c", "test_fnc")
fn = get_fncptr("test_sge", "test_fnc")
assert fn() == 1
def test_sgt():
fn = get_fncptr("suite/test_sgt.c", "test_fnc")
fn = get_fncptr("test_sgt", "test_fnc")
assert fn() == 0
def test_sle():
fn = get_fncptr("suite/test_sle.c", "test_fnc")
fn = get_fncptr("test_sle", "test_fnc")
assert fn() == 1
def test_slt():
fn = get_fncptr("suite/test_slt.c", "test_fnc")
fn = get_fncptr("test_slt", "test_fnc")
assert fn() == 0
def test_ult():
fn = get_fncptr("suite/test_ult.c", "test_fnc")
fn = get_fncptr("test_ult", "test_fnc")
assert fn() == 0
......@@ -4,6 +4,7 @@ Harness JIT tests using py.test framework
import subprocess as subp
import os, sys
import ctypes
import py
CC = 'clang'
# CI_PROJ_DIR = os.environ["CI_PROJECT_DIR"]
......@@ -16,9 +17,16 @@ CFLAGS = [
]
os.environ['RUST_BACKTRACE'] = '1'
def get_lib(src_c):
bin_path = src_c[:-2]
cmd = [CC] + CFLAGS + ['-o', bin_path, src_c]
testsuite_dir = py.path.local('suite')
def compile_lib(testname):
src_c = testsuite_dir.join(testname + '.c')
bin_dir = py.path.local('tmp')
if not bin_dir.exists():
bin_dir.mkdir()
bin_path = bin_dir.join(testname)
cmd = [CC] + CFLAGS + ['-o', str(bin_path)] + [str(src_c)]
# compile
p = subp.Popen(cmd, stdout=subp.PIPE, stderr=subp.PIPE, env=os.environ)
......@@ -29,27 +37,29 @@ def get_lib(src_c):
raise subp.CalledProcessError(p.returncode, cmd)
# run
p = subp.Popen([bin_path], stdout=subp.PIPE, stderr=subp.PIPE, env=os.environ)
p = subp.Popen([str(bin_path)], stdout=subp.PIPE, stderr=subp.PIPE,
cwd=str(bin_dir), env=os.environ)
out, err = p.communicate()
if p.returncode != 0: # failed
sys.stdout.write(out + '\n')
sys.stderr.write(err + '\n')
raise subp.CalledProcessError(p.returncode, bin_path)
return out.strip()
return str(bin_dir.join('emit', testname + '.dylib'))
def get_fncptr(src_c, entry_fnc):
lib = ctypes.CDLL(get_lib(src_c))
def get_fncptr(testname, entry_fnc):
lib_path = compile_lib(testname)
lib = ctypes.CDLL(lib_path)
return getattr(lib, entry_fnc)
def test_constant_function():
fn = get_fncptr("suite/test_constfunc.c", "test_fnc")
fn = get_fncptr("test_constfunc", "test_fnc")
assert fn() == 0
def test_fibonacci():
fn = get_fncptr("suite/test_fib.c", "fib")
fn = get_fncptr("test_fib", "fib")
assert fn(20) == 6765
def test_multifunc():
fn = get_fncptr("suite/test_multifunc.c", "entry")
fn = get_fncptr("test_multifunc", "entry")
assert fn() == 6765
\ No newline at end of file
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