Skip to content

Commit 0ec6ef1

Browse files
Move AubHelper tests to inl file
Change-Id: I2a535b2ff46be6f9a695dde934b981d58267b2d1 Signed-off-by: Maciej Dziuban <[email protected]>
1 parent 44491a1 commit 0ec6ef1

File tree

3 files changed

+152
-143
lines changed

3 files changed

+152
-143
lines changed

unit_tests/aub/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#
2-
# Copyright (C) 2018 Intel Corporation
2+
# Copyright (C) 2018-2019 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
66

77
set(IGDRCL_SRCS_aub_helper_tests
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}/aub_center_tests.cpp
10-
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_tests.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/aub_helper_tests.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_tests.inl
1112
)
1213

1314
if(NOT DEFINED AUB_STREAM_DIR)
Lines changed: 2 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,8 @@
11
/*
2-
* Copyright (C) 2018-2019 Intel Corporation
2+
* Copyright (C) 2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

8-
#include "gtest/gtest.h"
9-
#include "runtime/aub/aub_helper.h"
10-
#include "runtime/aub_mem_dump/aub_mem_dump.h"
11-
#include "runtime/aub_mem_dump/page_table_entry_bits.h"
12-
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
13-
#include "runtime/helpers/basic_math.h"
14-
#include "unit_tests/fixtures/device_fixture.h"
15-
#include "unit_tests/helpers/debug_manager_state_restore.h"
16-
#include "test.h"
17-
18-
using namespace OCLRT;
19-
20-
TEST(AubHelper, WhenGetMemTraceIsCalledWithZeroPDEntryBitsThenTraceNonLocalIsReturned) {
21-
int hint = AubHelper::getMemTrace(0u);
22-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceNonlocal, hint);
23-
}
24-
25-
TEST(AubHelper, WhenGetPTEntryBitsIsCalledThenEntryBitsAreNotMasked) {
26-
uint64_t entryBits = BIT(PageTableEntry::presentBit) |
27-
BIT(PageTableEntry::writableBit) |
28-
BIT(PageTableEntry::userSupervisorBit);
29-
uint64_t maskedEntryBits = AubHelper::getPTEntryBits(entryBits);
30-
EXPECT_EQ(entryBits, maskedEntryBits);
31-
}
32-
33-
TEST(AubHelper, WhenCreateMultipleDevicesIsSetThenGetDevicesCountReturnedCorrectValue) {
34-
DebugManagerStateRestore stateRestore;
35-
FeatureTable skuTable = {};
36-
WorkaroundTable waTable = {};
37-
RuntimeCapabilityTable capTable = {};
38-
GT_SYSTEM_INFO sysInfo = {};
39-
PLATFORM platform = {};
40-
HardwareInfo hwInfo{&platform, &skuTable, &waTable, &sysInfo, capTable};
41-
DebugManager.flags.CreateMultipleDevices.set(2);
42-
43-
uint32_t devicesCount = AubHelper::getDevicesCount(&hwInfo);
44-
EXPECT_EQ(devicesCount, 2u);
45-
46-
DebugManager.flags.CreateMultipleDevices.set(0);
47-
devicesCount = AubHelper::getDevicesCount(&hwInfo);
48-
EXPECT_EQ(devicesCount, 1u);
49-
}
50-
51-
TEST(AubHelper, WhenGetMemBankSizeIsCalledThenItReturnsCorrectValue) {
52-
auto memBankSize = AubHelper::getMemBankSize();
53-
EXPECT_EQ(memBankSize, 2 * GB);
54-
}
55-
56-
typedef Test<DeviceFixture> AubHelperHwTest;
57-
58-
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPml4EntryIsCalledThenTraceNotypeIsReturned) {
59-
AubHelperHw<FamilyType> aubHelper(false);
60-
int dataHint = aubHelper.getDataHintForPml4Entry();
61-
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint);
62-
}
63-
64-
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPdpEntryIsCalledThenTraceNotypeIsReturned) {
65-
AubHelperHw<FamilyType> aubHelper(false);
66-
int dataHint = aubHelper.getDataHintForPdpEntry();
67-
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint);
68-
}
69-
70-
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPdEntryIsCalledThenTraceNotypeIsReturned) {
71-
AubHelperHw<FamilyType> aubHelper(false);
72-
int dataHint = aubHelper.getDataHintForPdEntry();
73-
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint);
74-
}
75-
76-
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPtEntryIsCalledThenTraceNotypeIsReturned) {
77-
AubHelperHw<FamilyType> aubHelper(false);
78-
int dataHint = aubHelper.getDataHintForPtEntry();
79-
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint);
80-
}
81-
82-
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPml4EntryIsCalledThenTracePml4EntryIsReturned) {
83-
AubHelperHw<FamilyType> aubHelper(false);
84-
int addressSpace = aubHelper.getMemTraceForPml4Entry();
85-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePml4Entry, addressSpace);
86-
}
87-
88-
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPdpEntryIsCalledThenTracePhysicalPdpEntryIsReturned) {
89-
AubHelperHw<FamilyType> aubHelper(false);
90-
int addressSpace = aubHelper.getMemTraceForPdpEntry();
91-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePhysicalPdpEntry, addressSpace);
92-
}
93-
94-
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPd4EntryIsCalledThenTracePpgttPdEntryIsReturned) {
95-
AubHelperHw<FamilyType> aubHelper(false);
96-
int addressSpace = aubHelper.getMemTraceForPdEntry();
97-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePpgttPdEntry, addressSpace);
98-
}
99-
100-
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPtEntryIsCalledThenTracePpgttEntryIsReturned) {
101-
AubHelperHw<FamilyType> aubHelper(false);
102-
int addressSpace = aubHelper.getMemTraceForPtEntry();
103-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePpgttEntry, addressSpace);
104-
}
105-
106-
HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPml4EntryIsCalledThenTraceLocalIsReturned) {
107-
AubHelperHw<FamilyType> aubHelper(true);
108-
int addressSpace = aubHelper.getMemTraceForPml4Entry();
109-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace);
110-
}
111-
112-
HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPdpEntryIsCalledThenTraceLocalIsReturned) {
113-
AubHelperHw<FamilyType> aubHelper(true);
114-
int addressSpace = aubHelper.getMemTraceForPdpEntry();
115-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace);
116-
}
117-
118-
HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPd4EntryIsCalledThenTraceLocalIsReturned) {
119-
AubHelperHw<FamilyType> aubHelper(true);
120-
int addressSpace = aubHelper.getMemTraceForPdEntry();
121-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace);
122-
}
123-
124-
HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPtEntryIsCalledThenTraceLocalIsReturned) {
125-
AubHelperHw<FamilyType> aubHelper(true);
126-
int addressSpace = aubHelper.getMemTraceForPtEntry();
127-
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace);
128-
}
129-
130-
struct MockLrcaHelper : AubMemDump::LrcaHelper {
131-
mutable uint32_t setContextSaveRestoreFlagsCalled = 0;
132-
MockLrcaHelper(uint32_t base) : AubMemDump::LrcaHelper(base) {}
133-
void setContextSaveRestoreFlags(uint32_t &value) const override {
134-
setContextSaveRestoreFlagsCalled++;
135-
AubMemDump::LrcaHelper::setContextSaveRestoreFlags(value);
136-
}
137-
};
138-
139-
HWTEST_F(AubHelperHwTest, giverLrcaHelperWhenContextIsInitializedThenContextFlagsAreSet) {
140-
const auto &csTraits = CommandStreamReceiverSimulatedCommonHw<FamilyType>::getCsTraits(EngineType::ENGINE_RCS);
141-
MockLrcaHelper lrcaHelper(csTraits.mmioBase);
142-
143-
std::unique_ptr<void, std::function<void(void *)>> lrcaBase(alignedMalloc(csTraits.sizeLRCA, csTraits.alignLRCA), alignedFree);
144-
145-
lrcaHelper.initialize(lrcaBase.get());
146-
ASSERT_NE(0u, lrcaHelper.setContextSaveRestoreFlagsCalled);
147-
}
8+
#include "unit_tests/aub/aub_helper_tests.inl"
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* Copyright (C) 2018-2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "gtest/gtest.h"
9+
#include "runtime/aub/aub_helper.h"
10+
#include "runtime/aub_mem_dump/aub_mem_dump.h"
11+
#include "runtime/aub_mem_dump/page_table_entry_bits.h"
12+
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
13+
#include "runtime/helpers/basic_math.h"
14+
#include "unit_tests/fixtures/device_fixture.h"
15+
#include "unit_tests/helpers/debug_manager_state_restore.h"
16+
#include "test.h"
17+
18+
using namespace OCLRT;
19+
20+
TEST(AubHelper, WhenGetMemTraceIsCalledWithZeroPDEntryBitsThenTraceNonLocalIsReturned) {
21+
int hint = AubHelper::getMemTrace(0u);
22+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceNonlocal, hint);
23+
}
24+
25+
TEST(AubHelper, WhenGetPTEntryBitsIsCalledThenEntryBitsAreNotMasked) {
26+
uint64_t entryBits = BIT(PageTableEntry::presentBit) |
27+
BIT(PageTableEntry::writableBit) |
28+
BIT(PageTableEntry::userSupervisorBit);
29+
uint64_t maskedEntryBits = AubHelper::getPTEntryBits(entryBits);
30+
EXPECT_EQ(entryBits, maskedEntryBits);
31+
}
32+
33+
TEST(AubHelper, WhenCreateMultipleDevicesIsSetThenGetDevicesCountReturnedCorrectValue) {
34+
DebugManagerStateRestore stateRestore;
35+
FeatureTable skuTable = {};
36+
WorkaroundTable waTable = {};
37+
RuntimeCapabilityTable capTable = {};
38+
GT_SYSTEM_INFO sysInfo = {};
39+
PLATFORM platform = {};
40+
HardwareInfo hwInfo{&platform, &skuTable, &waTable, &sysInfo, capTable};
41+
DebugManager.flags.CreateMultipleDevices.set(2);
42+
43+
uint32_t devicesCount = AubHelper::getDevicesCount(&hwInfo);
44+
EXPECT_EQ(devicesCount, 2u);
45+
46+
DebugManager.flags.CreateMultipleDevices.set(0);
47+
devicesCount = AubHelper::getDevicesCount(&hwInfo);
48+
EXPECT_EQ(devicesCount, 1u);
49+
}
50+
51+
TEST(AubHelper, WhenGetMemBankSizeIsCalledThenItReturnsCorrectValue) {
52+
auto memBankSize = AubHelper::getMemBankSize();
53+
EXPECT_EQ(memBankSize, 2 * GB);
54+
}
55+
56+
typedef Test<DeviceFixture> AubHelperHwTest;
57+
58+
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPml4EntryIsCalledThenTraceNotypeIsReturned) {
59+
AubHelperHw<FamilyType> aubHelper(false);
60+
int dataHint = aubHelper.getDataHintForPml4Entry();
61+
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint);
62+
}
63+
64+
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPdpEntryIsCalledThenTraceNotypeIsReturned) {
65+
AubHelperHw<FamilyType> aubHelper(false);
66+
int dataHint = aubHelper.getDataHintForPdpEntry();
67+
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint);
68+
}
69+
70+
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPdEntryIsCalledThenTraceNotypeIsReturned) {
71+
AubHelperHw<FamilyType> aubHelper(false);
72+
int dataHint = aubHelper.getDataHintForPdEntry();
73+
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint);
74+
}
75+
76+
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPtEntryIsCalledThenTraceNotypeIsReturned) {
77+
AubHelperHw<FamilyType> aubHelper(false);
78+
int dataHint = aubHelper.getDataHintForPtEntry();
79+
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint);
80+
}
81+
82+
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPml4EntryIsCalledThenTracePml4EntryIsReturned) {
83+
AubHelperHw<FamilyType> aubHelper(false);
84+
int addressSpace = aubHelper.getMemTraceForPml4Entry();
85+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePml4Entry, addressSpace);
86+
}
87+
88+
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPdpEntryIsCalledThenTracePhysicalPdpEntryIsReturned) {
89+
AubHelperHw<FamilyType> aubHelper(false);
90+
int addressSpace = aubHelper.getMemTraceForPdpEntry();
91+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePhysicalPdpEntry, addressSpace);
92+
}
93+
94+
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPd4EntryIsCalledThenTracePpgttPdEntryIsReturned) {
95+
AubHelperHw<FamilyType> aubHelper(false);
96+
int addressSpace = aubHelper.getMemTraceForPdEntry();
97+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePpgttPdEntry, addressSpace);
98+
}
99+
100+
HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPtEntryIsCalledThenTracePpgttEntryIsReturned) {
101+
AubHelperHw<FamilyType> aubHelper(false);
102+
int addressSpace = aubHelper.getMemTraceForPtEntry();
103+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePpgttEntry, addressSpace);
104+
}
105+
106+
HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPml4EntryIsCalledThenTraceLocalIsReturned) {
107+
AubHelperHw<FamilyType> aubHelper(true);
108+
int addressSpace = aubHelper.getMemTraceForPml4Entry();
109+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace);
110+
}
111+
112+
HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPdpEntryIsCalledThenTraceLocalIsReturned) {
113+
AubHelperHw<FamilyType> aubHelper(true);
114+
int addressSpace = aubHelper.getMemTraceForPdpEntry();
115+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace);
116+
}
117+
118+
HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPd4EntryIsCalledThenTraceLocalIsReturned) {
119+
AubHelperHw<FamilyType> aubHelper(true);
120+
int addressSpace = aubHelper.getMemTraceForPdEntry();
121+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace);
122+
}
123+
124+
HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPtEntryIsCalledThenTraceLocalIsReturned) {
125+
AubHelperHw<FamilyType> aubHelper(true);
126+
int addressSpace = aubHelper.getMemTraceForPtEntry();
127+
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace);
128+
}
129+
130+
struct MockLrcaHelper : AubMemDump::LrcaHelper {
131+
mutable uint32_t setContextSaveRestoreFlagsCalled = 0;
132+
MockLrcaHelper(uint32_t base) : AubMemDump::LrcaHelper(base) {}
133+
void setContextSaveRestoreFlags(uint32_t &value) const override {
134+
setContextSaveRestoreFlagsCalled++;
135+
AubMemDump::LrcaHelper::setContextSaveRestoreFlags(value);
136+
}
137+
};
138+
139+
HWTEST_F(AubHelperHwTest, giverLrcaHelperWhenContextIsInitializedThenContextFlagsAreSet) {
140+
const auto &csTraits = CommandStreamReceiverSimulatedCommonHw<FamilyType>::getCsTraits(EngineType::ENGINE_RCS);
141+
MockLrcaHelper lrcaHelper(csTraits.mmioBase);
142+
143+
std::unique_ptr<void, std::function<void(void *)>> lrcaBase(alignedMalloc(csTraits.sizeLRCA, csTraits.alignLRCA), alignedFree);
144+
145+
lrcaHelper.initialize(lrcaBase.get());
146+
ASSERT_NE(0u, lrcaHelper.setContextSaveRestoreFlagsCalled);
147+
}

0 commit comments

Comments
 (0)