Skip to content

Commit b45ffdb

Browse files
Move drm command stream fixture to shared
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent 779bca3 commit b45ffdb

File tree

7 files changed

+13
-92
lines changed

7 files changed

+13
-92
lines changed

opencl/test/unit_test/os_interface/linux/drm_command_stream_mm_tests.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#include "shared/source/command_container/command_encoder.h"
89
#include "shared/source/execution_environment/root_device_environment.h"
910
#include "shared/source/os_interface/linux/drm_command_stream.h"
1011
#include "shared/source/os_interface/linux/drm_memory_manager.h"
@@ -18,11 +19,9 @@
1819
#include "shared/test/common/mocks/mock_execution_environment.h"
1920
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
2021
#include "shared/test/common/os_interface/linux/drm_buffer_object_fixture.h"
22+
#include "shared/test/common/os_interface/linux/drm_command_stream_fixture.h"
2123
#include "shared/test/common/test_macros/test.h"
2224

23-
#include "opencl/source/platform/platform.h"
24-
#include "opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h"
25-
2625
using namespace NEO;
2726

2827
using DrmCommandStreamMMTest = ::testing::Test;

opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
#include "shared/test/common/mocks/mock_gmm_page_table_mngr.h"
3434
#include "shared/test/common/mocks/mock_host_ptr_manager.h"
3535
#include "shared/test/common/mocks/mock_submissions_aggregator.h"
36+
#include "shared/test/common/os_interface/linux/drm_command_stream_fixture.h"
3637
#include "shared/test/common/test_macros/test.h"
3738
#include "shared/test/unit_test/helpers/gtest_helpers.h"
3839

3940
#include "opencl/source/mem_obj/buffer.h"
4041
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
4142
#include "opencl/test/unit_test/mocks/mock_buffer.h"
4243
#include "opencl/test/unit_test/mocks/mock_program.h"
43-
#include "opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h"
4444

4545
#include "drm/i915_drm.h"
4646
#include "gtest/gtest.h"

opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
#include "shared/test/common/mocks/mock_gmm_page_table_mngr.h"
3131
#include "shared/test/common/mocks/mock_host_ptr_manager.h"
3232
#include "shared/test/common/mocks/mock_submissions_aggregator.h"
33+
#include "shared/test/common/os_interface/linux/drm_command_stream_fixture.h"
3334
#include "shared/test/common/test_macros/test.h"
3435

3536
#include "opencl/source/helpers/cl_memory_properties_helpers.h"
3637
#include "opencl/source/mem_obj/buffer.h"
3738
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
3839
#include "opencl/test/unit_test/mocks/mock_buffer.h"
3940
#include "opencl/test/unit_test/mocks/mock_program.h"
40-
#include "opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h"
4141

4242
#include "drm/i915_drm.h"
4343

opencl/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#include "shared/source/command_container/command_encoder.h"
89
#include "shared/source/execution_environment/root_device_environment.h"
910
#include "shared/source/os_interface/linux/drm_command_stream.h"
1011
#include "shared/source/os_interface/linux/drm_memory_manager.h"
@@ -21,10 +22,9 @@
2122
#include "shared/test/common/mocks/mock_execution_environment.h"
2223
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
2324
#include "shared/test/common/os_interface/linux/drm_buffer_object_fixture.h"
25+
#include "shared/test/common/os_interface/linux/drm_command_stream_fixture.h"
2426
#include "shared/test/common/test_macros/test.h"
2527

26-
#include "opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h"
27-
2828
using namespace NEO;
2929

