Skip to content

Commit

Permalink
[UR][CTS] Add invalid size test to urPhysicalMemCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Vesely committed Jun 29, 2023
1 parent 7acf7a8 commit c06763b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/conformance/testing/include/uur/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ struct urPhysicalMemTest : urContextTest {
ASSERT_NE(physical_mem, nullptr);
}

void TearDown() {
void TearDown() override {
if (physical_mem) {
EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem));
}
Expand Down
14 changes: 13 additions & 1 deletion test/conformance/virtual_memory/urPhysicalMemCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using urPhysicalMemCreateTestParams = size_t;
struct urPhysicalMemCreateTest
: uur::urContextTestWithParam<urPhysicalMemCreateTestParams> {

void SetUp() {
void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(uur::urContextTestWithParam<
urPhysicalMemCreateTestParams>::SetUp());
ASSERT_SUCCESS(urVirtualMemGranularityGetInfo(
Expand Down Expand Up @@ -54,3 +54,15 @@ TEST_P(urPhysicalMemCreateTest, InvalidNullPointerPhysicalMem) {
urPhysicalMemCreate(context, device, size, nullptr, nullptr),
UR_RESULT_ERROR_INVALID_NULL_POINTER);
}

TEST_P(urPhysicalMemCreateTest, InvalidSize) {
if (granularity == 1) {
GTEST_SKIP()
<< "A granularity of 1 means that any size will be accepted.";
}
ur_physical_mem_handle_t physical_mem = nullptr;
size_t invalid_size = size - 1;
ASSERT_EQ_RESULT(urPhysicalMemCreate(context, device, invalid_size, nullptr,
&physical_mem),
UR_RESULT_ERROR_INVALID_SIZE);
}

0 comments on commit c06763b

Please sign in to comment.