|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | #include "shared/source/helpers/string.h" |
| 9 | +#include "shared/source/memory_manager/memory_operations_status.h" |
9 | 10 | #include "shared/test/common/helpers/debug_manager_state_restore.h" |
10 | 11 |
|
11 | 12 | #include "opencl/test/unit_test/mocks/mock_memory_manager.h" |
12 | 13 | #include "test.h" |
13 | 14 |
|
14 | 15 | #include "level_zero/core/source/context/context_imp.h" |
15 | 16 | #include "level_zero/core/source/driver/host_pointer_manager.h" |
| 17 | +#include "level_zero/core/source/memory/memory_operations_helper.h" |
16 | 18 | #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" |
17 | 19 | #include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h" |
18 | 20 |
|
@@ -1488,5 +1490,35 @@ TEST_F(ContextMemoryTest, givenSystemAllocatedPointerThenGetAllocPropertiesRetur |
1488 | 1490 | delete[] ptr; |
1489 | 1491 | } |
1490 | 1492 |
|
| 1493 | +TEST_F(ContextMemoryTest, givenCallTochangeMemoryOperationStatusToL0ResultTypeThenExpectedValueIsReturned) { |
| 1494 | + NEO::MemoryOperationsStatus status = NEO::MemoryOperationsStatus::SUCCESS; |
| 1495 | + ze_result_t res = changeMemoryOperationStatusToL0ResultType(status); |
| 1496 | + EXPECT_EQ(res, ZE_RESULT_SUCCESS); |
| 1497 | + |
| 1498 | + status = NEO::MemoryOperationsStatus::FAILED; |
| 1499 | + res = changeMemoryOperationStatusToL0ResultType(status); |
| 1500 | + EXPECT_EQ(res, ZE_RESULT_ERROR_DEVICE_LOST); |
| 1501 | + |
| 1502 | + status = NEO::MemoryOperationsStatus::MEMORY_NOT_FOUND; |
| 1503 | + res = changeMemoryOperationStatusToL0ResultType(status); |
| 1504 | + EXPECT_EQ(res, ZE_RESULT_ERROR_INVALID_ARGUMENT); |
| 1505 | + |
| 1506 | + status = NEO::MemoryOperationsStatus::OUT_OF_MEMORY; |
| 1507 | + res = changeMemoryOperationStatusToL0ResultType(status); |
| 1508 | + EXPECT_EQ(res, ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY); |
| 1509 | + |
| 1510 | + status = NEO::MemoryOperationsStatus::UNSUPPORTED; |
| 1511 | + res = changeMemoryOperationStatusToL0ResultType(status); |
| 1512 | + EXPECT_EQ(res, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); |
| 1513 | + |
| 1514 | + status = NEO::MemoryOperationsStatus::DEVICE_UNINITIALIZED; |
| 1515 | + res = changeMemoryOperationStatusToL0ResultType(status); |
| 1516 | + EXPECT_EQ(res, ZE_RESULT_ERROR_UNINITIALIZED); |
| 1517 | + |
| 1518 | + status = static_cast<NEO::MemoryOperationsStatus>(static_cast<uint32_t>(NEO::MemoryOperationsStatus::DEVICE_UNINITIALIZED) + 1); |
| 1519 | + res = changeMemoryOperationStatusToL0ResultType(status); |
| 1520 | + EXPECT_EQ(res, ZE_RESULT_ERROR_UNKNOWN); |
| 1521 | +} |
| 1522 | + |
1491 | 1523 | } // namespace ult |
1492 | 1524 | } // namespace L0 |
0 commit comments