Skip to content

Commit a9470b9

Browse files
Dont restore overrideCommandStreamReceiverCreation at creation time
Change-Id: I17039e501c0cdc84799ae16e7f82e8091cc6fb3a Signed-off-by: Dunajski, Bartosz <[email protected]>
1 parent c2ef7ef commit a9470b9

File tree

7 files changed

+31
-24
lines changed

7 files changed

+31
-24
lines changed

unit_tests/api/cl_get_device_ids_tests.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -102,7 +102,7 @@ extern bool overrideCommandStreamReceiverCreation;
102102

103103
TEST(MultiDeviceTests, givenCreateMultipleDevicesAndLimitAmountOfReturnedDevicesFlagWhenClGetDeviceIdsIsCalledThenLowerValueIsReturned) {
104104
platformImpl.reset(nullptr);
105-
overrideCommandStreamReceiverCreation = true;
105+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
106106
VariableBackup<bool> overrideHelper(&overrideDeviceWithDefaultHardwareInfo, false);
107107
DeviceFactoryCleaner cleaner;
108108
DebugManagerStateRestore stateRestore;

unit_tests/command_stream/create_command_stream_receiver_tests.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -14,6 +14,7 @@
1414
#include "unit_tests/helpers/execution_environment_helper.h"
1515
#include "unit_tests/libult/create_command_stream.h"
1616
#include "unit_tests/helpers/debug_manager_state_restore.h"
17+
#include "unit_tests/helpers/variable_backup.h"
1718
#include "test.h"
1819

1920
using namespace OCLRT;
@@ -40,7 +41,7 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo
4041

4142
CommandStreamReceiverType csrType = GetParam();
4243

43-
overrideCommandStreamReceiverCreation = true;
44+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
4445
DebugManager.flags.SetCommandStreamReceiver.set(csrType);
4546
executionEnvironment->commandStreamReceivers.resize(1);
4647
executionEnvironment->commandStreamReceivers[0][0] = std::unique_ptr<CommandStreamReceiver>(createCommandStream(hwInfo,

unit_tests/device/device_tests.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -12,6 +12,7 @@
1212
#include "test.h"
1313
#include "unit_tests/fixtures/device_fixture.h"
1414
#include "unit_tests/helpers/debug_manager_state_restore.h"
15+
#include "unit_tests/helpers/variable_backup.h"
1516
#include "unit_tests/libult/create_command_stream.h"
1617
#include "unit_tests/libult/ult_command_stream_receiver.h"
1718
#include "unit_tests/mocks/mock_context.h"
@@ -108,7 +109,7 @@ TEST(DeviceCreation, givenSelectedAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimu
108109
DebugManagerStateRestore dbgRestorer;
109110
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB);
110111

111-
overrideCommandStreamReceiverCreation = true;
112+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
112113
auto mockDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
113114
EXPECT_TRUE(mockDevice->isSimulation());
114115
}
@@ -117,7 +118,7 @@ TEST(DeviceCreation, givenSelectedTbxCsrInDebugVarsWhenDeviceIsCreatedThenIsSimu
117118
DebugManagerStateRestore dbgRestorer;
118119
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX);
119120

120-
overrideCommandStreamReceiverCreation = true;
121+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
121122
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
122123
EXPECT_TRUE(device->isSimulation());
123124
}
@@ -126,7 +127,7 @@ TEST(DeviceCreation, givenSelectedTbxWithAubCsrInDebugVarsWhenDeviceIsCreatedThe
126127
DebugManagerStateRestore dbgRestorer;
127128
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX_WITH_AUB);
128129

129-
overrideCommandStreamReceiverCreation = true;
130+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
130131
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
131132
EXPECT_TRUE(device->isSimulation());
132133
}

