Skip to content

Commit

Permalink
Switching HAL CTS to use TEST_F. (iree-org#17844)
Browse files Browse the repository at this point in the history
This allows tests to use parameters if they want to (and they do!).
  • Loading branch information
benvanik authored Jul 10, 2024
1 parent 8513e5f commit 6f25718
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 122 deletions.
1 change: 0 additions & 1 deletion build_tools/cmake/iree_hal_cts_test_suite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ function(iree_hal_cts_test_suite)
set(IREE_CTS_TEST_FILE_PATH "runtime/src/iree/hal/cts/${_TEST_NAME}_test.h")
set(IREE_CTS_DRIVER_REGISTRATION_HDR "${_RULE_DRIVER_REGISTRATION_HDR}")
set(IREE_CTS_DRIVER_REGISTRATION_FN "${_RULE_DRIVER_REGISTRATION_FN}")
set(IREE_CTS_TEST_CLASS_NAME "${_TEST_NAME}_test")
set(IREE_CTS_DRIVER_NAME "${_RULE_DRIVER_NAME}")
set(IREE_CTS_TARGET_BACKEND "${_RULE_COMPILER_TARGET_BACKEND}")

Expand Down
8 changes: 4 additions & 4 deletions runtime/src/iree/hal/cts/allocator_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ constexpr iree_device_size_t kAllocationSize = 1024;

} // namespace

class allocator_test : public CtsTestBase {};
class allocator_test : public CTSTestBase<> {};

// All allocators must support some baseline capabilities.
//
// Certain capabilities or configurations are optional and may vary between
// driver implementations or target devices, such as:
// IREE_HAL_MEMORY_TYPE_HOST_LOCAL | IREE_HAL_MEMORY_TYPE_DEVICE_LOCAL
// IREE_HAL_BUFFER_USAGE_MAPPING
TEST_P(allocator_test, BaselineBufferCompatibility) {
TEST_F(allocator_test, BaselineBufferCompatibility) {
// Need at least one way to get data between the host and device.
iree_hal_buffer_params_t host_local_params = {0};
host_local_params.type =
Expand Down Expand Up @@ -80,7 +80,7 @@ TEST_P(allocator_test, BaselineBufferCompatibility) {
IREE_HAL_BUFFER_COMPATIBILITY_QUEUE_DISPATCH));
}