3030
struct DrmCommandStreamMultiTileMemExecFixture {

shared/test/common/os_interface/linux/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
if(UNIX)
88
target_sources(${TARGET_NAME} PRIVATE
99
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_fixture.h
1011
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.h
1112
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_cache_info.h
1213
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_device_blob.h

opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h renamed to shared/test/common/os_interface/linux/drm_command_stream_fixture.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@
77

88
#pragma once
99
#include "shared/source/command_stream/preemption.h"
10-
#include "shared/source/os_interface/linux/drm_command_stream.h"
1110
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
1211
#include "shared/source/os_interface/linux/os_context_linux.h"
13-
#include "shared/source/os_interface/os_interface.h"
1412
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1513
#include "shared/test/common/helpers/engine_descriptor_helper.h"
1614
#include "shared/test/common/libult/linux/drm_mock.h"
1715
#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
16+
#include "shared/test/common/mocks/mock_device.h"
1817
#include "shared/test/common/mocks/mock_execution_environment.h"
19-
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
20-
#include "shared/test/common/test_macros/test.h"
21-
22-
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
2318

2419
#include "gtest/gtest.h"
2520

shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,118 +5,44 @@
55
*
66
*/
77

8-
#include "shared/source/command_stream/preemption.h"
98
#include "shared/source/helpers/api_specific_config.h"
10-
#include "shared/source/os_interface/linux/drm_command_stream.h"
11-
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
12-
#include "shared/source/os_interface/linux/os_context_linux.h"
13-
#include "shared/test/common/helpers/debug_manager_state_restore.h"
14-
#include "shared/test/common/helpers/default_hw_info.h"
15-
#include "shared/test/common/helpers/engine_descriptor_helper.h"
16-
#include "shared/test/common/helpers/variable_backup.h"
17-
#include "shared/test/common/libult/linux/drm_mock.h"
18-
#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
19-
#include "shared/test/common/mocks/mock_execution_environment.h"
209
#include "shared/test/common/mocks/mock_graphics_allocation.h"
21-
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
10+
#include "shared/test/common/os_interface/linux/drm_command_stream_fixture.h"
2211
#include "shared/test/common/test_macros/test.h"
2312

24-
#include "drm/i915_drm.h"
25-
#include "gtest/gtest.h"
26-
2713
namespace NEO {
2814
extern ApiSpecificConfig::ApiType apiTypeForUlts;
2915
} //namespace NEO
3016
using namespace NEO;
3117

32-
class DrmCommandStreamTest2 : public ::testing::Test {
33-
public:
34-
template <typename GfxFamily>
35-
void SetUpT() {
36-
37-
//make sure this is disabled, we don't want to test this now
38-
DebugManager.flags.EnableForcePin.set(false);
39-
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
40-
41-
mock = new DrmMock(mockFd, *executionEnvironment.rootDeviceEnvironments[0]);
42-
mock->setupIoctlHelper(hwInfo->platform.eProductFamily);
43-
44-
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
45-
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
46-
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
47-
48-
mock->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(hwInfo));
49-
osContext = std::make_unique<OsContextLinux>(*mock, 0u,
50-
EngineDescriptorHelper::getDefaultDescriptor(HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
51-
PreemptionHelper::getDefaultPreemptionMode(*hwInfo)));
52-
osContext->ensureContextInitialized();
53-
54-
csr = new DrmCommandStreamReceiver<GfxFamily>(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerActive);
55-
ASSERT_NE(nullptr, csr);
56-
csr->setupContext(*osContext);
57-
58-
mock->ioctlCallsCount = 0u;
59-
memoryManager = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerActive,
60-
DebugManager.flags.EnableForcePin.get(),
61-
true,
62-
executionEnvironment);
63-
executionEnvironment.memoryManager.reset(memoryManager);
64-
// Memory manager creates pinBB with ioctl, expect one call
65-
EXPECT_EQ(1u, mock->ioctlCallsCount);
66-
67-
//assert we have memory manager
68-
ASSERT_NE(nullptr, memoryManager);
69-
}
70-
71-
template <typename GfxFamily>
72-
void TearDownT() {
73-
memoryManager->waitForDeletions();
74-
memoryManager->peekGemCloseWorker()->close(true);
75-
delete csr;
76-
// Expect 1 call with DRM_IOCTL_I915_GEM_CONTEXT_DESTROY request on destroyDrmContext
77-
// Expect 1 call with DRM_IOCTL_GEM_CLOSE request on BufferObject close
78-
mock->expectedIoctlCallsOnDestruction = mock->ioctlCallsCount + 2;
79-
mock->expectIoctlCallsOnDestruction = true;
80-
}
81-
82-
CommandStreamReceiver *csr = nullptr;
83-
DrmMemoryManager *memoryManager = nullptr;
84-
DrmMock *mock = nullptr;
85-
const int mockFd = 33;
86-
static const uint64_t alignment = MemoryConstants::allocationAlignment;
87-
DebugManagerStateRestore dbgState;
88-
MockExecutionEnvironment executionEnvironment;
89-
std::unique_ptr<OsContextLinux> osContext;
90-
};
91-
9218
template <typename GfxFamily>
9319
struct MockDrmCsr : public DrmCommandStreamReceiver<GfxFamily> {
9420
using DrmCommandStreamReceiver<GfxFamily>::DrmCommandStreamReceiver;
9521
using DrmCommandStreamReceiver<GfxFamily>::dispatchMode;
9622
};
9723

98-
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
24+
HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
9925
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0);
10026
MockDrmCsr<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
10127
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
10228
}
10329

104-
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) {
30+
HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) {
10531
MockGraphicsAllocation allocation{};
10632
uint32_t expectedValue = 0x1234;
10733
allocation.updateTaskCount(expectedValue, osContext->getContextId());
10834
EXPECT_EQ(expectedValue, csr->getCompletionValue(allocation));
10935
}
11036

111-
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) {
37+
HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) {
11238
csr->initializeTagAllocation();
11339
EXPECT_NE(nullptr, csr->getTagAddress());
11440
uint64_t tagAddress = castToUint64(const_cast<uint32_t *>(csr->getTagAddress()));
11541
auto expectedAddress = tagAddress + Drm::completionFenceOffset;
11642
EXPECT_EQ(expectedAddress, csr->getCompletionAddress());
11743
}
11844

119-
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, givenNoTagAddressWhenGettingCompletionAddressThenZeroIsReturned) {
45+
HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenNoTagAddressWhenGettingCompletionAddressThenZeroIsReturned) {
12046
EXPECT_EQ(nullptr, csr->getTagAddress());
12147
EXPECT_EQ(0u, csr->getCompletionAddress());
12248
}

0 commit comments

Comments
 (0)