Commit f5449b1a authored by John Zhang's avatar John Zhang

refactor

parent 09c2ba88
Pipeline #11 failed with stage
in 60 minutes and 9 seconds
def test_add():
src_c = "suite/test_add.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
from test_harness import get_fncptr
def test_add():
fn = get_fncptr("suite/test_add.c", "test_fnc")
assert fn() == 9
def test_sub():
src_c = "suite/test_sub.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_sub.c", "test_fnc")
assert fn() == 11
def test_mul():
src_c = "suite/test_mul.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_mul.c", "test_fnc")
assert fn() == 0xf6
def test_sdiv():
src_c = "suite/test_sdiv.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_sdiv.c", "test_fnc")
assert fn() == 0xf4
def test_urem():
src_c = "suite/test_urem.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_urem.c", "test_fnc")
assert fn() == 5
def test_shl():
src_c = "suite/test_shl.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_shl.c", "test_fnc")
assert fn() == 0x7e707560c92d5400
def test_lshr():
src_c = "suite/test_shr.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_lshr.c", "test_fnc")
assert fn() == 0x2367e707560c92
def test_and():
src_c = "suite/test_and.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_and.c", "test_fnc")
assert fn() == 0x8588901c10004b14
def test_xor():
src_c = "suite/test_xor.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_xor.c", "test_fnc")
assert fn() == 0x58376ec3e83fa0e1
......@@ -38,20 +38,14 @@ def get_lib(src_c):
return out.strip()
def test_constant_function():
src_c = "suite/test_constfunc.c"
entry_fnc = "test_fnc"
def get_fncptr(src_c, entry_fnc):
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
return getattr(lib, entry_fnc)
def test_constant_function():
fn = get_fncptr("suite/test_constfunc.c", "test_fnc")
assert fn() == 0
def test_factorial():
src_c = "suite/test_fib.c"
entry_fnc = "fib"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
fn = get_fncptr("suite/test_fib.c", "fib")
assert fn(20) == 6765
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