2018-01-19 10:00:51 +01:00
|
|
|
/*
|
2019-01-08 13:11:09 +01:00
|
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
2018-01-19 10:00:51 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-01-19 10:00:51 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
|
|
|
|
#include "runtime/command_stream/command_stream_receiver_with_aub_dump.h"
|
2018-07-16 16:37:17 +02:00
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
2018-01-19 10:00:51 +01:00
|
|
|
#include "runtime/helpers/options.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
|
|
|
|
#include "test.h"
|
2018-07-16 16:37:17 +02:00
|
|
|
#include "unit_tests/fixtures/gmm_environment_fixture.h"
|
2018-01-19 10:00:51 +01:00
|
|
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "unit_tests/helpers/execution_environment_helper.h"
|
2019-01-08 13:11:09 +01:00
|
|
|
#include "unit_tests/helpers/variable_backup.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "unit_tests/libult/create_command_stream.h"
|
2018-01-19 10:00:51 +01:00
|
|
|
|
|
|
|
|
using namespace OCLRT;
|
|
|
|
|
|
2018-07-16 16:37:17 +02:00
|
|
|
struct CreateCommandStreamReceiverTest : public GmmEnvironmentFixture, public ::testing::TestWithParam<CommandStreamReceiverType> {
|
2018-01-19 10:00:51 +01:00
|
|
|
void SetUp() override {
|
2018-07-16 16:37:17 +02:00
|
|
|
GmmEnvironmentFixture::SetUp();
|
2018-01-19 10:00:51 +01:00
|
|
|
storeInitHWTag = initialHardwareTag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
|
initialHardwareTag = storeInitHWTag;
|
2018-07-16 16:37:17 +02:00
|
|
|
GmmEnvironmentFixture::TearDown();
|
2018-01-19 10:00:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
int storeInitHWTag;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetToValidTypeThenTheFuntionReturnsCommandStreamReceiver) {
|
|
|
|
|
DebugManagerStateRestore stateRestorer;
|
2018-09-17 15:42:15 +02:00
|
|
|
HardwareInfo *hwInfo = nullptr;
|
|
|
|
|
std::unique_ptr<ExecutionEnvironment> executionEnvironment = std::unique_ptr<ExecutionEnvironment>(getExecutionEnvironmentImpl(hwInfo));
|
2018-07-16 16:37:17 +02:00
|
|
|
|
2018-01-19 10:00:51 +01:00
|
|
|
CommandStreamReceiverType csrType = GetParam();
|
|
|
|
|
|
2019-01-08 13:11:09 +01:00
|
|
|
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
|
2018-01-19 10:00:51 +01:00
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(csrType);
|
2018-11-20 13:58:15 +01:00
|
|
|
executionEnvironment->commandStreamReceivers.resize(1);
|
2019-01-10 13:57:40 +01:00
|
|
|
executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr<CommandStreamReceiver>(createCommandStream(hwInfo,
|
|
|
|
|
*executionEnvironment)));
|
2018-09-17 15:42:15 +02:00
|
|
|
|
2018-01-19 10:00:51 +01:00
|
|
|
if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) {
|
2018-11-20 13:58:15 +01:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get());
|
2018-01-19 10:00:51 +01:00
|
|
|
} else {
|
2018-11-20 13:58:15 +01:00
|
|
|
EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0]);
|
2018-01-19 10:00:51 +01:00
|
|
|
}
|
2019-03-08 12:18:02 +01:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager.get());
|
2018-01-19 10:00:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CommandStreamReceiverType commandStreamReceiverTypes[] = {
|
|
|
|
|
CSR_HW,
|
|
|
|
|
CSR_AUB,
|
|
|
|
|
CSR_TBX,
|
|
|
|
|
CSR_HW_WITH_AUB,
|
2018-03-05 22:16:21 +01:00
|
|
|
CSR_TBX_WITH_AUB,
|
2018-01-19 10:00:51 +01:00
|
|
|
CSR_TYPES_NUM};
|
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
|
CreateCommandStreamReceiverTest_Create,
|
|
|
|
|
CreateCommandStreamReceiverTest,
|
2018-08-08 13:49:09 +02:00
|
|
|
testing::ValuesIn(commandStreamReceiverTypes));
|