|
| 1 | +// Copyright (C) 2024 Intel Corporation |
| 2 | +// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. |
| 3 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | + |
| 5 | +#include "memspace_helpers.hpp" |
| 6 | + |
| 7 | +#include <umf/base.h> |
| 8 | +#include <umf/memspace.h> |
| 9 | +#include <umf/memtarget.h> |
| 10 | + |
| 11 | +using umf_test::test; |
| 12 | + |
| 13 | +TEST_F(test, memTargetNuma) { |
| 14 | + auto memspace = umfMemspaceHostAllGet(); |
| 15 | + ASSERT_NE(memspace, nullptr); |
| 16 | + |
| 17 | + for (size_t i = 0; i < umfMemspaceMemtargetNum(memspace); i++) { |
| 18 | + auto hTarget = umfMemspaceMemtargetGet(memspace, i); |
| 19 | + ASSERT_NE(hTarget, nullptr); |
| 20 | + umf_memtarget_type_t type; |
| 21 | + auto ret = umfMemtargetGetType(hTarget, &type); |
| 22 | + EXPECT_EQ(ret, UMF_RESULT_SUCCESS); |
| 23 | + EXPECT_EQ(type, UMF_MEMTARGET_TYPE_NUMA); |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +TEST_F(test, memTargetInvalid) { |
| 28 | + auto memspace = umfMemspaceHostAllGet(); |
| 29 | + ASSERT_NE(memspace, nullptr); |
| 30 | + umf_memtarget_type_t type; |
| 31 | + auto ret = umfMemtargetGetType(NULL, &type); |
| 32 | + EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT); |
| 33 | + ret = umfMemtargetGetType(NULL, NULL); |
| 34 | + EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT); |
| 35 | + auto hTarget = umfMemspaceMemtargetGet(memspace, 0); |
| 36 | + ASSERT_NE(hTarget, nullptr); |
| 37 | + ret = umfMemtargetGetType(hTarget, NULL); |
| 38 | + EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT); |
| 39 | +} |
0 commit comments