summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDenis Steckelmacher <steckdenis@yahoo.fr>2011-05-19 17:58:56 +0200
committerDenis Steckelmacher <steckdenis@yahoo.fr>2011-05-19 17:58:56 +0200
commit8fe56bcd81198da886ac5916ac76e45cd65e875c (patch)
treef1707e6b50c5cf26a943a4795965e4994e0aba5d /tests
parent802c9f6fd1ed72f73594091c692ad9ed6c054e3e (diff)
Implement clGetDeviceIDs, and a stub of the abstraction layer based on the Device class.
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/test_device.cpp55
-rw-r--r--tests/test_device.h17
-rw-r--r--tests/tests.c2
4 files changed, 76 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 752a991..d8be45d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -4,6 +4,7 @@ LINK_DIRECTORIES(${Coal_BINARY_DIR}/src ${CHECK_LIBRARY_DIRS})
set(OPENCL_TESTS_SOURCE
tests.c
test_platform.cpp
+ test_device.cpp
)
add_executable(tests ${OPENCL_TESTS_SOURCE})
@@ -13,4 +14,4 @@ MACRO(OPENCL_TEST EXECUTABLE_NAME TEST_NAME)
add_test(${TEST_NAME} ${EXECUTABLE_NAME} ${TEST_NAME})
ENDMACRO(OPENCL_TEST)
-OPENCL_TEST(tests platform)
+OPENCL_TEST(tests platform device)
diff --git a/tests/test_device.cpp b/tests/test_device.cpp
new file mode 100644
index 0000000..2be898f
--- /dev/null
+++ b/tests/test_device.cpp
@@ -0,0 +1,55 @@
+#include "test_device.h"
+#include "CL/cl.h"
+
+START_TEST (test_get_device_ids)
+{
+ cl_platform_id platform = 0;
+ cl_device_id device;
+ cl_uint num_devices;
+ cl_int result;
+
+ result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 0, &device, &num_devices);
+ fail_if(
+ result != CL_INVALID_VALUE,
+ "num_entries cannot be NULL when devices is not null"
+ );
+
+ result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 0, 0, &num_devices);
+ fail_if(
+ result != CL_INVALID_VALUE,
+ "num_entires and devices cannot be NULL at the same time"
+ );
+
+ result = clGetDeviceIDs((cl_platform_id)1337, CL_DEVICE_TYPE_CPU, 1, &device, &num_devices);
+ fail_if(
+ result != CL_INVALID_PLATFORM,
+ "1337 is not a valid platform"
+ );
+
+ result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, &num_devices);
+ fail_if(
+ result != CL_DEVICE_NOT_FOUND,
+ "there are no GPU devices currently available"
+ );
+
+ result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, 0, &num_devices);
+ fail_if(
+ result != CL_SUCCESS || num_devices != 1,
+ "we must succeed and say that we have one CPU device"
+ );
+
+ result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &device, &num_devices);
+ fail_if(
+ result != CL_SUCCESS || num_devices != 1 || device == 0,
+ "we must succeed and have one CPU device"
+ );
+}
+END_TEST
+
+TCase *cl_device_tcase_create(void)
+{
+ TCase *tc = NULL;
+ tc = tcase_create("device");
+ tcase_add_test(tc, test_get_device_ids);
+ return tc;
+}
diff --git a/tests/test_device.h b/tests/test_device.h
new file mode 100644
index 0000000..34c2237
--- /dev/null
+++ b/tests/test_device.h
@@ -0,0 +1,17 @@
+#ifndef __UTEST_DEVICE__
+#define __UTEST_DEVICE__
+
+#include <check.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+TCase *cl_device_tcase_create(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/tests/tests.c b/tests/tests.c
index 7fd0291..292b29a 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -1,4 +1,5 @@
#include "test_platform.h"
+#include "test_device.h"
#include <stdlib.h>
#include <stdio.h>
@@ -20,6 +21,7 @@ int main(int argc, char **argv)
}
TESTSUITE(platform, "platform");
+ TESTSUITE(device, "device");
if (s == NULL) {
printf("test case %s does not exist", argv[1]);