Skip to content

Commit

Permalink
Move urVirtualMemGetInfo success test from a switch to individual tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
martygrant committed Jan 9, 2025
1 parent 9c652ff commit a111144
Showing 1 changed file with 12 additions and 30 deletions.
42 changes: 12 additions & 30 deletions test/conformance/virtual_memory/urVirtualMemGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,24 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <uur/fixtures.h>

using urVirtualMemGetInfoTestWithParam =
uur::urVirtualMemMappedTestWithParam<ur_virtual_mem_info_t>;
UUR_TEST_SUITE_P(urVirtualMemGetInfoTestWithParam,
::testing::Values(UR_VIRTUAL_MEM_INFO_ACCESS_MODE),
uur::deviceTestWithParamPrinter<ur_virtual_mem_info_t>);
using urVirtualMemGetInfoTest = uur::urVirtualMemMappedTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemGetInfoTest);

TEST_P(urVirtualMemGetInfoTestWithParam, Success) {
TEST_P(urVirtualMemGetInfoTest, SuccessAccessMode) {
size_t info_size = 0;
ur_virtual_mem_info_t info = getParam();
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(urVirtualMemGetInfo(context, virtual_ptr,
size, info, 0, nullptr,
&info_size),
info);
ASSERT_NE(info_size, 0);

std::vector<uint8_t> data(info_size);
ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, info,
data.size(), data.data(), nullptr));
auto info_type = UR_VIRTUAL_MEM_INFO_ACCESS_MODE;
ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, info_type, 0,
nullptr, &info_size));
ASSERT_EQ(sizeof(ur_virtual_mem_access_flags_t), size);

switch (info) {
case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: {
ASSERT_EQ(sizeof(ur_virtual_mem_access_flags_t), data.size());
ur_virtual_mem_access_flags_t flags =
*reinterpret_cast<ur_virtual_mem_access_flags_t *>(data.data());
ASSERT_TRUE(flags & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE);
} break;
ur_virtual_mem_access_flags_t returned_flags =
UR_VIRTUAL_MEM_ACCESS_FLAG_FORCE_UINT32;
ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, info_type,
info_size, &returned_flags, nullptr));

default:
FAIL() << "Unhandled ur_virtual_mem_info_t enumeration: " << info;
break;
}
ASSERT_TRUE(returned_flags & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE);
}

using urVirtualMemGetInfoTest = uur::urVirtualMemMappedTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemGetInfoTest);

TEST_P(urVirtualMemGetInfoTest, InvalidNullHandleContext) {
ur_virtual_mem_access_flags_t flags = 0;
ASSERT_EQ_RESULT(urVirtualMemGetInfo(nullptr, virtual_ptr, size,
Expand Down

0 comments on commit a111144

Please sign in to comment.