cl22: Use single array for function list (#148)

Signed-off-by: Radek Szymanski <radek.szymanski@arm.com>
This commit is contained in:
Radek Szymanski
2019-04-10 12:30:38 +01:00
committed by Kévin Petit
parent 394dece0d7
commit 07196c351a
139 changed files with 2380 additions and 4142 deletions

View File

@@ -17,19 +17,6 @@
#define TEST_COMMON_AUTOTEST_AUTOTEST_HPP
#include "test_suite.hpp"
#include "test_case.hpp"
namespace autotest {
inline std::vector<const char*> get_strings_ptrs(const std::vector<std::string>& list)
{
std::vector<const char*> v;
for(auto& s : list)
{
v.push_back(s.c_str());
}
return v;
}
}
#define STR_JOIN( X, Y ) STR_DO_JOIN( X, Y )
#define STR_DO_JOIN( X, Y ) STR_DO_JOIN_2(X,Y)
@@ -43,13 +30,6 @@ namespace autotest {
// (test case code...)
// }
//
// It automatically registers created test case to global test_suite object. Test functions
// names and pointers to those functions can be later retrieved this way:
// - std::vector<basefn> test_functions_list = autotest::test_suite::get_test_functions();
// - std::vector<std::string> test_functions_names = autotest::test_suite::get_test_names();
//
// Helper function which constructs vector of const char pointers to test functions names:
// - std::vector<const char *> test_functions_names_c_str = autotest::get_strings_ptrs(test_functions_names);
#define AUTO_TEST_CASE(name) \
struct name { static int run_test(cl_device_id, cl_context, cl_command_queue, int); }; \
static autotest::detail::test_case_registration STR_JOIN(name, STR_JOIN(_registration, __LINE__)) (#name, name::run_test); \

View File

@@ -1,41 +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 TEST_COMMON_AUTOTEST_TEST_CASE_HPP
#define TEST_COMMON_AUTOTEST_TEST_CASE_HPP
#include <string>
#include "../../test_common/harness/threadTesting.h"
namespace autotest
{
struct test_case {
// Test case name
const std::string name;
// Pointer to test function.
const basefn function_pointer;
test_case(const std::string& name, const basefn function_ptr)
: name(name), function_pointer(function_ptr)
{
}
};
} // end namespace autotest
#endif // TEST_COMMON_AUTOTEST_TEST_CASE_HPP

View File

@@ -19,8 +19,6 @@
#include <vector>
#include <string>
#include "test_case.hpp"
namespace autotest {
struct test_suite {
@@ -30,33 +28,13 @@ struct test_suite {
}
void add(const test_case& tc)
void add(const test_definition& td)
{
test_cases.push_back(tc);
test_defs.push_back(td);
}
static std::vector<basefn> get_test_functions()
{
std::vector<basefn> v;
for(auto& tc: global_test_suite().test_cases)
{
v.push_back(tc.function_pointer);
}
return v;
}
static std::vector<std::string> get_test_names()
{
std::vector<std::string> v;
for(auto& tc : global_test_suite().test_cases)
{
v.push_back(tc.name);
}
return v;
}
// List of test cases
std::vector<test_case> test_cases;
// List of test definitions
std::vector<test_definition> test_defs;
// Test suite name
const std::string name;
@@ -73,7 +51,7 @@ struct test_case_registration
{
test_case_registration(const std::string& name, const basefn ptr)
{
::autotest::test_suite::global_test_suite().add(test_case(name, ptr));
::autotest::test_suite::global_test_suite().add(test_definition({ptr, name.c_str()}));
}
};