TEST_P(allocator_test, AllocateBuffer) {
TEST_F(allocator_test, AllocateBuffer) {
iree_hal_buffer_params_t params = {0};
params.type = IREE_HAL_MEMORY_TYPE_DEVICE_LOCAL;
params.usage = IREE_HAL_BUFFER_USAGE_TRANSFER;
Expand All @@ -102,7 +102,7 @@ TEST_P(allocator_test, AllocateBuffer) {

// While empty allocations aren't particularly useful, they can occur in
// practice so we should at least be able to create them without errors.
TEST_P(allocator_test, AllocateEmptyBuffer) {
TEST_F(allocator_test, AllocateEmptyBuffer) {
iree_hal_buffer_params_t params = {0};
params.type = IREE_HAL_MEMORY_TYPE_DEVICE_LOCAL;
params.usage = IREE_HAL_BUFFER_USAGE_TRANSFER;
Expand Down
34 changes: 17 additions & 17 deletions runtime/src/iree/hal/cts/buffer_mapping_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ constexpr iree_device_size_t kDefaultAllocationSize = 1024;
// * write with an offset and length
// * write into a subspan of a buffer

class buffer_mapping_test : public CtsTestBase {
class buffer_mapping_test : public CTSTestBase<> {
protected:
void AllocateUninitializedBuffer(iree_device_size_t buffer_size,
iree_hal_buffer_t** out_buffer) {
Expand All @@ -59,7 +59,7 @@ class buffer_mapping_test : public CtsTestBase {
}
};

TEST_P(buffer_mapping_test, AllocatorSupportsBufferMapping) {
TEST_F(buffer_mapping_test, AllocatorSupportsBufferMapping) {
iree_hal_buffer_params_t params = {0};
params.type = IREE_HAL_MEMORY_TYPE_HOST_VISIBLE;
params.usage = IREE_HAL_BUFFER_USAGE_MAPPING;
Expand All @@ -83,7 +83,7 @@ TEST_P(buffer_mapping_test, AllocatorSupportsBufferMapping) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, ZeroWholeBuffer) {
TEST_F(buffer_mapping_test, ZeroWholeBuffer) {
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(kDefaultAllocationSize, &buffer);

Expand All @@ -102,7 +102,7 @@ TEST_P(buffer_mapping_test, ZeroWholeBuffer) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, ZeroWithOffset) {
TEST_F(buffer_mapping_test, ZeroWithOffset) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand All @@ -128,7 +128,7 @@ TEST_P(buffer_mapping_test, ZeroWithOffset) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, ZeroSubspan) {
TEST_F(buffer_mapping_test, ZeroSubspan) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand Down Expand Up @@ -171,7 +171,7 @@ TEST_P(buffer_mapping_test, ZeroSubspan) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, FillEmpty) {
TEST_F(buffer_mapping_test, FillEmpty) {
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(kDefaultAllocationSize, &buffer);

Expand All @@ -195,7 +195,7 @@ TEST_P(buffer_mapping_test, FillEmpty) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, FillWholeBuffer) {
TEST_F(buffer_mapping_test, FillWholeBuffer) {
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(kDefaultAllocationSize, &buffer);

Expand All @@ -217,7 +217,7 @@ TEST_P(buffer_mapping_test, FillWholeBuffer) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, FillWithOffset) {
TEST_F(buffer_mapping_test, FillWithOffset) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand All @@ -244,7 +244,7 @@ TEST_P(buffer_mapping_test, FillWithOffset) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, FillSubspan) {
TEST_F(buffer_mapping_test, FillSubspan) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand Down Expand Up @@ -288,7 +288,7 @@ TEST_P(buffer_mapping_test, FillSubspan) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, ReadData) {
TEST_F(buffer_mapping_test, ReadData) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand Down Expand Up @@ -325,7 +325,7 @@ TEST_P(buffer_mapping_test, ReadData) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, ReadDataSubspan) {
TEST_F(buffer_mapping_test, ReadDataSubspan) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand Down Expand Up @@ -368,7 +368,7 @@ TEST_P(buffer_mapping_test, ReadDataSubspan) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, WriteDataWholeBuffer) {
TEST_F(buffer_mapping_test, WriteDataWholeBuffer) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand All @@ -390,7 +390,7 @@ TEST_P(buffer_mapping_test, WriteDataWholeBuffer) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, WriteDataWithOffset) {
TEST_F(buffer_mapping_test, WriteDataWithOffset) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand All @@ -417,7 +417,7 @@ TEST_P(buffer_mapping_test, WriteDataWithOffset) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, WriteDataSubspan) {
TEST_F(buffer_mapping_test, WriteDataSubspan) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand Down Expand Up @@ -459,7 +459,7 @@ TEST_P(buffer_mapping_test, WriteDataSubspan) {
iree_hal_buffer_release(buffer);
}

TEST_P(buffer_mapping_test, CopyData) {
TEST_F(buffer_mapping_test, CopyData) {
iree_hal_buffer_t* buffer_a = NULL;
iree_hal_buffer_t* buffer_b = NULL;
AllocateUninitializedBuffer(kDefaultAllocationSize, &buffer_a);
Expand Down Expand Up @@ -490,7 +490,7 @@ TEST_P(buffer_mapping_test, CopyData) {

// Maps a buffer range for reading from device -> host.
// This is roughly what iree_hal_buffer_map_read does internally.
TEST_P(buffer_mapping_test, MapRangeRead) {
TEST_F(buffer_mapping_test, MapRangeRead) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand Down Expand Up @@ -520,7 +520,7 @@ TEST_P(buffer_mapping_test, MapRangeRead) {

// Maps a buffer range for writing from host -> device.
// This is roughly what iree_hal_buffer_map_write does internally.
TEST_P(buffer_mapping_test, MapRangeWrite) {
TEST_F(buffer_mapping_test, MapRangeWrite) {
iree_device_size_t buffer_size = 16;
iree_hal_buffer_t* buffer = NULL;
AllocateUninitializedBuffer(buffer_size, &buffer);
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/iree/hal/cts/command_buffer_dispatch_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace iree {
namespace hal {
namespace cts {

class command_buffer_dispatch_test : public CtsTestBase {
class command_buffer_dispatch_test : public CTSTestBase<> {
protected:
void PrepareAbsExecutable() {
IREE_ASSERT_OK(iree_hal_executable_cache_create(
Expand Down Expand Up @@ -76,7 +76,7 @@ class command_buffer_dispatch_test : public CtsTestBase {
iree_hal_executable_t* executable_ = NULL;
};

TEST_P(command_buffer_dispatch_test, DispatchAbs) {
TEST_F(command_buffer_dispatch_test, DispatchAbs) {
PrepareAbsExecutable();

iree_hal_command_buffer_t* command_buffer = NULL;
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/iree/hal/cts/command_buffer_push_constants_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace cts {

using ::testing::ContainerEq;

class command_buffer_push_constants_test : public CtsTestBase {
class command_buffer_push_constants_test : public CTSTestBase<> {
protected:
void PrepareExecutable() {
IREE_ASSERT_OK(iree_hal_executable_cache_create(
Expand Down Expand Up @@ -77,7 +77,7 @@ class command_buffer_push_constants_test : public CtsTestBase {
iree_hal_executable_t* executable_ = NULL;
};

TEST_P(command_buffer_push_constants_test, DispatchWithPushConstants) {
TEST_F(command_buffer_push_constants_test, DispatchWithPushConstants) {
ASSERT_NO_FATAL_FAILURE(PrepareExecutable());

iree_hal_command_buffer_t* command_buffer = NULL;
Expand Down
Loading

0 comments on commit 6f25718

Please sign in to comment.