diff --git a/test/test_wrapper.py b/test/test_wrapper.py index 8f86ff1788145be449728c2b0d04b8ff391c2e6c..ba6c90f1c9ee31ace43b67021387250b51a0d194 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -707,6 +707,23 @@ def test_buffer_get_host_array(ctx_factory): host_buf.__array_interface__['data'][0]) assert host_buf2.base is buf + try: + buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, size=100) + host_buf2 = buf.get_host_array(25, np.float32) + assert False, ("MemoryObject.get_host_array should not accept buffer " + "without USE_HOST_PTR") + except cl.LogicError: + pass + + try: + host_buf = np.random.rand(25).astype(np.float32) + buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=host_buf) + host_buf2 = buf.get_host_array(25, np.float32) + assert False, ("MemoryObject.get_host_array should not accept buffer " + "without USE_HOST_PTR") + except cl.LogicError: + pass + if __name__ == "__main__": # make sure that import failures get reported, instead of skipping the tests. import pyopencl # noqa