480 lines
22 KiB
C++
480 lines
22 KiB
C++
/*
|
|
* Copyright (c) 2018, Intel Corporation
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included
|
|
* in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include "runtime/command_stream/aub_subcapture.h"
|
|
#include "runtime/helpers/dispatch_info.h"
|
|
#include "unit_tests/fixtures/device_fixture.h"
|
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
|
#include "unit_tests/mocks/mock_aub_subcapture_manager.h"
|
|
#include "unit_tests/mocks/mock_kernel.h"
|
|
#include "unit_tests/mocks/mock_program.h"
|
|
#include "test.h"
|
|
|
|
using namespace OCLRT;
|
|
|
|
struct AubSubCaptureTest : public DeviceFixture,
|
|
public ::testing::Test {
|
|
void SetUp() override {
|
|
DeviceFixture::SetUp();
|
|
program = std::make_unique<MockProgram>(*pDevice->getExecutionEnvironment());
|
|
kernelInfo.name = "kernel_name";
|
|
dbgRestore = new DebugManagerStateRestore();
|
|
}
|
|
|
|
void TearDown() override {
|
|
DeviceFixture::TearDown();
|
|
delete dbgRestore;
|
|
}
|
|
|
|
std::unique_ptr<MockProgram> program;
|
|
KernelInfo kernelInfo;
|
|
DebugManagerStateRestore *dbgRestore;
|
|
};
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureToggleCaptureOnOffIsUnspecifiedThenSubCaptureIsToggledOffByDefault) {
|
|
struct AubSubCaptureManagerWithToggleActiveMock : public AubSubCaptureManager {
|
|
using AubSubCaptureManager::AubSubCaptureManager;
|
|
using AubSubCaptureManager::isSubCaptureToggleActive;
|
|
} aubSubCaptureManagerWithToggleActiveMock("");
|
|
|
|
EXPECT_FALSE(aubSubCaptureManagerWithToggleActiveMock.isSubCaptureToggleActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureToggleFileNameIsUnspecifiedThenEmptyExternalFileNameIsReturnedByDefault) {
|
|
struct AubSubCaptureManagerWithToggleActiveMock : public AubSubCaptureManager {
|
|
using AubSubCaptureManager::AubSubCaptureManager;
|
|
using AubSubCaptureManager::getExternalFileName;
|
|
} aubSubCaptureManagerWithToggleActiveMock("");
|
|
|
|
EXPECT_STREQ("", aubSubCaptureManagerWithToggleActiveMock.getExternalFileName().c_str());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenItIsCreatedThenItIsInitializedWithDefaults) {
|
|
std::string initialFileName = "initial_file_name.aub";
|
|
AubSubCaptureManagerMock aubSubCaptureManager(initialFileName);
|
|
|
|
EXPECT_EQ(AubSubCaptureManager::SubCaptureMode::Off, aubSubCaptureManager.subCaptureMode);
|
|
EXPECT_STREQ("", aubSubCaptureManager.subCaptureFilter.dumpKernelName.c_str());
|
|
EXPECT_EQ(0u, aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx);
|
|
EXPECT_EQ(static_cast<uint32_t>(-1), aubSubCaptureManager.subCaptureFilter.dumpKernelEndIdx);
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureMode());
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
|
EXPECT_FALSE(aubSubCaptureManager.wasSubCaptureActive());
|
|
EXPECT_EQ(0u, aubSubCaptureManager.getKernelCurrentIndex());
|
|
EXPECT_TRUE(aubSubCaptureManager.getUseExternalFileName());
|
|
EXPECT_STREQ(initialFileName.c_str(), aubSubCaptureManager.getInitialFileName().c_str());
|
|
EXPECT_STREQ("", aubSubCaptureManager.getCurrentFileName().c_str());
|
|
EXPECT_NE(nullptr, aubSubCaptureManager.getSettingsReader());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenActivateSubCaptureIsCalledWithEmptyDispatchInfoThenSubCaptureIsInactive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
MultiDispatchInfo dispatchInfo;
|
|
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
|
EXPECT_FALSE(active);
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenActivateSubCaptureIsCalledWithNonEmptyDispatchInfoThenKernelCurrentIndexIsIncremented) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
uint32_t kernelCurrentIndex = aubSubCaptureManager.getKernelCurrentIndex();
|
|
ASSERT_EQ(0u, kernelCurrentIndex);
|
|
|
|
aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_EQ(kernelCurrentIndex + 1, aubSubCaptureManager.getKernelCurrentIndex());
|
|
|
|
aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_EQ(kernelCurrentIndex + 2, aubSubCaptureManager.getKernelCurrentIndex());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenActivateSubCaptureIsCalledButSubCaptureModeIsOffThenSubCaptureIsInactive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Off;
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_FALSE(active);
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenActivateSubCaptureIsCalledAndSubCaptureIsToggledOnThenSubCaptureIsActive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
aubSubCaptureManager.setSubCaptureToggleActive(true);
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_TRUE(active);
|
|
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenActivateSubCaptureIsCalledButSubCaptureIsToggledOffThenSubCaptureIsInactive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
aubSubCaptureManager.setSubCaptureToggleActive(false);
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_FALSE(active);
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterIsDefaultThenSubCaptureIsActive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_TRUE(active);
|
|
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithValidKernelStartIndexIsSpecifiedThenSubCaptureIsActive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx = 0;
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_TRUE(active);
|
|
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelStartIndexIsSpecifiedThenSubCaptureIsInactive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx = 1;
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_FALSE(active);
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelEndIndexIsSpecifiedThenSubCaptureIsInactive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
aubSubCaptureManager.subCaptureFilter.dumpKernelEndIdx = 0;
|
|
aubSubCaptureManager.setKernelCurrentIndex(1);
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_FALSE(active);
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithValidKernelNameIsSpecifiedThenSubCaptureIsActive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
aubSubCaptureManager.subCaptureFilter.dumpKernelName = "kernel_name";
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_TRUE(active);
|
|
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelNameIsSpecifiedThenSubCaptureIsInactive) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
aubSubCaptureManager.subCaptureFilter.dumpKernelName = "invalid_kernel_name";
|
|
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_FALSE(active);
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenDeactivateSubCaptureIsCalledThenSubCaptureActiveStatesAreCleared) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
aubSubCaptureManager.setSubCaptureIsActive(true);
|
|
aubSubCaptureManager.setSubCaptureWasActive(true);
|
|
|
|
aubSubCaptureManager.disableSubCapture();
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
|
EXPECT_FALSE(aubSubCaptureManager.wasSubCaptureActive());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureKeepsInactiveThenMakeEachEnqueueBlocking) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.setSubCaptureIsActive(false);
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
aubSubCaptureManager.setSubCaptureToggleActive(false);
|
|
|
|
aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_TRUE(DebugManager.flags.MakeEachEnqueueBlocking.get());
|
|
EXPECT_FALSE(DebugManager.flags.ForceCsrFlushing.get());
|
|
EXPECT_FALSE(DebugManager.flags.ForceCsrReprogramming.get());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureGetsActiveThenDontMakeEachEnqueueBlockingAndForceCsrReprogramming) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.setSubCaptureIsActive(false);
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
aubSubCaptureManager.setSubCaptureToggleActive(true);
|
|
|
|
aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_FALSE(DebugManager.flags.ForceCsrFlushing.get());
|
|
EXPECT_TRUE(DebugManager.flags.ForceCsrReprogramming.get());
|
|
EXPECT_FALSE(DebugManager.flags.MakeEachEnqueueBlocking.get());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureKeepsActiveThenDontMakeEachEnqueueBlocking) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.setSubCaptureIsActive(true);
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
aubSubCaptureManager.setSubCaptureToggleActive(true);
|
|
|
|
aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_FALSE(DebugManager.flags.ForceCsrFlushing.get());
|
|
EXPECT_FALSE(DebugManager.flags.ForceCsrReprogramming.get());
|
|
EXPECT_FALSE(DebugManager.flags.MakeEachEnqueueBlocking.get());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureGetsInactiveThenMakeEachEnqueueBlockingAndForceCsrFlushing) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
|
|
aubSubCaptureManager.setSubCaptureIsActive(true);
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
aubSubCaptureManager.setSubCaptureToggleActive(false);
|
|
|
|
aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
|
|
EXPECT_TRUE(DebugManager.flags.ForceCsrFlushing.get());
|
|
EXPECT_FALSE(DebugManager.flags.ForceCsrReprogramming.get());
|
|
EXPECT_TRUE(DebugManager.flags.MakeEachEnqueueBlocking.get());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureActiveStatesAreDeterminedThenIsSubCaptureFunctionReturnCorrectValues) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
aubSubCaptureManager.setSubCaptureWasActive(false);
|
|
aubSubCaptureManager.setSubCaptureIsActive(false);
|
|
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureEnabled());
|
|
|
|
aubSubCaptureManager.setSubCaptureWasActive(false);
|
|
aubSubCaptureManager.setSubCaptureIsActive(true);
|
|
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureEnabled());
|
|
|
|
aubSubCaptureManager.setSubCaptureWasActive(true);
|
|
aubSubCaptureManager.setSubCaptureIsActive(false);
|
|
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureEnabled());
|
|
|
|
aubSubCaptureManager.setSubCaptureIsActive(true);
|
|
aubSubCaptureManager.setSubCaptureWasActive(true);
|
|
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureEnabled());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInOffModeWhenGetSubCaptureFileNameIsCalledThenItReturnsEmptyFileName) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
EXPECT_STREQ("", aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo).c_str());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGetSubCaptureFileNameIsCalledAndExternalFileNameIsSpecifiedThenItReturnsItsName) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
std::string externalFileName = "external_file_name.aub";
|
|
aubSubCaptureManager.setExternalFileName(externalFileName);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
EXPECT_STREQ(externalFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo).c_str());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGetSubCaptureFileNameIsCalledAndExternalFileNameIsSpecifiedThenItReturnsItsName) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
std::string externalFileName = "external_file_name.aub";
|
|
aubSubCaptureManager.setExternalFileName(externalFileName);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
EXPECT_STREQ(externalFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo).c_str());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGetSubCaptureFileNameIsCalledAndExternalFileNameIsNotSpecifiedThenItGeneratesFilterFileName) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
std::string externalFileName = "";
|
|
aubSubCaptureManager.setExternalFileName(externalFileName);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
std::string filterFileName = aubSubCaptureManager.generateFilterFileName();
|
|
EXPECT_STREQ(filterFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo).c_str());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGetSubCaptureFileNameIsCalledAndExternalFileNameIsNotSpecifiedThenItGeneratesToggleFileName) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
|
dispatchInfo.setKernel(&kernel);
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
std::string externalFileName = "";
|
|
aubSubCaptureManager.setExternalFileName(externalFileName);
|
|
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
std::string toggleFileName = aubSubCaptureManager.generateToggleFileName(multiDispatchInfo);
|
|
EXPECT_STREQ(toggleFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo).c_str());
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGetSubCaptureFileNameIsCalledManyTimesAndExternalFileNameIsNotSpecifiedThenItGeneratesFilterFileNameOnceOnly) {
|
|
struct AubSubCaptureManagerMockWithFilterFileNameGenerationCount : AubSubCaptureManager {
|
|
using AubSubCaptureManager::AubSubCaptureManager;
|
|
std::string generateFilterFileName() const override {
|
|
generateFilterFileNameCount++;
|
|
return "aubfile_filter.aub";
|
|
}
|
|
mutable uint32_t generateFilterFileNameCount = 0;
|
|
} aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo);
|
|
aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo);
|
|
aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo);
|
|
EXPECT_EQ(1u, aubSubCaptureManager.generateFilterFileNameCount);
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGetSubCaptureFileNameIsCalledManyTimesAndExternalFileNameIsNotSpecifiedThenItGeneratesToggleFileNameOnceOnly) {
|
|
struct AubSubCaptureManagerMockWithToggleFileNameGenerationCount : AubSubCaptureManager {
|
|
using AubSubCaptureManager::AubSubCaptureManager;
|
|
std::string generateToggleFileName(const MultiDispatchInfo &dispatchInfo) const override {
|
|
generateToggleFileNameCount++;
|
|
return "aubfile_toggle.aub";
|
|
}
|
|
mutable uint32_t generateToggleFileNameCount = 0;
|
|
} aubSubCaptureManager("");
|
|
|
|
DispatchInfo dispatchInfo;
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
multiDispatchInfo.push(dispatchInfo);
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo);
|
|
aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo);
|
|
aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo);
|
|
EXPECT_EQ(1u, aubSubCaptureManager.generateToggleFileNameCount);
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFileNameIsCalledAndKernelNameIsSpecifiedInFilterThenItGeneratesFileNameWithNameOfKernel) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
|
|
std::string kernelName = "kernel_name";
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
|
aubSubCaptureManager.subCaptureFilter.dumpKernelName = kernelName;
|
|
std::string filterFileName = aubSubCaptureManager.generateFilterFileName();
|
|
EXPECT_NE(std::string::npos, filterFileName.find(kernelName));
|
|
}
|
|
|
|
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGenerateToggleFileNameIsCalledAndDispatchInfoIsEmptyThenItGeneratesFileNameWithoutNameOfKernel) {
|
|
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
|
|
std::string kernelName = "kernel_name";
|
|
MultiDispatchInfo dispatchInfo;
|
|
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
|
aubSubCaptureManager.subCaptureFilter.dumpKernelName = kernelName;
|
|
std::string toggleFileName = aubSubCaptureManager.generateToggleFileName(dispatchInfo);
|
|
EXPECT_EQ(std::string::npos, toggleFileName.find(kernelName));
|
|
}
|