Dont restore overrideCommandStreamReceiverCreation at creation time

Change-Id: I17039e501c0cdc84799ae16e7f82e8091cc6fb3a
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz 2019-01-08 13:11:09 +01:00 committed by sys_ocldev
parent c2ef7ef0ca
commit a9470b9f79
7 changed files with 31 additions and 24 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -102,7 +102,7 @@ extern bool overrideCommandStreamReceiverCreation;
TEST(MultiDeviceTests, givenCreateMultipleDevicesAndLimitAmountOfReturnedDevicesFlagWhenClGetDeviceIdsIsCalledThenLowerValueIsReturned) {
platformImpl.reset(nullptr);
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
VariableBackup<bool> overrideHelper(&overrideDeviceWithDefaultHardwareInfo, false);
DeviceFactoryCleaner cleaner;
DebugManagerStateRestore stateRestore;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -14,6 +14,7 @@
#include "unit_tests/helpers/execution_environment_helper.h"
#include "unit_tests/libult/create_command_stream.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/variable_backup.h"
#include "test.h"
using namespace OCLRT;
@ -40,7 +41,7 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo
CommandStreamReceiverType csrType = GetParam();
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
DebugManager.flags.SetCommandStreamReceiver.set(csrType);
executionEnvironment->commandStreamReceivers.resize(1);
executionEnvironment->commandStreamReceivers[0][0] = std::unique_ptr<CommandStreamReceiver>(createCommandStream(hwInfo,

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -12,6 +12,7 @@
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/variable_backup.h"
#include "unit_tests/libult/create_command_stream.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "unit_tests/mocks/mock_context.h"
@ -108,7 +109,7 @@ TEST(DeviceCreation, givenSelectedAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimu
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB);
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
auto mockDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_TRUE(mockDevice->isSimulation());
}
@ -117,7 +118,7 @@ TEST(DeviceCreation, givenSelectedTbxCsrInDebugVarsWhenDeviceIsCreatedThenIsSimu
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX);
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_TRUE(device->isSimulation());
}
@ -126,7 +127,7 @@ TEST(DeviceCreation, givenSelectedTbxWithAubCsrInDebugVarsWhenDeviceIsCreatedThe
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX_WITH_AUB);
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_TRUE(device->isSimulation());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -25,7 +25,6 @@ CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo, Executio
CommandStreamReceiver *commandStreamReceiver = nullptr;
assert(nullptr != pHwInfo->pPlatform);
auto offset = !overrideCommandStreamReceiverCreation ? IGFX_MAX_CORE : 0;
overrideCommandStreamReceiverCreation = false;
if (offset != 0) {
auto funcCreate = commandStreamReceiverFactory[offset + pHwInfo->pPlatform->eRenderCoreFamily];
if (funcCreate) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -12,6 +12,7 @@
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/helpers/options.h"
#include "unit_tests/libult/create_command_stream.h"
#include "unit_tests/helpers/variable_backup.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_csr.h"
#include "unit_tests/mocks/mock_wddm.h"
@ -43,17 +44,20 @@ class DriverInfoDeviceTest : public ::testing::Test {
CommandStreamReceiver *createMockCommandStreamReceiver(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
auto csr = new MockCommandStreamReceiver(executionEnvironment);
OSInterface *osInterface = new OSInterface();
executionEnvironment.osInterface.reset(osInterface);
if (!executionEnvironment.osInterface) {
executionEnvironment.osInterface = std::make_unique<OSInterface>();
auto wddm = new WddmMock();
wddm->init(PreemptionHelper::getDefaultPreemptionMode(hwInfoIn));
osInterface->get()->setWddm(wddm);
csr->setOSInterface(osInterface);
executionEnvironment.osInterface->get()->setWddm(wddm);
}
EXPECT_NE(nullptr, executionEnvironment.osInterface.get());
csr->setOSInterface(executionEnvironment.osInterface.get());
return csr;
}
TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWhenCorrectOSInterfaceThenCreateDriverInfo) {
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo);
EXPECT_TRUE(device->hasDriverInfo());
@ -61,7 +65,7 @@ TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWhenCorrectOSInterfaceThenCreateD
}
TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWithoutCorrectOSInterfaceThenDontCreateDriverInfo) {
overrideCommandStreamReceiverCreation = false;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, false);
auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo);
EXPECT_FALSE(device->hasDriverInfo());

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -10,6 +10,7 @@
#include "runtime/platform/extensions.h"
#include "runtime/sharings/sharing_factory.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/variable_backup.h"
#include "unit_tests/fixtures/platform_fixture.h"
#include "unit_tests/mocks/mock_async_event_handler.h"
#include "unit_tests/mocks/mock_builtins.h"
@ -150,7 +151,7 @@ TEST(PlatformTestSimple, givenCsrHwTypeWhenPlatformIsInitializedThenInitAubCente
TEST(PlatformTestSimple, givenNotCsrHwTypeWhenPlatformIsInitializedThenInitAubCenterIsCalled) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.SetCommandStreamReceiver.set(1);
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
MockPlatformWithMockExecutionEnvironment platform;
bool ret = platform.initialize();
EXPECT_TRUE(ret);
@ -185,7 +186,6 @@ class PlatformFailingTest : public PlatformTest {
hwInfo = platformDevices[0];
commandStreamReceiverCreateFunc = commandStreamReceiverFactory[hwInfo->pPlatform->eRenderCoreFamily];
commandStreamReceiverFactory[hwInfo->pPlatform->eRenderCoreFamily] = createMockCommandStreamReceiver;
overrideCommandStreamReceiverCreation = true;
}
void TearDown() override {
@ -193,6 +193,7 @@ class PlatformFailingTest : public PlatformTest {
PlatformTest::TearDown();
}
VariableBackup<bool> backup{&overrideCommandStreamReceiverCreation, true};
CommandStreamReceiverCreateFunc commandStreamReceiverCreateFunc;
const HardwareInfo *hwInfo;
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -11,6 +11,7 @@
#include "runtime/source_level_debugger/source_level_debugger.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/execution_environment_helper.h"
#include "unit_tests/helpers/variable_backup.h"
#include "unit_tests/libult/source_level_debugger_library.h"
#include "unit_tests/libult/create_command_stream.h"
#include "unit_tests/mocks/mock_source_level_debugger.h"
@ -486,7 +487,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreate
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
HardwareInfo *hwInfo = nullptr;
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);