diff --git a/python/test/test_all.py b/python/test/test_all.py index c2698907..1f8a3851 100644 --- a/python/test/test_all.py +++ b/python/test/test_all.py @@ -88,3 +88,5 @@ def case2(): def test_all(): case1() case2() + +test_all() \ No newline at end of file diff --git a/python/test/test_binding.py b/python/test/test_binding.py new file mode 100644 index 00000000..f016edb1 --- /dev/null +++ b/python/test/test_binding.py @@ -0,0 +1,42 @@ +from ionpy import Node, Builder, Buffer, PortMap, Port, Param, Type, TypeCode +import numpy as np # TODO: rewrite with pure python + +def test_binding(): + + input_port = Port(name='input', type=Type.from_dtype(np.dtype(np.int32)), dim=2) + value41 = Param(key='v', val='41') + + builder = Builder() + builder.set_target(target='host') + builder.with_bb_module(path='ion-bb-test') + + node = builder.add('test_inc_i32x2').set_iport([input_port]).set_param(params=[ value41, ]) + + idata = np.full((4, 4), fill_value=1, dtype=np.int32) + ibuf = Buffer(array=idata) + + odata = np.full((4, 4), fill_value=0, dtype=np.int32) + obuf = Buffer(array=odata) + + + input_port.bind_buffer(ibuf) + output_port = node.get_port(name='output') + output_port.bind_buffer(obuf) + + # First run + builder.run() + + for y in range(4): + for x in range(4): + assert odata[y][x] == 42 + + # Second + for y in range(4): + for x in range(4): + idata[y][x] = 2 + + builder.run() + + for y in range(4): + for x in range(4): + assert odata[y][x] == 43