mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
Modify makro HWTEST2_F and HWTEST2_P
to not call SetUp and TearDown when not matched Change-Id: I00b43a738fa3b33ba743f4f92f8ee16674bf9a50 Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
@@ -85,7 +85,7 @@ set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_F
|
||||
target_include_directories(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${ENGINE_NODE_DIR}
|
||||
${NEO_SHARED_TEST_DIRECTORY}/unit_test/test_macros${BRANCH_DIR_SUFFIX}
|
||||
${NEO_SHARED_TEST_DIRECTORY}/unit_test/test_macros/header${BRANCH_DIR_SUFFIX}
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
set(NEO_CORE_test_macros
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/header${BRANCH_DIR_SUFFIX}/test.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_checks_shared.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_checks_shared.h
|
||||
)
|
||||
|
||||
@@ -231,7 +231,21 @@ extern GFXCORE_FAMILY renderCoreFamily;
|
||||
template <unsigned int matcherOrdinal> \
|
||||
void checkForMatch(PRODUCT_FAMILY matchProduct); \
|
||||
\
|
||||
template <unsigned int matcherOrdinal> \
|
||||
bool checkMatch(PRODUCT_FAMILY matchProduct); \
|
||||
\
|
||||
void SetUp() override { \
|
||||
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
|
||||
parent_class::SetUp(); \
|
||||
} \
|
||||
} \
|
||||
void TearDown() override { \
|
||||
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
|
||||
parent_class::TearDown(); \
|
||||
} \
|
||||
} \
|
||||
void TestBody() override; \
|
||||
\
|
||||
static ::testing::TestInfo *const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)); \
|
||||
}; \
|
||||
@@ -276,6 +290,32 @@ extern GFXCORE_FAMILY renderCoreFamily;
|
||||
MatcherFalse>::type; \
|
||||
Matcher::template matched<productFamily>(); \
|
||||
} \
|
||||
} \
|
||||
template <unsigned int matcherOrdinal> \
|
||||
bool GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)::checkMatch(PRODUCT_FAMILY matchProduct) { \
|
||||
const PRODUCT_FAMILY productFamily = At<ContainerType, matcherOrdinal>::productFamily; \
|
||||
\
|
||||
if (matchProduct == productFamily) { \
|
||||
const bool isMatched = MatcherType::isMatched<productFamily>(); \
|
||||
return isMatched; \
|
||||
} else { \
|
||||
return checkMatch<matcherOrdinal - 1u>(matchProduct); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
bool GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)::checkMatch<0>(PRODUCT_FAMILY matchProduct) { \
|
||||
const int matcherOrdinal = 0u; \
|
||||
const PRODUCT_FAMILY productFamily = At<ContainerType, matcherOrdinal>::productFamily; \
|
||||
\
|
||||
if (matchProduct == productFamily) { \
|
||||
const bool isMatched = MatcherType::isMatched<productFamily>(); \
|
||||
return isMatched; \
|
||||
} else { \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody() { \
|
||||
@@ -600,7 +640,21 @@ extern GFXCORE_FAMILY renderCoreFamily;
|
||||
template <unsigned int matcherOrdinal> \
|
||||
void checkForMatch(PRODUCT_FAMILY matchProduct); \
|
||||
\
|
||||
virtual void TestBody(); \
|
||||
template <unsigned int matcherOrdinal> \
|
||||
bool checkMatch(PRODUCT_FAMILY matchProduct); \
|
||||
\
|
||||
void SetUp() override { \
|
||||
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
|
||||
test_suite_name::SetUp(); \
|
||||
} \
|
||||
} \
|
||||
void TearDown() override { \
|
||||
if (checkMatch<SupportedProductFamilies::size - 1u>(::productFamily)) { \
|
||||
test_suite_name::TearDown(); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void TestBody() override; \
|
||||
\
|
||||
static int AddToRegistry() { \
|
||||
::testing::UnitTest::GetInstance() \
|
||||
@@ -647,6 +701,32 @@ extern GFXCORE_FAMILY renderCoreFamily;
|
||||
MatcherFalse>::type; \
|
||||
Matcher::template matched<productFamily>(); \
|
||||
} \
|
||||
} \
|
||||
template <unsigned int matcherOrdinal> \
|
||||
bool GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)::checkMatch(PRODUCT_FAMILY matchProduct) { \
|
||||
const PRODUCT_FAMILY productFamily = At<ContainerType, matcherOrdinal>::productFamily; \
|
||||
\
|
||||
if (matchProduct == productFamily) { \
|
||||
const bool isMatched = MatcherType::isMatched<productFamily>(); \
|
||||
return isMatched; \
|
||||
} else { \
|
||||
return checkMatch<matcherOrdinal - 1u>(matchProduct); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
bool GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)::checkMatch<0>(PRODUCT_FAMILY matchProduct) { \
|
||||
const int matcherOrdinal = 0u; \
|
||||
const PRODUCT_FAMILY productFamily = At<ContainerType, matcherOrdinal>::productFamily; \
|
||||
\
|
||||
if (matchProduct == productFamily) { \
|
||||
const bool isMatched = MatcherType::isMatched<productFamily>(); \
|
||||
return isMatched; \
|
||||
} else { \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody() { \
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "shared/test/unit_test/test_macros/test_checks_shared.h"
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/test/unit_test/helpers/default_hw_info.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
@@ -20,3 +23,27 @@ bool TestChecks::supportsSvm(const std::unique_ptr<HardwareInfo> &pHardwareInfo)
|
||||
bool TestChecks::supportsSvm(const Device *pDevice) {
|
||||
return supportsSvm(&pDevice->getHardwareInfo());
|
||||
}
|
||||
|
||||
class TestMacrosIfNotMatchTearDownCall : public ::testing::Test {
|
||||
public:
|
||||
void expectCorrectPlatform() {
|
||||
EXPECT_EQ(IGFX_SKYLAKE, NEO::defaultHwInfo->platform.eProductFamily);
|
||||
}
|
||||
void SetUp() override {
|
||||
expectCorrectPlatform();
|
||||
}
|
||||
void TearDown() override {
|
||||
expectCorrectPlatform();
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST2_F(TestMacrosIfNotMatchTearDownCall, givenNotMatchPlatformWhenUseHwTest2FThenSetUpAndTearDownAreNotCalled, IsSKL) {
|
||||
expectCorrectPlatform();
|
||||
}
|
||||
class TestMacrosWithParamIfNotMatchTearDownCall : public TestMacrosIfNotMatchTearDownCall, public ::testing::WithParamInterface<int> {};
|
||||
HWTEST2_P(TestMacrosWithParamIfNotMatchTearDownCall, givenNotMatchPlatformWhenUseHwTest2PThenSetUpAndTearDownAreNotCalled, IsSKL) {
|
||||
expectCorrectPlatform();
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(givenNotMatchPlatformWhenUseHwTest2PThenSetUpAndTearDownAreNotCalled,
|
||||
TestMacrosWithParamIfNotMatchTearDownCall,
|
||||
::testing::Values(0));
|
||||
Reference in New Issue
Block a user