cl: Add imperfect CL_DEVICE_OPENCL_C_VERSION check
[piglit.git] / tests / cl / api / get-command-queue-info.c
blob3ea87800bd306ff180d7f1c6b5b6db9b0511c2fa
1 /*
2 * Copyright © 2012 Blaž Tomažič <blaz.tomazic@gmail.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 /**
25 * @file get-command-queue-info.c
27 * Test API function:
29 * cl_int clGetCommandQueueInfo (cl_command_queue command_queue,
30 * cl_command_queue_info param_name,
31 * size_t param_value_size,
32 * void *param_value,
33 * size_t param_value_size_ret)
36 #include "piglit-framework-cl-api.h"
39 PIGLIT_CL_API_TEST_CONFIG_BEGIN
41 config.name = "clGetCommandQueueInfo";
42 config.version_min = 10;
44 config.run_per_device = true;
45 config.create_context = true;
47 PIGLIT_CL_API_TEST_CONFIG_END
50 enum piglit_result
51 piglit_cl_test(const int argc,
52 const char** argv,
53 const struct piglit_cl_api_test_config* config,
54 const struct piglit_cl_api_test_env* env)
56 enum piglit_result result = PIGLIT_PASS;
58 int i;
59 cl_int errNo;
60 cl_command_queue command_queue = env->context->command_queues[0];
62 size_t param_value_size;
63 void* param_value;
65 int num_command_queue_infos =
66 PIGLIT_CL_ENUM_NUM(cl_command_queue_info, env->version);
67 const cl_command_queue_info *command_queue_infos =
68 PIGLIT_CL_ENUM_ARRAY(cl_command_queue_info);
70 /*** Normal usage ***/
72 for(i = 0; i < num_command_queue_infos; i++) {
73 printf("%s ", piglit_cl_get_enum_name(command_queue_infos[i]));
75 errNo = clGetCommandQueueInfo(command_queue,
76 command_queue_infos[i],
78 NULL,
79 &param_value_size);
80 if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
81 fprintf(stderr,
82 "Failed (error code: %s): Get size of %s.\n",
83 piglit_cl_get_error_name(errNo),
84 piglit_cl_get_enum_name(command_queue_infos[i]));
85 piglit_merge_result(&result, PIGLIT_FAIL);
86 continue;
89 param_value = malloc(param_value_size);
90 errNo = clGetCommandQueueInfo(command_queue,
91 command_queue_infos[i],
92 param_value_size,
93 param_value,
94 NULL);
95 if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
96 fprintf(stderr,
97 "Failed (error code: %s): Get value of %s.\n",
98 piglit_cl_get_error_name(errNo),
99 piglit_cl_get_enum_name(command_queue_infos[i]));
100 piglit_merge_result(&result, PIGLIT_FAIL);
103 //TODO: output returned values
104 printf("\n");
105 free(param_value);
108 /*** Errors ***/
111 * CL_INVALID_VALUE if param_name is not one of the supported
112 * values or if size in bytes specified by param_value_size is
113 * less than size of return type and param_value is not a NULL
114 * value.
116 errNo = clGetCommandQueueInfo(command_queue,
117 CL_PLATFORM_NAME,
119 NULL,
120 &param_value_size);
121 if(!piglit_cl_check_error(errNo, CL_INVALID_VALUE)) {
122 fprintf(stderr,
123 "Failed (error code: %s): Trigger CL_INVALID_VALUE if param_name is not one of the supported values.\n",
124 piglit_cl_get_error_name(errNo));
125 piglit_merge_result(&result, PIGLIT_FAIL);
128 errNo = clGetCommandQueueInfo(command_queue,
129 CL_QUEUE_REFERENCE_COUNT,
131 param_value,
132 NULL);
133 if(!piglit_cl_check_error(errNo, CL_INVALID_VALUE)) {
134 fprintf(stderr,
135 "Failed (error code: %s): Trigger CL_INVALID_VALUE if size in bytes specified by param_value is less than size of return type and param_value is not a NULL value.\n",
136 piglit_cl_get_error_name(errNo));
137 piglit_merge_result(&result, PIGLIT_FAIL);
141 * CL_INVALID_COMMAND_QUEUE if command_queue is not a valid command queue.
143 errNo = clGetCommandQueueInfo(NULL,
144 CL_QUEUE_CONTEXT,
146 NULL,
147 &param_value_size);
148 if(!piglit_cl_check_error(errNo, CL_INVALID_COMMAND_QUEUE)) {
149 fprintf(stderr,
150 "Failed (error code: %s): Trigger CL_INVALID_COMMAND_QUEUE if command_queue is not a valid command queue.\n",
151 piglit_cl_get_error_name(errNo));
152 piglit_merge_result(&result, PIGLIT_FAIL);
156 return result;