Skip to content

Commit 9dd5ae7

Browse files
Jaime ArteagaCompute-Runtime-Automation
authored andcommitted
Add ULT for getMemoryProperties
Signed-off-by: Jaime Arteaga <[email protected]>
1 parent 584da13 commit 9dd5ae7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

level_zero/core/test/unit_tests/sources/device/test_device.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,44 @@ TEST_F(DeviceTest, whenGetExternalMemoryPropertiesIsCalledThenSuccessIsReturnedA
334334
EXPECT_TRUE(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);
335335
}
336336

337+
using DeviceGetMemoryTests = DeviceTest;
338+
339+
TEST_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesWithCountZeroThenOneIsReturned) {
340+
uint32_t count = 0;
341+
ze_result_t res = device->getMemoryProperties(&count, nullptr);
342+
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
343+
EXPECT_EQ(1u, count);
344+
}
345+
346+
TEST_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesWithNullPtrThenInvalidArgumentIsReturned) {
347+
uint32_t count = 0;
348+
ze_result_t res = device->getMemoryProperties(&count, nullptr);
349+
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
350+
EXPECT_EQ(1u, count);
351+
352+
count++;
353+
res = device->getMemoryProperties(&count, nullptr);
354+
EXPECT_EQ(res, ZE_RESULT_ERROR_INVALID_ARGUMENT);
355+
EXPECT_EQ(1u, count);
356+
}
357+
358+
TEST_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesWithNonNullPtrThenPropertiesAreReturned) {
359+
uint32_t count = 0;
360+
ze_result_t res = device->getMemoryProperties(&count, nullptr);
361+
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
362+
EXPECT_EQ(1u, count);
363+
364+
count++;
365+
ze_device_memory_properties_t memProperties = {};
366+
res = device->getMemoryProperties(&count, &memProperties);
367+
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
368+
EXPECT_EQ(1u, count);
369+
370+
EXPECT_EQ(memProperties.maxClockRate, this->neoDevice->getDeviceInfo().maxClockFrequency);
371+
EXPECT_EQ(memProperties.maxBusWidth, this->neoDevice->getDeviceInfo().addressBits);
372+
EXPECT_EQ(memProperties.totalSize, this->neoDevice->getDeviceInfo().globalMemSize);
373+
}
374+
337375
struct DeviceHasNoDoubleFp64Test : public ::testing::Test {
338376
void SetUp() override {
339377
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);

0 commit comments

Comments
 (0)