Update test exclude macros

Unify exclude macros and respect them in all custom test macros.


Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2021-06-29 22:20:34 +00:00
committed by Compute-Runtime-Automation
parent 50490feaf2
commit 6fb1be80c8
12 changed files with 205 additions and 169 deletions

View File

@@ -45,6 +45,8 @@ set(igdrcl_libult_common_SRCS_LIB_ULT
${NEO_SHARED_TEST_DIRECTORY}/common/libult/source_level_debugger_library.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/libult/source_level_debugger_library.h
${NEO_SHARED_TEST_DIRECTORY}/common/libult/source_level_debugger_ult.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/test_excludes.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/test_excludes.h
${NEO_SHARED_TEST_DIRECTORY}/unit_test/base_ult_config_listener.cpp
${NEO_SHARED_TEST_DIRECTORY}/unit_test/base_ult_config_listener.h
${NEO_SHARED_TEST_DIRECTORY}/unit_test/helpers/debug_helpers.cpp

View File

@@ -7,16 +7,13 @@
#pragma once
#include "shared/source/helpers/hw_info.h"
#include "shared/test/common/test_macros/test_excludes.h"
#include "gtest/gtest.h"
#include "hw_cmds.h"
#include "igfxfmid.h"
#include "test_mode.h"
#include <cstdint>
#include <memory>
#include <unordered_set>
extern PRODUCT_FAMILY productFamily;
extern GFXCORE_FAMILY renderCoreFamily;
@@ -77,6 +74,16 @@ extern GFXCORE_FAMILY renderCoreFamily;
#define CHECK_TEST_NAME_LENGTH(test_fixture, test_name) \
CHECK_TEST_NAME_LENGTH_WITH_MAX(test_fixture, test_name, TEST_MAX_LENGTH)
#define HWTEST_EXCLUDE_PRODUCT(test_suite_name, test_name, family) \
struct test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family { \
test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family() { \
NEO::TestExcludes::addTestExclude(#test_suite_name #test_name, family); \
} \
} test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family##_init;
#define IS_TEST_EXCLUDED(test_suite_name, test_name) \
NEO::TestExcludes::isTestExcluded(#test_suite_name #test_name, ::productFamily)
#ifdef TEST_F
#undef TEST_F
#endif
@@ -125,20 +132,6 @@ extern GFXCORE_FAMILY renderCoreFamily;
// Test can use FamilyType in the test -- equivalent to SKLFamily
#define HWTEST_TEST_(test_suite_name, test_name, parent_class, parent_id, SetUpT_name, TearDownT_name) \
CHECK_TEST_NAME_LENGTH(test_suite_name, test_name) \
class PLATFORM_EXCLUDES_CLASS_NAME(test_suite_name, test_name) { \
public: \
static std::unique_ptr<std::unordered_set<uint32_t>> &getExcludes() { \
static std::unique_ptr<std::unordered_set<uint32_t>> excludes; \
return excludes; \
} \
static void addExclude(uint32_t product) { \
auto &excludes = getExcludes(); \
if (excludes == nullptr) { \
excludes = std::make_unique<std::unordered_set<uint32_t>>(); \
} \
excludes->insert(product); \
} \
}; \
\
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) : public parent_class { \
\
@@ -149,31 +142,24 @@ extern GFXCORE_FAMILY renderCoreFamily;
private: \
template <typename FamilyType> \
void testBodyHw(); \
bool notExcluded() const { \
using ExcludesT = PLATFORM_EXCLUDES_CLASS_NAME(test_suite_name, test_name); \
auto &excludes = ExcludesT::getExcludes(); \
if (excludes == nullptr) { \
return true; \
} \
return excludes->count(::productFamily) == 0; \
} \
template <typename T> \
void emptyFcn() {} \
void SetUp() override { \
if (notExcluded()) { \
parent_class::SetUp(); \
FAMILY_SELECTOR(::renderCoreFamily, SetUpT_name) \
if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
GTEST_SKIP(); \
} \
parent_class::SetUp(); \
FAMILY_SELECTOR(::renderCoreFamily, SetUpT_name); \
} \
void TearDown() override { \
if (notExcluded()) { \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
FAMILY_SELECTOR(::renderCoreFamily, TearDownT_name) \
parent_class::TearDown(); \
} \
} \
\
void TestBody() override { \
if (notExcluded()) { \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
FAMILY_SELECTOR(::renderCoreFamily, testBodyHw) \
} \
} \
@@ -202,6 +188,8 @@ extern GFXCORE_FAMILY renderCoreFamily;
// Macros to provide template based testing.
// Test can use productFamily, gfxCoreFamily and FamilyType in the test
#define HWTEST2_TEST_(test_suite_name, test_name, parent_class, parent_id, test_matcher) \
CHECK_TEST_NAME_LENGTH(test_suite_name, test_name) \
\
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) : public parent_class { \
\
public: \
@@ -311,18 +299,24 @@ extern GFXCORE_FAMILY renderCoreFamily;
} \
\
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::SetUp() { \
if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
GTEST_SKIP(); \
} \
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
parent_class::SetUp(); \
} \
} \
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TearDown() { \
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
parent_class::TearDown(); \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
parent_class::TearDown(); \
} \
} \
} \
\
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody() { \
checkForMatch<SupportedProductFamilies::size - 1u>(::productFamily); \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
checkForMatch<SupportedProductFamilies::size - 1u>(::productFamily); \
} \
} \
\
template <PRODUCT_FAMILY productFamily, GFXCORE_FAMILY gfxCoreFamily, typename FamilyType> \
@@ -336,9 +330,6 @@ extern GFXCORE_FAMILY renderCoreFamily;
HWTEST_TEST_(test_fixture, test_name, test_fixture, \
::testing::internal::GetTypeId<test_fixture>(), SetUpT, TearDownT)
#define PLATFORM_EXCLUDES_CLASS_NAME(test_suite_name, test_name) \
PLATFORM_EXCLUDES_##test_suite_name##test_name
#define CALL_IF_SUPPORTED(cmdSetBase, expression) \
{ \
bool supported = false; \
@@ -368,20 +359,6 @@ extern GFXCORE_FAMILY renderCoreFamily;
// Test can use FamilyType in the test -- equivalent to SKLFamily
#define HWCMDTEST_TEST_(cmdset_gen_base, test_suite_name, test_name, parent_class, parent_id) \
CHECK_TEST_NAME_LENGTH(test_suite_name, test_name) \
class PLATFORM_EXCLUDES_CLASS_NAME(test_suite_name, test_name) { \
public: \
static std::unique_ptr<std::unordered_set<uint32_t>> &getExcludes() { \
static std::unique_ptr<std::unordered_set<uint32_t>> excludes; \
return excludes; \
} \
static void addExclude(uint32_t product) { \
auto &excludes = getExcludes(); \
if (excludes == nullptr) { \
excludes = std::make_unique<std::unordered_set<uint32_t>>(); \
} \
excludes->insert(product); \
} \
}; \
\
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) : public parent_class { \
public: \
@@ -394,20 +371,11 @@ extern GFXCORE_FAMILY renderCoreFamily;
\
template <typename FamilyType, bool ShouldBeTested = FamilyType::supportsCmdSet(cmdset_gen_base)> \
auto runCmdTestHwIfSupported() -> typename std::enable_if<ShouldBeTested>::type { \
if (notExcluded()) { \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
testBodyHw<FamilyType>(); \
} \
} \
\
bool notExcluded() const { \
using ExcludesT = PLATFORM_EXCLUDES_CLASS_NAME(test_suite_name, test_name); \
auto &excludes = ExcludesT::getExcludes(); \
if (excludes == nullptr) { \
return true; \
} \
return excludes->count(::productFamily) == 0; \
} \
\
template <typename FamilyType, bool ShouldBeTested = FamilyType::supportsCmdSet(cmdset_gen_base)> \
auto runCmdTestHwIfSupported() -> typename std::enable_if<false == ShouldBeTested>::type { \
/* do nothing */ \
@@ -417,12 +385,13 @@ extern GFXCORE_FAMILY renderCoreFamily;
FAMILY_SELECTOR(::renderCoreFamily, runCmdTestHwIfSupported) \
} \
void SetUp() override { \
if (notExcluded()) { \
CALL_IF_SUPPORTED(cmdset_gen_base, parent_class::SetUp()); \
if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
GTEST_SKIP(); \
} \
CALL_IF_SUPPORTED(cmdset_gen_base, parent_class::SetUp()); \
} \
void TearDown() override { \
if (notExcluded()) { \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
CALL_IF_SUPPORTED(cmdset_gen_base, parent_class::TearDown()); \
} \
} \
@@ -444,36 +413,6 @@ extern GFXCORE_FAMILY renderCoreFamily;
template <typename FamilyType> \
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::testBodyHw()
#define HWCMDTEST_EXCLUDE_FAMILY(test_suite_name, test_name, family) \
CHECK_TEST_NAME_LENGTH(test_suite_name, test_name) \
class PLATFORM_EXCLUDES_CLASS_NAME(test_suite_name, test_name) { \
public: \
static std::unique_ptr<std::unordered_set<uint32_t>> &getExcludes() { \
static std::unique_ptr<std::unordered_set<uint32_t>> excludes; \
return excludes; \
} \
static void addExclude(uint32_t product) { \
auto &excludes = getExcludes(); \
if (excludes == nullptr) { \
excludes = std::make_unique<std::unordered_set<uint32_t>>(); \
} \
excludes->insert(product); \
} \
}; \
\
struct test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family { \
test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family() { \
PLATFORM_EXCLUDES_CLASS_NAME(test_suite_name, test_name)::addExclude(family); \
} \
} test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family##_init;
#define HWCMDTEST_EXCLUDE_ADDITIONAL_FAMILY(test_suite_name, test_name, family) \
struct test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family { \
test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family() { \
PLATFORM_EXCLUDES_CLASS_NAME(test_suite_name, test_name)::addExclude(family); \
} \
} test_suite_name##test_name##_PLATFORM_EXCLUDES_EXCLUDE_##family##_init;
#define HWCMDTEST_F(cmdset_gen_base, test_fixture, test_name) \
HWCMDTEST_TEST_(cmdset_gen_base, test_fixture, test_name, test_fixture, \
::testing::internal::GetTypeId<test_fixture>())
@@ -488,6 +427,7 @@ extern GFXCORE_FAMILY renderCoreFamily;
#define FAMILYTEST_TEST_(test_suite_name, test_name, parent_class, parent_id, match_core, match_product) \
CHECK_TEST_NAME_LENGTH(test_suite_name, test_name) \
\
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) : public parent_class { \
public: \
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
@@ -498,14 +438,21 @@ extern GFXCORE_FAMILY renderCoreFamily;
void testBodyHw(); \
\
void TestBody() override { \
CALL_IF_MATCH(match_core, match_product, \
testBodyHw<typename NEO::GfxFamilyMapper<match_core>::GfxFamily>()) \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
CALL_IF_MATCH(match_core, match_product, \
testBodyHw<typename NEO::GfxFamilyMapper<match_core>::GfxFamily>()) \
} \
} \
void SetUp() override { \
if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
GTEST_SKIP(); \
} \
CALL_IF_MATCH(match_core, match_product, parent_class::SetUp()) \
} \
void TearDown() override { \
CALL_IF_MATCH(match_core, match_product, parent_class::TearDown()) \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
CALL_IF_MATCH(match_core, match_product, parent_class::TearDown()) \
} \
} \
static ::testing::TestInfo *const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
GTEST_DISALLOW_COPY_AND_ASSIGN_( \
@@ -563,10 +510,12 @@ extern GFXCORE_FAMILY renderCoreFamily;
#define HWCMDTEST_P(cmdset_gen_base, test_suite_name, test_name) \
CHECK_TEST_NAME_LENGTH(test_suite_name, test_name) \
\
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) : public test_suite_name { \
public: \
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
() {} \
\
template <typename FamilyType> \
void testBodyHw(); \
\
@@ -581,13 +530,20 @@ extern GFXCORE_FAMILY renderCoreFamily;
} \
\
void TestBody() override { \
FAMILY_SELECTOR(::renderCoreFamily, runCmdTestHwIfSupported) \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
FAMILY_SELECTOR(::renderCoreFamily, runCmdTestHwIfSupported) \
} \
} \
void SetUp() override { \
if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
GTEST_SKIP(); \
} \
CALL_IF_SUPPORTED(cmdset_gen_base, test_suite_name::SetUp()); \
} \
void TearDown() override { \
CALL_IF_SUPPORTED(cmdset_gen_base, test_suite_name::TearDown()); \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
CALL_IF_SUPPORTED(cmdset_gen_base, test_suite_name::TearDown()); \
} \
} \
\
private: \
@@ -725,18 +681,25 @@ extern GFXCORE_FAMILY renderCoreFamily;
} \
\
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::SetUp() { \
if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
GTEST_SKIP(); \
} \
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
test_suite_name::SetUp(); \
} \
} \
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TearDown() { \
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
test_suite_name::TearDown(); \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
test_suite_name::TearDown(); \
} \
} \
} \
\
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody() { \
checkForMatch<SupportedProductFamilies::size - 1u>(::productFamily); \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
checkForMatch<SupportedProductFamilies::size - 1u>(::productFamily); \
} \
} \
\
int GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::gtest_registering_dummy_ = \
@@ -754,14 +717,21 @@ extern GFXCORE_FAMILY renderCoreFamily;
void testBodyHw(); \
\
void TestBody() override { \
CALL_IF_MATCH(match_core, match_product, \
testBodyHw<typename NEO::GfxFamilyMapper<match_core>::GfxFamily>()) \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
CALL_IF_MATCH(match_core, match_product, \
testBodyHw<typename NEO::GfxFamilyMapper<match_core>::GfxFamily>()) \
} \
} \
void SetUp() override { \
if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
GTEST_SKIP(); \
} \
CALL_IF_MATCH(match_core, match_product, test_suite_name::SetUp()) \
} \
void TearDown() override { \
CALL_IF_MATCH(match_core, match_product, test_suite_name::TearDown()) \
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
CALL_IF_MATCH(match_core, match_product, test_suite_name::TearDown()) \
} \
} \
\
private: \
@@ -996,7 +966,6 @@ using SupportedProductFamilies =
SupportedProductFamilyContainer<SUPPORTED_TEST_PRODUCT_FAMILIES>;
// Static container accessor
template <typename Container, int index>
struct At {
static const PRODUCT_FAMILY productFamily =
@@ -1017,14 +986,6 @@ struct IsGfxCore {
}
};
template <GFXCORE_FAMILY gfxCoreFamily, GFXCORE_FAMILY gfxCoreFamily2>
struct AreNotGfxCores {
template <PRODUCT_FAMILY productFamily>
static constexpr bool isMatched() {
return NEO::ToGfxCoreFamily<productFamily>::get() != gfxCoreFamily && NEO::ToGfxCoreFamily<productFamily>::get() != gfxCoreFamily2;
}
};
template <GFXCORE_FAMILY gfxCoreFamily>
struct IsNotGfxCore {
template <PRODUCT_FAMILY productFamily>
@@ -1033,6 +994,14 @@ struct IsNotGfxCore {
}
};
template <GFXCORE_FAMILY gfxCoreFamily, GFXCORE_FAMILY gfxCoreFamily2>
struct AreNotGfxCores {
template <PRODUCT_FAMILY productFamily>
static constexpr bool isMatched() {
return NEO::ToGfxCoreFamily<productFamily>::get() != gfxCoreFamily && NEO::ToGfxCoreFamily<productFamily>::get() != gfxCoreFamily2;
}
};
template <GFXCORE_FAMILY gfxCoreFamily>
struct IsAtMostGfxCore {
template <PRODUCT_FAMILY productFamily>
@@ -1049,6 +1018,14 @@ struct IsAtLeastGfxCore {
}
};
template <GFXCORE_FAMILY gfxCoreFamilyMin, GFXCORE_FAMILY gfxCoreFamilyMax>
struct IsWithinGfxCore {
template <PRODUCT_FAMILY productFamily>
static constexpr bool isMatched() {
return NEO::ToGfxCoreFamily<productFamily>::get() >= gfxCoreFamilyMin && NEO::ToGfxCoreFamily<productFamily>::get() <= gfxCoreFamilyMax;
}
};
template <PRODUCT_FAMILY product>
struct IsProduct {
template <PRODUCT_FAMILY productFamily>
@@ -1098,6 +1075,7 @@ using IsAtMostGen12lp = IsAtMostGfxCore<IGFX_GEN12LP_CORE>;
using IsAtLeastGen12lp = IsAtLeastGfxCore<IGFX_GEN12LP_CORE>;
using IsADLS = IsProduct<IGFX_ALDERLAKE_S>;
using IsBXT = IsProduct<IGFX_BROXTON>;
using IsCFL = IsProduct<IGFX_COFFEELAKE>;
using IsDG1 = IsProduct<IGFX_DG1>;
@@ -1109,4 +1087,3 @@ using IsLKF = IsProduct<IGFX_LAKEFIELD>;
using IsSKL = IsProduct<IGFX_SKYLAKE>;
using IsTGLLP = IsProduct<IGFX_TIGERLAKE_LP>;
using IsRKL = IsProduct<IGFX_ROCKETLAKE>;
using IsADLS = IsProduct<IGFX_ALDERLAKE_S>;

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/test_macros/test_excludes.h"
#include "shared/source/helpers/debug_helpers.h"
#include <map>
#include <memory>
#include <string>
#include <unordered_set>
using namespace NEO;
static std::unique_ptr<std::map<std::string, std::unordered_set<uint32_t>>> pExcludesPerTest;
bool TestExcludes::isTestExcluded(const char *testName, const uint32_t product) {
if ((pExcludesPerTest == nullptr) || pExcludesPerTest->count(testName) == 0) {
return false;
}
return (pExcludesPerTest->at(testName).count(product) > 0);
}
void TestExcludes::addTestExclude(const char *testName, const uint32_t product) {
if (pExcludesPerTest == nullptr) {
pExcludesPerTest = std::make_unique<std::map<std::string, std::unordered_set<uint32_t>>>();
}
if (pExcludesPerTest->count(testName) == 0) {
pExcludesPerTest->insert(std::make_pair(testName, std::unordered_set<uint32_t>{}));
}
DEBUG_BREAK_IF(pExcludesPerTest->at(testName).count(product) != 0);
pExcludesPerTest->at(testName).insert(product);
}

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <cstdint>
namespace NEO {
namespace TestExcludes {
bool isTestExcluded(const char *testName, const uint32_t product);
void addTestExclude(const char *testName, const uint32_t product);
} // namespace TestExcludes
} // namespace NEO

View File

@@ -12,6 +12,7 @@
#include "test.h"
#include <sstream>
#include <unordered_set>
TEST(ProgramDumper, GivenEmptyProgramThenProperlyCreatesDumpStringWithWarnig) {
NEO::PatchTokenBinary::ProgramFromPatchtokens emptyProgram = {};