From 7d9ecaaf737575475b636fbf36b8e8925e8104e1 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:47:01 +0000 Subject: [PATCH] Migrate vectors suite to the new test registration framework (#2190) Contributes to #2181 --- test_conformance/vectors/main.cpp | 25 +--------- test_conformance/vectors/procs.h | 54 --------------------- test_conformance/vectors/testBase.h | 2 - test_conformance/vectors/test_step.cpp | 20 +++----- test_conformance/vectors/test_vec_align.cpp | 29 +++++------ 5 files changed, 22 insertions(+), 108 deletions(-) delete mode 100644 test_conformance/vectors/procs.h diff --git a/test_conformance/vectors/main.cpp b/test_conformance/vectors/main.cpp index e499faf9..6e7c6d48 100644 --- a/test_conformance/vectors/main.cpp +++ b/test_conformance/vectors/main.cpp @@ -13,32 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "harness/compat.h" -#include -#include -#include "procs.h" #include "harness/testHarness.h" -#if !defined(_WIN32) -#include -#endif - -test_definition test_list[] = { - ADD_TEST(step_type), - ADD_TEST(step_var), - ADD_TEST(step_typedef_type), - ADD_TEST(step_typedef_var), - ADD_TEST(vec_align_array), - ADD_TEST(vec_align_struct), - ADD_TEST(vec_align_packed_struct), - ADD_TEST(vec_align_struct_arr), - ADD_TEST(vec_align_packed_struct_arr), -}; - -const int test_num = ARRAY_SIZE(test_list); - int main(int argc, const char *argv[]) { - return runTestHarness(argc, argv, test_num, test_list, false, 0); + return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0); } diff --git a/test_conformance/vectors/procs.h b/test_conformance/vectors/procs.h deleted file mode 100644 index 7a6dba41..00000000 --- a/test_conformance/vectors/procs.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// Copyright (c) 2017 The Khronos Group Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#include "harness/errorHelpers.h" -#include "harness/kernelHelpers.h" -#include "harness/typeWrappers.h" -#include "harness/conversions.h" -#include "harness/mt19937.h" - -// The number of errors to print out for each test in the shuffle tests -#define MAX_ERRORS_TO_PRINT 1 - - -extern int create_program_and_kernel(const char *source, - const char *kernel_name, - cl_program *program_ret, - cl_kernel *kernel_ret); - -extern int test_step_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_step_var(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_step_typedef_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_step_typedef_var(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -int test_vec_align_array(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -int test_vec_align_struct(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - - -int test_vec_align_struct_arr(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -int test_vec_align_packed_struct_arr(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); diff --git a/test_conformance/vectors/testBase.h b/test_conformance/vectors/testBase.h index 63086d7e..a358b81a 100644 --- a/test_conformance/vectors/testBase.h +++ b/test_conformance/vectors/testBase.h @@ -23,6 +23,4 @@ #include #include -#include "procs.h" - #endif // _testBase_h diff --git a/test_conformance/vectors/test_step.cpp b/test_conformance/vectors/test_step.cpp index 4549cf1e..1aa2e29d 100644 --- a/test_conformance/vectors/test_step.cpp +++ b/test_conformance/vectors/test_step.cpp @@ -222,30 +222,26 @@ static const char* patterns[] = { test_step_typedef_var, */ -int test_step_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(step_type) { - return test_step_internal(deviceID, context, queue, patterns[0], + return test_step_internal(device, context, queue, patterns[0], "test_step_type"); } -int test_step_var(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(step_var) { - return test_step_internal(deviceID, context, queue, patterns[1], + return test_step_internal(device, context, queue, patterns[1], "test_step_var"); } -int test_step_typedef_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(step_typedef_type) { - return test_step_internal(deviceID, context, queue, patterns[2], + return test_step_internal(device, context, queue, patterns[2], "test_step_typedef_type"); } -int test_step_typedef_var(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(step_typedef_var) { - return test_step_internal(deviceID, context, queue, patterns[3], + return test_step_internal(device, context, queue, patterns[3], "test_step_typedef_var"); } diff --git a/test_conformance/vectors/test_vec_align.cpp b/test_conformance/vectors/test_vec_align.cpp index 6c0d48b5..36fc6c47 100644 --- a/test_conformance/vectors/test_vec_align.cpp +++ b/test_conformance/vectors/test_vec_align.cpp @@ -352,8 +352,7 @@ size_t post_align_arr[] = { 0, sizeof(cl_char), size_t type_multiple_post_align_arr[] = { 0, 0, 3, 5, 4, 12 }; // there hsould be a packed version of this? -int test_vec_align_array(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_array) { char tmp[2048]; int result; @@ -361,14 +360,13 @@ int test_vec_align_array(cl_device_id deviceID, cl_context context, log_info("Testing global\n"); doReplace(tmp, (size_t)2048, patterns[0], ".SRC_SCOPE.", "__global", ".DST_SCOPE.", "__global"); // - result = test_vec_internal(deviceID, context, queue, tmp, + result = test_vec_internal(device, context, queue, tmp, "test_vec_align_array", BUFFER_SIZE, 0, 0, 0, 0); return result; } -int test_vec_align_struct(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_struct) { char tmp1[2048], tmp2[2048]; int result = 0; @@ -387,7 +385,7 @@ int test_vec_align_struct(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = - test_vec_internal(deviceID, context, queue, tmp1, + test_vec_internal(device, context, queue, tmp1, "test_vec_align_struct", 512, 0, 0, 0, 0); if (result != 0) { @@ -409,7 +407,7 @@ int test_vec_align_struct(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = - test_vec_internal(deviceID, context, queue, tmp1, + test_vec_internal(device, context, queue, tmp1, "test_vec_align_struct", 512, 0, 0, 0, 0); if (result != 0) { @@ -420,8 +418,7 @@ int test_vec_align_struct(cl_device_id deviceID, cl_context context, return 0; } -int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_packed_struct) { char tmp1[2048], tmp2[2048]; int result = 0; @@ -441,7 +438,7 @@ int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = test_vec_internal( - deviceID, context, queue, tmp1, "test_vec_align_packed_struct", + device, context, queue, tmp1, "test_vec_align_packed_struct", 512, pre_align_arr[preIdx], type_multiple_pre_align_arr[preIdx], post_align_arr[postIdx], type_multiple_post_align_arr[postIdx]); if (result != 0) @@ -464,7 +461,7 @@ int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = test_vec_internal( - deviceID, context, queue, tmp1, "test_vec_align_packed_struct", + device, context, queue, tmp1, "test_vec_align_packed_struct", 512, pre_align_arr[preIdx], type_multiple_pre_align_arr[preIdx], post_align_arr[postIdx], type_multiple_post_align_arr[postIdx]); if (result != 0) @@ -476,8 +473,7 @@ int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, return 0; } -int test_vec_align_struct_arr(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_struct_arr) { char tmp1[2048], tmp2[2048]; int result = 0; @@ -496,7 +492,7 @@ int test_vec_align_struct_arr(cl_device_id deviceID, cl_context context, pre_substitution_arr[preIdx], ".POST.", post_substitution_arr[postIdx]); - result = test_vec_internal(deviceID, context, queue, tmp1, + result = test_vec_internal(device, context, queue, tmp1, "test_vec_align_struct_arr", BUFFER_SIZE, 0, 0, 0, 0); if (result != 0) @@ -508,8 +504,7 @@ int test_vec_align_struct_arr(cl_device_id deviceID, cl_context context, return 0; } -int test_vec_align_packed_struct_arr(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_packed_struct_arr) { char tmp1[2048], tmp2[2048]; int result = 0; @@ -529,7 +524,7 @@ int test_vec_align_packed_struct_arr(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = test_vec_internal( - deviceID, context, queue, tmp1, + device, context, queue, tmp1, "test_vec_align_packed_struct_arr", BUFFER_SIZE, pre_align_arr[preIdx], type_multiple_pre_align_arr[preIdx], post_align_arr[postIdx], type_multiple_post_align_arr[postIdx]);