mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
refactor: add mock_aubstream
Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4aa7c6c99e
commit
cbc868c4ed
17
shared/test/common/mock_aubstream/CMakeLists.txt
Normal file
17
shared/test/common/mock_aubstream/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
project(mock_aubstream)
|
||||
|
||||
add_library(
|
||||
mock_aubstream EXCLUDE_FROM_ALL OBJECT
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_aubstream.cpp
|
||||
)
|
||||
|
||||
create_project_source_tree(mock_aubstream)
|
||||
set_target_properties(mock_aubstream PROPERTIES FOLDER "test mocks")
|
||||
target_include_directories(mock_aubstream PRIVATE ${AUB_STREAM_HEADERS_DIR})
|
||||
39
shared/test/common/mock_aubstream/mock_aubstream.cpp
Normal file
39
shared/test/common/mock_aubstream/mock_aubstream.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "aubstream/aubstream.h"
|
||||
|
||||
namespace aub_stream_stubs {
|
||||
uint16_t tbxServerPort = 4321;
|
||||
std::string tbxServerIp = "127.0.0.1";
|
||||
bool tbxFrontdoorMode = false;
|
||||
aub_stream::MMIOList mmioListInjected;
|
||||
} // namespace aub_stream_stubs
|
||||
|
||||
namespace aub_stream {
|
||||
|
||||
void injectMMIOList(MMIOList mmioList) {
|
||||
aub_stream_stubs::mmioListInjected = mmioList;
|
||||
aub_stream_stubs::mmioListInjected.shrink_to_fit();
|
||||
}
|
||||
void setTbxServerPort(uint16_t port) {
|
||||
aub_stream_stubs::tbxServerPort = port;
|
||||
}
|
||||
void setTbxServerIp(std::string server) {
|
||||
// better to avoid reassigning global variables which assume memory allocations since
|
||||
// we could step into false-positive memory leak detection with embedded leak check helper
|
||||
if (aub_stream_stubs::tbxServerIp != server) {
|
||||
aub_stream_stubs::tbxServerIp = server;
|
||||
}
|
||||
}
|
||||
void setTbxFrontdoorMode(bool frontdoor) {
|
||||
aub_stream_stubs::tbxFrontdoorMode = frontdoor;
|
||||
}
|
||||
void setAubStreamCaller(uint32_t caller) {
|
||||
}
|
||||
|
||||
} // namespace aub_stream
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
# Copyright (C) 2020-2024 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -21,5 +21,3 @@ target_include_directories(${target_name} PRIVATE
|
||||
|
||||
create_project_source_tree(${target_name})
|
||||
set_target_properties(${target_name} PROPERTIES FOLDER "test mocks")
|
||||
target_compile_definitions(${target_name} PUBLIC)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ add_executable(neo_shared_tests
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/common_main.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/tests_configuration.h
|
||||
$<TARGET_OBJECTS:mock_aubstream>
|
||||
$<TARGET_OBJECTS:mock_gmm>
|
||||
$<TARGET_OBJECTS:neo_libult_common>
|
||||
$<TARGET_OBJECTS:neo_libult_cs>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2018-2022 Intel Corporation
|
||||
# Copyright (C) 2018-2024 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -10,8 +10,6 @@ target_sources(neo_shared_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_tests.cpp
|
||||
)
|
||||
|
||||
if(NOT DEFINED AUB_STREAM_PROJECT_NAME)
|
||||
target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/aub_center_using_aubstream_stubs_tests.cpp)
|
||||
endif()
|
||||
target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/aub_center_using_aubstream_stubs_tests.cpp)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -30,28 +30,31 @@ TEST(AubCenter, GivenUseAubStreamAndTbxServerIpDebugVariableSetWhenAubCenterIsCr
|
||||
debugManager.flags.TbxServer.set("10.10.10.10");
|
||||
VariableBackup<std::string> backup(&aub_stream_stubs::tbxServerIp);
|
||||
|
||||
ASSERT_STRNE("10.10.10.10", aub_stream_stubs::tbxServerIp.c_str());
|
||||
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||
|
||||
MockAubCenter aubCenter(rootDeviceEnvironment, false, "", CommandStreamReceiverType::CSR_TBX);
|
||||
MockAubCenter aubCenter(rootDeviceEnvironment, false, "", CommandStreamReceiverType::tbx);
|
||||
|
||||
EXPECT_STREQ("10.10.10.10", aub_stream_stubs::tbxServerIp.c_str());
|
||||
}
|
||||
|
||||
TEST(AubCenter, GivenUseAubStreamAndTbxServerPortDebugVariableSetWhenAubCenterIsCreatedThenServerIpIsModified) {
|
||||
TEST(AubCenter, GivenUseAubStreamAndTbxServerPortDebugVariableSetWhenAubCenterIsCreatedThenServerPortIsModified) {
|
||||
DebugManagerStateRestore restorer;
|
||||
debugManager.flags.UseAubStream.set(true);
|
||||
debugManager.flags.TbxPort.set(1234);
|
||||
|
||||
VariableBackup<uint16_t> backup(&aub_stream_stubs::tbxServerPort);
|
||||
|
||||
aub_stream_stubs::tbxServerPort = 4321u;
|
||||
uint16_t port = 1234u;
|
||||
EXPECT_NE(port, aub_stream_stubs::tbxServerPort);
|
||||
ASSERT_NE(port, aub_stream_stubs::tbxServerPort);
|
||||
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||
|
||||
MockAubCenter aubCenter(rootDeviceEnvironment, false, "", CommandStreamReceiverType::CSR_TBX);
|
||||
MockAubCenter aubCenter(rootDeviceEnvironment, false, "", CommandStreamReceiverType::tbx);
|
||||
EXPECT_EQ(port, aub_stream_stubs::tbxServerPort);
|
||||
}
|
||||
|
||||
@@ -62,11 +65,12 @@ TEST(AubCenter, GivenUseAubStreamAndTbxFrontdoorModeDebugVariableSetWhenAubCente
|
||||
|
||||
VariableBackup<bool> backup(&aub_stream_stubs::tbxFrontdoorMode);
|
||||
|
||||
aub_stream_stubs::tbxFrontdoorMode = false;
|
||||
EXPECT_FALSE(aub_stream_stubs::tbxFrontdoorMode);
|
||||
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||
|
||||
MockAubCenter aubCenter(rootDeviceEnvironment, false, "", CommandStreamReceiverType::CSR_TBX);
|
||||
MockAubCenter aubCenter(rootDeviceEnvironment, false, "", CommandStreamReceiverType::tbx);
|
||||
EXPECT_TRUE(aub_stream_stubs::tbxFrontdoorMode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user