diff --git a/unit_tests/gen_common/exclude_tests/exclude_test_declare.cpp b/unit_tests/gen_common/exclude_tests/exclude_test_declare.cpp index e97acbe09e..c24446a7a9 100644 --- a/unit_tests/gen_common/exclude_tests/exclude_test_declare.cpp +++ b/unit_tests/gen_common/exclude_tests/exclude_test_declare.cpp @@ -11,16 +11,36 @@ #include -using ExcludeTest = ::testing::Test; +template +struct ExcludeTest : ::testing::Test { + void SetUp() override { + EXPECT_NE(prohibitedValue, ::productFamily); + } + void TearDown() override { + EXPECT_NE(prohibitedValue, ::productFamily); + } +}; -HWCMDTEST_F(IGFX_GEN8_CORE, ExcludeTest, whenBdwExcludedDontRunOnBdw) { +using ExcludeTestBdw = ExcludeTest; +HWCMDTEST_F(IGFX_GEN8_CORE, ExcludeTestBdw, givenHwCmdTestWhenBdwExcludedDontRunOnBdw) { + EXPECT_NE(IGFX_BROADWELL, ::productFamily); +} +HWTEST_F(ExcludeTestBdw, givenHwTestWhenBdwExcludedDontRunOnBdw) { EXPECT_NE(IGFX_BROADWELL, ::productFamily); } -HWCMDTEST_F(IGFX_GEN8_CORE, ExcludeTest, whenSklExcludedDontRunOnSkl) { +using ExcludeTestSkl = ExcludeTest; +HWCMDTEST_F(IGFX_GEN8_CORE, ExcludeTestSkl, givenHwCmdTestWhenSklExcludedDontRunOnSkl) { + EXPECT_NE(IGFX_SKYLAKE, ::productFamily); +} +HWTEST_F(ExcludeTestSkl, givenHwTestWhenSklExcludedDontRunOnSkl) { EXPECT_NE(IGFX_SKYLAKE, ::productFamily); } -HWCMDTEST_F(IGFX_GEN8_CORE, ExcludeTest, whenCnlExcludedDontRunOnCnl) { +using ExcludeTestCnl = ExcludeTest; +HWCMDTEST_F(IGFX_GEN8_CORE, ExcludeTestCnl, givenHwCmdTestWhenCnlExcludedDontRunOnCnl) { + EXPECT_NE(IGFX_CANNONLAKE, ::productFamily); +} +HWTEST_F(ExcludeTestCnl, givenHwTestWhenCnlExcludedDontRunOnCnl) { EXPECT_NE(IGFX_CANNONLAKE, ::productFamily); } diff --git a/unit_tests/gen_common/exclude_tests/exclude_test_exclude.cpp b/unit_tests/gen_common/exclude_tests/exclude_test_exclude.cpp index e765811efd..85abfa0aee 100644 --- a/unit_tests/gen_common/exclude_tests/exclude_test_exclude.cpp +++ b/unit_tests/gen_common/exclude_tests/exclude_test_exclude.cpp @@ -7,6 +7,9 @@ #include "test.h" -HWCMDTEST_EXCLUDE_FAMILY(ExcludeTest, whenBdwExcludedDontRunOnBdw, IGFX_BROADWELL); -HWCMDTEST_EXCLUDE_FAMILY(ExcludeTest, whenSklExcludedDontRunOnSkl, IGFX_SKYLAKE); -HWCMDTEST_EXCLUDE_FAMILY(ExcludeTest, whenCnlExcludedDontRunOnCnl, IGFX_CANNONLAKE); +HWCMDTEST_EXCLUDE_FAMILY(ExcludeTestBdw, givenHwCmdTestWhenBdwExcludedDontRunOnBdw, IGFX_BROADWELL); +HWCMDTEST_EXCLUDE_FAMILY(ExcludeTestBdw, givenHwTestWhenBdwExcludedDontRunOnBdw, IGFX_BROADWELL); +HWCMDTEST_EXCLUDE_FAMILY(ExcludeTestSkl, givenHwCmdTestWhenSklExcludedDontRunOnSkl, IGFX_SKYLAKE); +HWCMDTEST_EXCLUDE_FAMILY(ExcludeTestSkl, givenHwTestWhenSklExcludedDontRunOnSkl, IGFX_SKYLAKE); +HWCMDTEST_EXCLUDE_FAMILY(ExcludeTestCnl, givenHwCmdTestWhenCnlExcludedDontRunOnCnl, IGFX_CANNONLAKE); +HWCMDTEST_EXCLUDE_FAMILY(ExcludeTestCnl, givenHwTestWhenCnlExcludedDontRunOnCnl, IGFX_CANNONLAKE); diff --git a/unit_tests/gen_common/test.h b/unit_tests/gen_common/test.h index a5d04dac22..ca0597b1c7 100644 --- a/unit_tests/gen_common/test.h +++ b/unit_tests/gen_common/test.h @@ -44,6 +44,21 @@ extern GFXCORE_FAMILY renderCoreFamily; // Macros to provide template based testing. // Test can use FamilyType in the test -- equivalent to SKLFamily #define HWTEST_TEST_(test_case_name, test_name, parent_class, parent_id) \ + class PLATFORM_EXCLUDES_CLASS_NAME(test_case_name, test_name) { \ + public: \ + static std::unique_ptr> &getExcludes() { \ + static std::unique_ptr> excludes; \ + return excludes; \ + } \ + static void addExclude(uint32_t product) { \ + auto &excludes = getExcludes(); \ + if (excludes == nullptr) { \ + excludes = std::make_unique>(); \ + } \ + excludes->insert(product); \ + } \ + }; \ + \ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class { \ \ public: \ @@ -53,21 +68,41 @@ extern GFXCORE_FAMILY renderCoreFamily; private: \ template \ void testBodyHw(); \ + bool notExcluded() const { \ + using ExcludesT = PLATFORM_EXCLUDES_CLASS_NAME(test_case_name, test_name); \ + auto &excludes = ExcludesT::getExcludes(); \ + if (excludes == nullptr) { \ + return true; \ + } \ + return excludes->count(::productFamily) == 0; \ + } \ + void SetUp() override { \ + if (notExcluded()) { \ + parent_class::SetUp(); \ + } \ + } \ + void TearDown() override { \ + if (notExcluded()) { \ + parent_class::TearDown(); \ + } \ + } \ \ void TestBody() override { \ - switch (::renderCoreFamily) { \ - case IGFX_GEN8_CORE: \ - BDW_TYPED_TEST_BODY \ - break; \ - case IGFX_GEN9_CORE: \ - SKL_TYPED_TEST_BODY \ - break; \ - case IGFX_GEN10_CORE: \ - CNL_TYPED_TEST_BODY \ - break; \ - default: \ - ASSERT_TRUE((false && "Unknown hardware family")); \ - break; \ + if (notExcluded()) { \ + switch (::renderCoreFamily) { \ + case IGFX_GEN8_CORE: \ + BDW_TYPED_TEST_BODY \ + break; \ + case IGFX_GEN9_CORE: \ + SKL_TYPED_TEST_BODY \ + break; \ + case IGFX_GEN10_CORE: \ + CNL_TYPED_TEST_BODY \ + break; \ + default: \ + ASSERT_TRUE((false && "Unknown hardware family")); \ + break; \ + } \ } \ } \ static ::testing::TestInfo *const test_info_ GTEST_ATTRIBUTE_UNUSED_; \