[RFC] Move logic for test registration to the test harness (#2151)

And use in device_timer suite.

Signed-off-by: Kévin Petit <kpet@free.fr>
This commit is contained in:
Kévin Petit
2024-11-26 17:55:09 +00:00
committed by GitHub
parent df5e87bf97
commit 0a1456d8f9
36 changed files with 307 additions and 352 deletions

View File

@@ -23,13 +23,6 @@
#include <unistd.h>
#endif
#include "procs.h"
test_definition test_list[] = {
ADD_TEST( timer_resolution_queries ),
ADD_TEST( device_and_host_timers ),
};
test_status InitCL(cl_device_id device)
{
auto version = get_device_cl_version(device);
@@ -70,11 +63,10 @@ test_status InitCL(cl_device_id device)
return TEST_PASS;
}
const int test_num = ARRAY_SIZE( test_list );
int main(int argc, const char *argv[])
{
return runTestHarnessWithCheck( argc, argv, test_num, test_list, false, 0, InitCL );
return runTestHarnessWithCheck(
argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0, InitCL);
}

View File

@@ -1,24 +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.
//
#ifndef __PROCS_H__
#define __PROCS_H__
extern int test_device_and_host_timers(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_timer_resolution_queries(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
#endif // #ifndef __PROCS_H__

View File

@@ -17,6 +17,7 @@
#include <CL/cl.h>
#include "harness/errorHelpers.h"
#include "harness/compat.h"
#include "harness/testHarness.h"
#if !defined(_WIN32)
#include "unistd.h" // For "sleep"
@@ -24,7 +25,7 @@
#define ALLOWED_ERROR 0.005f
int test_device_and_host_timers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(device_and_host_timers)
{
int errors = 0;
cl_int result = CL_SUCCESS;
@@ -124,7 +125,7 @@ End:
return errors;
}
int test_timer_resolution_queries(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(timer_resolution_queries)
{
int errors = 0;
cl_int result = CL_SUCCESS;