2019-08-27 21:58:53 +08:00
|
|
|
/*
|
2020-01-30 16:36:05 +08:00
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
2019-08-27 21:58:53 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 08:01:38 +08:00
|
|
|
#include "shared/test/unit_test/helpers/default_hw_info.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/helpers/hardware_commands_helper.h"
|
2019-08-27 21:58:53 +08:00
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
struct TemplatedFixtureTests : public ::testing::Test {
|
|
|
|
void SetUp() override {
|
|
|
|
baseSetUpCallId = callsOrder++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
EXPECT_EQ(idForBaseTearDown, callsOrder);
|
|
|
|
EXPECT_EQ((idForBaseTearDown - 1), templateBaseTearDownCallId);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void SetUpT() {
|
|
|
|
templateBaseSetUpCallId = callsOrder++;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void TearDownT() {
|
|
|
|
templateBaseTearDownCallId = callsOrder++;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t callsOrder = 0;
|
|
|
|
uint32_t baseSetUpCallId = -1;
|
|
|
|
uint32_t templateBaseSetUpCallId = -1;
|
|
|
|
uint32_t templateBaseTearDownCallId = -1;
|
|
|
|
|
|
|
|
uint32_t idForBaseTearDown = -1;
|
|
|
|
};
|
|
|
|
|
2019-08-28 18:55:48 +08:00
|
|
|
HWTEST_TEMPLATED_F(TemplatedFixtureTests, whenExecutingTemplatedTestThenCallTemplatedSetupAndTeardown) {
|
2019-08-27 21:58:53 +08:00
|
|
|
EXPECT_EQ(2u, callsOrder);
|
|
|
|
|
|
|
|
EXPECT_EQ(0u, baseSetUpCallId);
|
|
|
|
EXPECT_EQ(1u, templateBaseSetUpCallId);
|
|
|
|
|
|
|
|
idForBaseTearDown = callsOrder + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DerivedTemplatedFixtureTests : public TemplatedFixtureTests {
|
|
|
|
template <typename T>
|
|
|
|
void SetUpT() {
|
|
|
|
TemplatedFixtureTests::SetUpT<T>();
|
|
|
|
templateDerivedSetUpCallId = callsOrder++;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void TearDownT() {
|
|
|
|
templateDerivedTearDownCallId = callsOrder++;
|
|
|
|
TemplatedFixtureTests::TearDownT<T>();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t templateDerivedSetUpCallId = -1;
|
|
|
|
uint32_t templateDerivedTearDownCallId = -1;
|
|
|
|
};
|
|
|
|
|
2019-08-28 18:55:48 +08:00
|
|
|
HWTEST_TEMPLATED_F(DerivedTemplatedFixtureTests, whenExecutingTemplatedTestThenCallTemplatedSetupAndTeardown) {
|
2019-08-27 21:58:53 +08:00
|
|
|
EXPECT_EQ(3u, callsOrder);
|
|
|
|
|
|
|
|
EXPECT_EQ(0u, baseSetUpCallId);
|
|
|
|
EXPECT_EQ(1u, templateBaseSetUpCallId);
|
|
|
|
EXPECT_EQ(2u, templateDerivedSetUpCallId);
|
|
|
|
|
|
|
|
idForBaseTearDown = callsOrder + 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TemplatedFixtureBaseTests : public ::testing::Test {
|
|
|
|
template <typename T>
|
|
|
|
void SetUpT() {
|
2020-03-24 18:42:54 +08:00
|
|
|
capturedPipeControlWaRequiredInSetUp = HardwareCommandsHelper<T>::isPipeControlWArequired(*defaultHwInfo);
|
2019-08-27 21:58:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void TearDownT() {}
|
|
|
|
|
|
|
|
bool capturedPipeControlWaRequiredInSetUp = false;
|
|
|
|
};
|
|
|
|
|
2019-08-28 18:55:48 +08:00
|
|
|
HWTEST_TEMPLATED_F(TemplatedFixtureBaseTests, whenExecutingTemplatedSetupThenTemplateTargetsCorrectPlatform) {
|
2020-03-24 18:42:54 +08:00
|
|
|
bool capturedPipeControlWaRequiredInTestBody = HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(*defaultHwInfo);
|
2019-08-27 21:58:53 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(capturedPipeControlWaRequiredInTestBody, capturedPipeControlWaRequiredInSetUp);
|
|
|
|
}
|
|
|
|
} // namespace NEO
|