From 011959221875f213ef60c48837002e6b8f280331 Mon Sep 17 00:00:00 2001 From: Yichao Yu <yyc1992@gmail.com> Date: Mon, 23 Jun 2014 06:10:59 +0800 Subject: [PATCH] test_platform_get_devices --- test/test_wrapper.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_wrapper.py b/test/test_wrapper.py index c7ec91f9..45ca0fc3 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -640,6 +640,24 @@ def test_unload_compiler(platform): skip("Intel proprietary driver does not support unloading compiler") cl.unload_platform_compiler(platform) + +def test_platform_get_devices(platform): + dev_types = [cl.device_type.ACCELERATOR, cl.device_type.ALL, + cl.device_type.CPU, cl.device_type.DEFAULT, cl.device_type.GPU] + try: + if platform._get_cl_version() >= (1, 2): + dev_types.append(cl.device_type.CUSTOM) + except: + pass + for dev_type in dev_types: + devs = platform.get_devices(dev_type) + if dev_type in (cl.device_type.DEFAULT, + cl.device_type.ALL, + getattr(cl.device_type, 'CUSTOM', None)): + continue + for dev in devs: + assert dev.type == dev_type + if __name__ == "__main__": # make sure that import failures get reported, instead of skipping the tests. import pyopencl # noqa -- GitLab