unit_tests/libult/create_command_stream.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -25,7 +25,6 @@ CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo, Executio
2525
CommandStreamReceiver *commandStreamReceiver = nullptr;
2626
assert(nullptr != pHwInfo->pPlatform);
2727
auto offset = !overrideCommandStreamReceiverCreation ? IGFX_MAX_CORE : 0;
28-
overrideCommandStreamReceiverCreation = false;
2928
if (offset != 0) {
3029
auto funcCreate = commandStreamReceiverFactory[offset + pHwInfo->pPlatform->eRenderCoreFamily];
3130
if (funcCreate) {

unit_tests/os_interface/windows/driver_info_tests.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -12,6 +12,7 @@
1212
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
1313
#include "runtime/helpers/options.h"
1414
#include "unit_tests/libult/create_command_stream.h"
15+
#include "unit_tests/helpers/variable_backup.h"
1516
#include "unit_tests/mocks/mock_device.h"
1617
#include "unit_tests/mocks/mock_csr.h"
1718
#include "unit_tests/mocks/mock_wddm.h"
@@ -43,25 +44,28 @@ class DriverInfoDeviceTest : public ::testing::Test {
4344

4445
CommandStreamReceiver *createMockCommandStreamReceiver(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
4546
auto csr = new MockCommandStreamReceiver(executionEnvironment);
46-
OSInterface *osInterface = new OSInterface();
47-
executionEnvironment.osInterface.reset(osInterface);
48-
auto wddm = new WddmMock();
49-
wddm->init(PreemptionHelper::getDefaultPreemptionMode(hwInfoIn));
50-
osInterface->get()->setWddm(wddm);
51-
csr->setOSInterface(osInterface);
47+
if (!executionEnvironment.osInterface) {
48+
executionEnvironment.osInterface = std::make_unique<OSInterface>();
49+
auto wddm = new WddmMock();
50+
wddm->init(PreemptionHelper::getDefaultPreemptionMode(hwInfoIn));
51+
executionEnvironment.osInterface->get()->setWddm(wddm);
52+
}
53+
54+
EXPECT_NE(nullptr, executionEnvironment.osInterface.get());
55+
csr->setOSInterface(executionEnvironment.osInterface.get());
5256
return csr;
5357
}
5458

5559
TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWhenCorrectOSInterfaceThenCreateDriverInfo) {
56-
overrideCommandStreamReceiverCreation = true;
60+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
5761
auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo);
5862

5963
EXPECT_TRUE(device->hasDriverInfo());
6064
delete device;
6165
}
6266

6367
TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWithoutCorrectOSInterfaceThenDontCreateDriverInfo) {
64-
overrideCommandStreamReceiverCreation = false;
68+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, false);
6569
auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo);
6670

6771
EXPECT_FALSE(device->hasDriverInfo());

unit_tests/platform/platform_tests.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -10,6 +10,7 @@
1010
#include "runtime/platform/extensions.h"
1111
#include "runtime/sharings/sharing_factory.h"
1212
#include "unit_tests/helpers/debug_manager_state_restore.h"
13+
#include "unit_tests/helpers/variable_backup.h"
1314
#include "unit_tests/fixtures/platform_fixture.h"
1415
#include "unit_tests/mocks/mock_async_event_handler.h"
1516
#include "unit_tests/mocks/mock_builtins.h"
@@ -150,7 +151,7 @@ TEST(PlatformTestSimple, givenCsrHwTypeWhenPlatformIsInitializedThenInitAubCente
150151
TEST(PlatformTestSimple, givenNotCsrHwTypeWhenPlatformIsInitializedThenInitAubCenterIsCalled) {
151152
DebugManagerStateRestore stateRestore;
152153
DebugManager.flags.SetCommandStreamReceiver.set(1);
153-
overrideCommandStreamReceiverCreation = true;
154+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
154155
MockPlatformWithMockExecutionEnvironment platform;
155156
bool ret = platform.initialize();
156157
EXPECT_TRUE(ret);
@@ -185,14 +186,14 @@ class PlatformFailingTest : public PlatformTest {
185186
hwInfo = platformDevices[0];
186187
commandStreamReceiverCreateFunc = commandStreamReceiverFactory[hwInfo->pPlatform->eRenderCoreFamily];
187188
commandStreamReceiverFactory[hwInfo->pPlatform->eRenderCoreFamily] = createMockCommandStreamReceiver;
188-
overrideCommandStreamReceiverCreation = true;
189189
}
190190

191191
void TearDown() override {
192192
commandStreamReceiverFactory[hwInfo->pPlatform->eRenderCoreFamily] = commandStreamReceiverCreateFunc;
193193
PlatformTest::TearDown();
194194
}
195195

196+
VariableBackup<bool> backup{&overrideCommandStreamReceiverCreation, true};
196197
CommandStreamReceiverCreateFunc commandStreamReceiverCreateFunc;
197198
const HardwareInfo *hwInfo;
198199
};

unit_tests/source_level_debugger/source_level_debugger_tests.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -11,6 +11,7 @@
1111
#include "runtime/source_level_debugger/source_level_debugger.h"
1212
#include "unit_tests/fixtures/device_fixture.h"
1313
#include "unit_tests/helpers/execution_environment_helper.h"
14+
#include "unit_tests/helpers/variable_backup.h"
1415
#include "unit_tests/libult/source_level_debugger_library.h"
1516
#include "unit_tests/libult/create_command_stream.h"
1617
#include "unit_tests/mocks/mock_source_level_debugger.h"
@@ -486,7 +487,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreate
486487
DebuggerLibrary::setDebuggerActive(true);
487488
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
488489

489-
overrideCommandStreamReceiverCreation = true;
490+
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
490491

491492
HardwareInfo *hwInfo = nullptr;
492493
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);

0 commit comments

Comments
 (0)