1 //
2 // Copyright (c) 2021 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include "testBase.h"
18
test_negative_get_platform_ids(cl_device_id deviceID,cl_context context,cl_command_queue queue,int num_elements)19 int test_negative_get_platform_ids(cl_device_id deviceID, cl_context context,
20 cl_command_queue queue, int num_elements)
21 {
22 cl_platform_id platform;
23 cl_int err = clGetPlatformIDs(0, &platform, nullptr);
24 test_failure_error_ret(
25 err, CL_INVALID_VALUE,
26 "clGetPlatformIDs should return CL_INVALID_VALUE when: \"num_entries "
27 "is equal to zero and platforms is not NULL\"",
28 TEST_FAIL);
29
30 err = clGetPlatformIDs(1, nullptr, nullptr);
31 test_failure_error_ret(
32 err, CL_INVALID_VALUE,
33 "clGetPlatformIDs should return CL_INVALID_VALUE when: \"both "
34 "num_platforms and platforms are NULL\"",
35 TEST_FAIL);
36
37 return TEST_PASS;
38 }
39
test_negative_get_platform_info(cl_device_id deviceID,cl_context context,cl_command_queue queue,int num_elements)40 int test_negative_get_platform_info(cl_device_id deviceID, cl_context context,
41 cl_command_queue queue, int num_elements)
42 {
43 cl_platform_id platform = getPlatformFromDevice(deviceID);
44
45 cl_int err =
46 clGetPlatformInfo(reinterpret_cast<cl_platform_id>(deviceID),
47 CL_PLATFORM_VERSION, sizeof(char*), nullptr, nullptr);
48 test_failure_error_ret(
49 err, CL_INVALID_PLATFORM,
50 "clGetPlatformInfo should return CL_INVALID_PLATFORM when: \"platform "
51 "is not a valid platform\" using a valid object which is NOT a "
52 "platform",
53 TEST_FAIL);
54
55 constexpr cl_platform_info INVALID_PARAM_VALUE = 0;
56 err = clGetPlatformInfo(platform, INVALID_PARAM_VALUE, 0, nullptr, nullptr);
57 test_failure_error_ret(
58 err, CL_INVALID_VALUE,
59 "clGetPlatformInfo should return CL_INVALID_VALUE when: \"param_name "
60 "is not one of the supported values\"",
61 TEST_FAIL);
62
63 char* version;
64 err =
65 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, &version, nullptr);
66 test_failure_error_ret(
67 err, CL_INVALID_VALUE,
68 "clGetPlatformInfo should return CL_INVALID_VALUE when: \"size in "
69 "bytes specified by param_value_size is < size of return type and "
70 "param_value is not a NULL value\"",
71 TEST_FAIL);
72
73 return TEST_PASS;
74 }
75