Refactor the HAL CTS for out of tree / individual drivers. (#7887)
Fixes https://github.com/google/iree/issues/4643
This refactors the Hardware Abstraction Layer's Conformance Test Suite into a set of libraries and parameterized test suites that can be instantiated for individual HAL drivers using a new CMake function. This way, we can filter tests/drivers within the build system and can support drivers that are not added to the global test registry.
The tests are still written as googletest [Value-Parameterized Tests](https://google.github.io/googletest/advanced.html#value-parameterized-tests), but they are now _abstract tests_ as well. The CMake function creates a concrete implementation of each test in the suite using a template file. Here is an example of a generated test file:
```c++
// clang-format off
#define IREE_CTS_TEST_FILE_PATH "iree/hal/cts/descriptor_set_layout_test.h"
#define IREE_CTS_TEST_CLASS_NAME DescriptorSetLayoutTest
#define IREE_CTS_DRIVER_NAME "vmvx"
// clang-format on
#include IREE_CTS_TEST_FILE_PATH
#include "iree/hal/cts/cts_test_base.h"
#include "iree/testing/gtest.h"
namespace iree {
namespace hal {
namespace cts {
INSTANTIATE_TEST_SUITE_P(CTS, IREE_CTS_TEST_CLASS_NAME,
::testing::Values(IREE_CTS_DRIVER_NAME),
GenerateTestName());
} // namespace cts
} // namespace hal
} // namespace iree
```
(I referenced https://crascit.com/2017/04/18/generated-sources-in-cmake-builds/ for guidance on generating files from templates in CMake)
This also drops support for running these tests through Bazel. Support could be added back, but the file and test generation is sufficiently weird that I'd rather not support both build systems. I also think we have sufficient CI coverage for the HAL in open source (where nearly all HAL development happens) using CMake that Bazel support won't be very useful.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a7856a4..5eac4c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -263,6 +263,7 @@
include(iree_trace_runner_test)
include(iree_run_binary_test)
include(iree_benchmark_suite)
+include(iree_hal_cts_test_suite)
set(DEFAULT_CMAKE_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
diff --git a/build_tools/cmake/iree_hal_cts_test_suite.cmake b/build_tools/cmake/iree_hal_cts_test_suite.cmake
new file mode 100644
index 0000000..68f166b
--- /dev/null
+++ b/build_tools/cmake/iree_hal_cts_test_suite.cmake
@@ -0,0 +1,79 @@
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+include(CMakeParseArguments)
+
+# iree_hal_cts_test_suite()
+#
+# Creates a set of tests for a provided Hardware Abstraction Layer (HAL) driver,
+# with one generated test for each test in the Conformance Test Suite (CTS).
+#
+# Parameters:
+# DRIVER_NAME: The name of the driver to test. Used for both target names and
+# for `iree_hal_driver_registry_try_create_by_name()` within test code.
+# DRIVER_REGISTRATION_HDR: The C #include path for `DRIVER_REGISTRATION_FN`.
+# DRIVER_REGISTRATION_FN: The C function which registers `DRIVER_NAME`.
+# DEPS: List of other libraries to link in to the binary targets (typically
+# the dependency for `DRIVER_REGISTRATION_HDR`).
+# EXCLUDED_TESTS: List of test names from `IREE_ALL_CTS_TESTS` to
+# exclude from the test suite for this driver.
+# LABELS: Additional labels to forward to `iree_cc_test`. The package path
+# and "driver=${DRIVER}" are added automatically.
+function(iree_hal_cts_test_suite)
+ if(NOT IREE_BUILD_TESTS)
+ return()
+ endif()
+
+ cmake_parse_arguments(
+ _RULE
+ ""
+ "DRIVER_NAME;DRIVER_REGISTRATION_HDR;DRIVER_REGISTRATION_FN"
+ "DEPS;EXCLUDED_TESTS;LABELS"
+ ${ARGN}
+ )
+
+ list(APPEND _RULE_LABELS "driver=${_RULE_DRIVER_NAME}")
+
+ foreach(_TEST_NAME ${IREE_ALL_CTS_TESTS})
+ if("${_TEST_NAME}" IN_LIST _RULE_EXCLUDED_TESTS)
+ continue()
+ endif()
+
+ # Note: driver names may contain dashes and other special characters. We
+ # could sanitize for file and target names, but passing through directly
+ # may be more intuitive.
+ set(_TEST_SOURCE_NAME "${_TEST_NAME}_${_RULE_DRIVER_NAME}_test.cc")
+ set(_TEST_LIBRARY_DEP "iree::hal::cts::${_TEST_NAME}_test_library")
+
+ # Generate the source file for this [test x driver] pair.
+ # TODO(scotttodd): Move to build time instead of configure time?
+ set(IREE_CTS_TEST_FILE_PATH "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}")
+ configure_file(
+ "${IREE_ROOT_DIR}/iree/hal/cts/cts_test_template.cc.in"
+ ${_TEST_SOURCE_NAME}
+ )
+
+ iree_cc_test(
+ NAME
+ ${_RULE_DRIVER_NAME}_${_TEST_NAME}_test
+ SRCS
+ "${CMAKE_CURRENT_BINARY_DIR}/${_TEST_SOURCE_NAME}"
+ DEPS
+ ${_RULE_DEPS}
+ ${_TEST_LIBRARY_DEP}
+ iree::base
+ iree::hal
+ iree::hal::cts::cts_test_base
+ iree::testing::gtest_main
+ LABELS
+ ${_RULE_LABELS}
+ )
+ endforeach()
+endfunction()
diff --git a/build_tools/kokoro/gcp_ubuntu/cmake/linux/x86-swiftshader-asan/build.sh b/build_tools/kokoro/gcp_ubuntu/cmake/linux/x86-swiftshader-asan/build.sh
index a592da4..3a6ee97 100755
--- a/build_tools/kokoro/gcp_ubuntu/cmake/linux/x86-swiftshader-asan/build.sh
+++ b/build_tools/kokoro/gcp_ubuntu/cmake/linux/x86-swiftshader-asan/build.sh
@@ -102,15 +102,6 @@
declare -a excluded_tests=(
"iree/base/internal/file_io_test"
"bindings/tflite/smoke_test"
- "iree/hal/cts/allocator_test"
- "iree/hal/cts/buffer_mapping_test"
- "iree/hal/cts/command_buffer_test"
- "iree/hal/cts/descriptor_set_layout_test"
- "iree/hal/cts/driver_test"
- "iree/hal/cts/event_test"
- "iree/hal/cts/executable_layout_test"
- "iree/hal/cts/semaphore_submission_test"
- "iree/hal/cts/semaphore_test"
"iree/modules/check/check_test"
"iree/samples/simple_embedding/simple_embedding_vulkan_test"
)
diff --git a/docs/developers/get_started/getting_started_linux_vulkan.md b/docs/developers/get_started/getting_started_linux_vulkan.md
index 85903c0..5fba4e7 100644
--- a/docs/developers/get_started/getting_started_linux_vulkan.md
+++ b/docs/developers/get_started/getting_started_linux_vulkan.md
@@ -58,16 +58,14 @@
HAL, which includes checking for supported layers and extensions.
Run the
-[driver test](https://github.com/google/iree/blob/main/iree/hal/cts/driver_test.cc):
+[driver test](https://github.com/google/iree/blob/main/iree/hal/cts/driver_test.h):
```shell
# -- CMake --
$ export VK_LOADER_DEBUG=all
-$ cmake --build ../iree-build/ --target iree_hal_cts_driver_test
-$ ../iree-build/iree/hal/cts/iree_hal_cts_driver_test
-
-# -- Bazel --
-$ bazel test iree/hal/cts:driver_test --test_env=VK_LOADER_DEBUG=all --test_output=all
+$ cmake --build ../iree-build/ --target iree_hal_vulkan_cts_vulkan_driver_test
+$ cd ../iree-build/
+$ ctest -R iree/hal/vulkan/cts/vulkan_driver_test
```
If these tests pass, you can skip down to the next section.
diff --git a/docs/developers/get_started/getting_started_windows_vulkan.md b/docs/developers/get_started/getting_started_windows_vulkan.md
index d5f43aa..938db53 100644
--- a/docs/developers/get_started/getting_started_windows_vulkan.md
+++ b/docs/developers/get_started/getting_started_windows_vulkan.md
@@ -63,11 +63,8 @@
```powershell
# -- CMake --
> set VK_LOADER_DEBUG=all
-> cmake --build ..\iree-build\ --target iree_hal_cts_driver_test
-> ..\iree-build\iree\hal\cts\iree_hal_cts_driver_test.exe
-
-# -- Bazel --
-> bazel test iree/hal/cts:driver_test --test_env=VK_LOADER_DEBUG=all --test_output=all
+> cmake --build ..\iree-build\ --target iree_hal_vulkan_cts_vulkan_driver_test
+> ctest -R iree/hal/vulkan/cts/vulkan_driver_test
```
If these tests pass, you can skip down to the next section.
diff --git a/experimental/rocm/cts/CMakeLists.txt b/experimental/rocm/cts/CMakeLists.txt
new file mode 100644
index 0000000..0f65682
--- /dev/null
+++ b/experimental/rocm/cts/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+iree_hal_cts_test_suite(
+ DRIVER_NAME
+ vulkan
+ DRIVER_REGISTRATION_HDR
+ "experimental/rocm/registration/driver_module.h"
+ DRIVER_REGISTRATION_FN
+ "iree_hal_rocm_driver_module_register"
+ DEPS
+ experimental::rocm::registration
+)
diff --git a/iree/hal/cts/BUILD b/iree/hal/cts/BUILD
deleted file mode 100644
index e15b553..0000000
--- a/iree/hal/cts/BUILD
+++ /dev/null
@@ -1,152 +0,0 @@
-# Copyright 2019 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "cts_test_base",
- testonly = True,
- hdrs = ["cts_test_base.h"],
- deps = [
- "//iree/base",
- "//iree/hal",
- "//iree/testing:gtest",
- ],
-)
-
-cc_test(
- name = "allocator_test",
- srcs = ["allocator_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "buffer_mapping_test",
- srcs = ["buffer_mapping_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "command_buffer_test",
- srcs = ["command_buffer_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "descriptor_set_test",
- srcs = ["descriptor_set_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "descriptor_set_layout_test",
- srcs = ["descriptor_set_layout_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "driver_test",
- srcs = ["driver_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "event_test",
- srcs = ["event_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "executable_layout_test",
- srcs = ["executable_layout_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "semaphore_test",
- srcs = ["semaphore_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-cc_test(
- name = "semaphore_submission_test",
- srcs = ["semaphore_submission_test.cc"],
- deps = [
- ":cts_test_base",
- "//iree/base",
- "//iree/hal",
- "//iree/hal/testing:driver_registry",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
diff --git a/iree/hal/cts/CMakeLists.txt b/iree/hal/cts/CMakeLists.txt
index c2dc986..9e10a2e 100644
--- a/iree/hal/cts/CMakeLists.txt
+++ b/iree/hal/cts/CMakeLists.txt
@@ -1,14 +1,22 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/hal/cts/BUILD #
-# #
-# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
-# CMake-only content. #
-# #
-# To disable autogeneration for this file entirely, delete this header. #
-################################################################################
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-iree_add_all_subdirs()
+set(IREE_ALL_CTS_TESTS
+ "allocator"
+ "buffer_mapping"
+ "command_buffer"
+ "descriptor_set_layout"
+ "descriptor_set"
+ "driver"
+ "event"
+ "executable_layout"
+ "semaphore_submission"
+ "semaphore"
+ PARENT_SCOPE
+)
iree_cc_library(
NAME
@@ -23,144 +31,122 @@
PUBLIC
)
-iree_cc_test(
+iree_cc_library(
NAME
- allocator_test
- SRCS
- "allocator_test.cc"
+ allocator_test_library
+ HDRS
+ "allocator_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- buffer_mapping_test
- SRCS
- "buffer_mapping_test.cc"
+ buffer_mapping_test_library
+ HDRS
+ "buffer_mapping_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- command_buffer_test
- SRCS
- "command_buffer_test.cc"
+ command_buffer_test_library
+ HDRS
+ "command_buffer_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- descriptor_set_test
- SRCS
- "descriptor_set_test.cc"
+ descriptor_set_test_library
+ HDRS
+ "descriptor_set_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- descriptor_set_layout_test
- SRCS
- "descriptor_set_layout_test.cc"
+ descriptor_set_layout_test_library
+ HDRS
+ "descriptor_set_layout_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- driver_test
- SRCS
- "driver_test.cc"
+ driver_test_library
+ HDRS
+ "driver_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- event_test
- SRCS
- "event_test.cc"
+ event_test_library
+ HDRS
+ "event_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- executable_layout_test
- SRCS
- "executable_layout_test.cc"
+ executable_layout_test_library
+ HDRS
+ "executable_layout_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- semaphore_test
- SRCS
- "semaphore_test.cc"
+ semaphore_test_library
+ HDRS
+ "semaphore_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-iree_cc_test(
+iree_cc_library(
NAME
- semaphore_submission_test
- SRCS
- "semaphore_submission_test.cc"
+ semaphore_submission_test_library
+ HDRS
+ "semaphore_submission_test.h"
DEPS
::cts_test_base
iree::base
iree::hal
- iree::hal::testing::driver_registry
iree::testing::gtest
- iree::testing::gtest_main
)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/hal/cts/README.md b/iree/hal/cts/README.md
index e5a4b45..54bfa34 100644
--- a/iree/hal/cts/README.md
+++ b/iree/hal/cts/README.md
@@ -6,6 +6,13 @@
in isolation, demonstrating typical full-system usage, and pointing out where
capabilities are optional.
+## Usage
+
+Each HAL driver (in-tree or out-of-tree) can use the `iree_hal_cts_test_suite()`
+CMake function to create a set of tests. See the documentation in
+[iree_hal_cts_test_suite.cmake](../../build_tools/cmake/iree_hal_cts_test_suite.cmake)
+and [cts_test_base.h](cts_test_base.h) for concrete details.
+
## On testing for error conditions
In general, error states are only lightly tested because the low level APIs that
@@ -24,8 +31,8 @@
## Tips for adding new HAL implementations
* Driver (`iree_hal_driver_t`) and device (`iree_hal_device_t`) creation, tested
- in [driver_test](driver_test.cc), are both prerequisites for all tests.
+ in [driver_test](driver_test.h), are both prerequisites for all tests.
* Tests for individual components (e.g.
- [descriptor_set_layout_test](descriptor_set_layout_test.cc)) are more
+ [descriptor_set_layout_test](descriptor_set_layout_test.h)) are more
approachable than tests which use collections of components together (e.g.
- [command_buffer_test](command_buffer_test.cc)).
+ [command_buffer_test](command_buffer_test.h)).
diff --git a/iree/hal/cts/allocator_test.cc b/iree/hal/cts/allocator_test.h
similarity index 90%
rename from iree/hal/cts/allocator_test.cc
rename to iree/hal/cts/allocator_test.h
index cd10af3..8377489 100644
--- a/iree/hal/cts/allocator_test.cc
+++ b/iree/hal/cts/allocator_test.h
@@ -4,13 +4,12 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include <string>
-#include <vector>
+#ifndef IREE_HAL_CTS_ALLOCATOR_TEST_H_
+#define IREE_HAL_CTS_ALLOCATOR_TEST_H_
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -24,7 +23,7 @@
} // namespace
-class AllocatorTest : public CtsTestBase {};
+class allocator_test : public CtsTestBase {};
// All allocators must support some baseline capabilities.
//
@@ -32,7 +31,7 @@
// 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(AllocatorTest, BaselineBufferCompatibility) {
+TEST_P(allocator_test, BaselineBufferCompatibility) {
// Need at least one way to get data between the host and device.
iree_hal_buffer_compatibility_t transfer_compatibility_host =
iree_hal_allocator_query_buffer_compatibility(
@@ -66,7 +65,7 @@
IREE_HAL_BUFFER_COMPATIBILITY_QUEUE_DISPATCH));
}
-TEST_P(AllocatorTest, BufferAllowedUsageDeterminesCompatibility) {
+TEST_P(allocator_test, BufferAllowedUsageDeterminesCompatibility) {
iree_hal_buffer_compatibility_t compatibility =
iree_hal_allocator_query_buffer_compatibility(
device_allocator_, IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE,
@@ -80,7 +79,7 @@
IREE_HAL_BUFFER_COMPATIBILITY_QUEUE_DISPATCH));
}
-TEST_P(AllocatorTest, AllocateBuffer) {
+TEST_P(allocator_test, AllocateBuffer) {
iree_hal_memory_type_t memory_type = IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE;
iree_hal_buffer_usage_t buffer_usage = IREE_HAL_BUFFER_USAGE_TRANSFER;
@@ -103,7 +102,7 @@
// 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(AllocatorTest, AllocateEmptyBuffer) {
+TEST_P(allocator_test, AllocateEmptyBuffer) {
iree_hal_memory_type_t memory_type = IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE;
iree_hal_buffer_usage_t buffer_usage = IREE_HAL_BUFFER_USAGE_TRANSFER;
@@ -115,11 +114,8 @@
iree_hal_buffer_release(buffer);
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, AllocatorTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_ALLOCATOR_TEST_H_
diff --git a/iree/hal/cts/buffer_mapping_test.cc b/iree/hal/cts/buffer_mapping_test.h
similarity index 93%
rename from iree/hal/cts/buffer_mapping_test.cc
rename to iree/hal/cts/buffer_mapping_test.h
index ae9645f..87a1a41 100644
--- a/iree/hal/cts/buffer_mapping_test.cc
+++ b/iree/hal/cts/buffer_mapping_test.h
@@ -4,15 +4,15 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#ifndef IREE_HAL_CTS_BUFFER_MAPPING_TEST_H_
+#define IREE_HAL_CTS_BUFFER_MAPPING_TEST_H_
+
#include <cstdint>
-#include <cstring>
-#include <string>
#include <vector>
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -28,11 +28,11 @@
} // namespace
-class BufferMappingTest : public CtsTestBase {};
+class buffer_mapping_test : public CtsTestBase {};
// TODO(scotttodd): move this check to SetUp() and skip tests if not supported
// or add general support for optional features/tests into the CTS framework?
-TEST_P(BufferMappingTest, AllocatorSupportsBufferMapping) {
+TEST_P(buffer_mapping_test, AllocatorSupportsBufferMapping) {
iree_hal_memory_type_t memory_type = IREE_HAL_MEMORY_TYPE_HOST_VISIBLE;
iree_hal_buffer_usage_t buffer_usage = IREE_HAL_BUFFER_USAGE_MAPPING;
@@ -58,7 +58,7 @@
iree_hal_buffer_release(buffer);
}
-TEST_P(BufferMappingTest, Zero) {
+TEST_P(buffer_mapping_test, Zero) {
iree_hal_memory_type_t memory_type = IREE_HAL_MEMORY_TYPE_HOST_VISIBLE;
iree_hal_buffer_usage_t buffer_usage = IREE_HAL_BUFFER_USAGE_MAPPING;
@@ -80,7 +80,7 @@
iree_hal_buffer_release(buffer);
}
-TEST_P(BufferMappingTest, FillEmpty) {
+TEST_P(buffer_mapping_test, FillEmpty) {
iree_hal_memory_type_t memory_type = IREE_HAL_MEMORY_TYPE_HOST_VISIBLE;
iree_hal_buffer_usage_t buffer_usage = IREE_HAL_BUFFER_USAGE_MAPPING;
@@ -108,7 +108,7 @@
iree_hal_buffer_release(buffer);
}
-TEST_P(BufferMappingTest, Fill) {
+TEST_P(buffer_mapping_test, Fill) {
iree_hal_memory_type_t memory_type = IREE_HAL_MEMORY_TYPE_HOST_VISIBLE;
iree_hal_buffer_usage_t buffer_usage = IREE_HAL_BUFFER_USAGE_MAPPING;
@@ -133,7 +133,7 @@
iree_hal_buffer_release(buffer);
}
-TEST_P(BufferMappingTest, Write) {
+TEST_P(buffer_mapping_test, Write) {
iree_hal_memory_type_t memory_type = IREE_HAL_MEMORY_TYPE_HOST_VISIBLE;
iree_hal_buffer_usage_t buffer_usage = IREE_HAL_BUFFER_USAGE_MAPPING;
@@ -155,7 +155,7 @@
iree_hal_buffer_release(buffer);
}
-TEST_P(BufferMappingTest, Copy) {
+TEST_P(buffer_mapping_test, Copy) {
iree_hal_memory_type_t memory_type = IREE_HAL_MEMORY_TYPE_HOST_VISIBLE;
iree_hal_buffer_usage_t buffer_usage = IREE_HAL_BUFFER_USAGE_MAPPING;
@@ -196,11 +196,8 @@
// TODO(scotttodd): revive old tests:
// https://github.com/google/iree/blob/440edee8a3190d73dbceb24986eed847cac8bd31/iree/hal/buffer_mapping_test.cc
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, BufferMappingTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_BUFFER_MAPPING_TEST_H_
diff --git a/iree/hal/cts/command_buffer_test.cc b/iree/hal/cts/command_buffer_test.h
similarity index 91%
rename from iree/hal/cts/command_buffer_test.cc
rename to iree/hal/cts/command_buffer_test.h
index 6b3ef9e..60df42d 100644
--- a/iree/hal/cts/command_buffer_test.cc
+++ b/iree/hal/cts/command_buffer_test.h
@@ -4,15 +4,15 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#ifndef IREE_HAL_CTS_COMMAND_BUFFER_TEST_H_
+#define IREE_HAL_CTS_COMMAND_BUFFER_TEST_H_
+
#include <cstdint>
-#include <cstring>
-#include <string>
#include <vector>
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -28,14 +28,7 @@
using ::testing::ContainerEq;
-class CommandBufferTest : public CtsTestBase {
- public:
- CommandBufferTest() {
- // TODO(#4680): command buffer recording so that this can run on sync HAL.
- SkipUnavailableDriver("dylib-sync");
- SkipUnavailableDriver("vmvx-sync");
- }
-
+class command_buffer_test : public CtsTestBase {
protected:
std::vector<uint8_t> RunFillBufferTest(iree_device_size_t buffer_size,
iree_device_size_t target_offset,
@@ -98,7 +91,7 @@
static constexpr iree_device_size_t kBufferSize = 4096;
};
-TEST_P(CommandBufferTest, Create) {
+TEST_P(command_buffer_test, Create) {
iree_hal_command_buffer_t* command_buffer;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
@@ -112,7 +105,7 @@
iree_hal_command_buffer_release(command_buffer);
}
-TEST_P(CommandBufferTest, BeginEnd) {
+TEST_P(command_buffer_test, BeginEnd) {
iree_hal_command_buffer_t* command_buffer;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
@@ -125,7 +118,7 @@
iree_hal_command_buffer_release(command_buffer);
}
-TEST_P(CommandBufferTest, SubmitEmpty) {
+TEST_P(command_buffer_test, SubmitEmpty) {
iree_hal_command_buffer_t* command_buffer;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
@@ -141,7 +134,7 @@
iree_hal_command_buffer_release(command_buffer);
}
-TEST_P(CommandBufferTest, CopyWholeBuffer) {
+TEST_P(command_buffer_test, CopyWholeBuffer) {
iree_hal_command_buffer_t* command_buffer;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
@@ -193,7 +186,7 @@
iree_hal_buffer_release(host_buffer);
}
-TEST_P(CommandBufferTest, CopySubBuffer) {
+TEST_P(command_buffer_test, CopySubBuffer) {
iree_hal_command_buffer_t* command_buffer;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
@@ -254,7 +247,7 @@
iree_hal_buffer_release(host_buffer);
}
-TEST_P(CommandBufferTest, FillBuffer_pattern1_size1_offset0_length1) {
+TEST_P(command_buffer_test, FillBuffer_pattern1_size1_offset0_length1) {
iree_device_size_t buffer_size = 1;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 1;
@@ -266,7 +259,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern1_size5_offset0_length5) {
+TEST_P(command_buffer_test, FillBuffer_pattern1_size5_offset0_length5) {
iree_device_size_t buffer_size = 5;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 5;
@@ -279,7 +272,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern1_size16_offset0_length1) {
+TEST_P(command_buffer_test, FillBuffer_pattern1_size16_offset0_length1) {
iree_device_size_t buffer_size = 16;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 1;
@@ -294,7 +287,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern1_size16_offset0_length3) {
+TEST_P(command_buffer_test, FillBuffer_pattern1_size16_offset0_length3) {
iree_device_size_t buffer_size = 16;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 3;
@@ -309,7 +302,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern1_size16_offset0_length8) {
+TEST_P(command_buffer_test, FillBuffer_pattern1_size16_offset0_length8) {
iree_device_size_t buffer_size = 16;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 8;
@@ -324,7 +317,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern1_size16_offset2_length8) {
+TEST_P(command_buffer_test, FillBuffer_pattern1_size16_offset2_length8) {
iree_device_size_t buffer_size = 16;
iree_device_size_t target_offset = 2;
iree_device_size_t fill_length = 8;
@@ -339,7 +332,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern2_size2_offset0_length2) {
+TEST_P(command_buffer_test, FillBuffer_pattern2_size2_offset0_length2) {
iree_device_size_t buffer_size = 2;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 2;
@@ -351,7 +344,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern2_size16_offset0_length8) {
+TEST_P(command_buffer_test, FillBuffer_pattern2_size16_offset0_length8) {
iree_device_size_t buffer_size = 16;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 8;
@@ -366,7 +359,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern2_size16_offset0_length10) {
+TEST_P(command_buffer_test, FillBuffer_pattern2_size16_offset0_length10) {
iree_device_size_t buffer_size = 16;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 10;
@@ -381,7 +374,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern2_size16_offset2_length8) {
+TEST_P(command_buffer_test, FillBuffer_pattern2_size16_offset2_length8) {
iree_device_size_t buffer_size = 16;
iree_device_size_t target_offset = 2;
iree_device_size_t fill_length = 8;
@@ -396,7 +389,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern4_size4_offset0_length4) {
+TEST_P(command_buffer_test, FillBuffer_pattern4_size4_offset0_length4) {
iree_device_size_t buffer_size = 4;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 4;
@@ -408,7 +401,7 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-TEST_P(CommandBufferTest, FillBuffer_pattern4_size16_offset0_length8) {
+TEST_P(command_buffer_test, FillBuffer_pattern4_size16_offset0_length8) {
iree_device_size_t buffer_size = 16;
iree_device_size_t target_offset = 0;
iree_device_size_t fill_length = 8;
@@ -423,11 +416,8 @@
EXPECT_THAT(actual_buffer, ContainerEq(reference_buffer));
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, CommandBufferTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_COMMAND_BUFFER_TEST_H_
diff --git a/iree/hal/cts/cts_test_base.h b/iree/hal/cts/cts_test_base.h
index 90a7e12..1269646 100644
--- a/iree/hal/cts/cts_test_base.h
+++ b/iree/hal/cts/cts_test_base.h
@@ -7,9 +7,8 @@
#ifndef IREE_HAL_CTS_CTS_TEST_BASE_H_
#define IREE_HAL_CTS_CTS_TEST_BASE_H_
-#include <map>
-#include <mutex>
#include <set>
+#include <string>
#include "iree/base/api.h"
#include "iree/hal/api.h"
@@ -20,17 +19,21 @@
namespace hal {
namespace cts {
-// Common setup for tests parameterized across all registered drivers.
+// Leaf test binaries must implement this function, registering the driver
+// that will be used with INSTANTIATE_TEST_SUITE_P.
+// Multiple drivers _may_ be registered and used with parameterized test suite
+// construction, but the expected use is 1 driver : 1 test suite.
+iree_status_t register_test_driver(iree_hal_driver_registry_t* registry);
+
+// Common setup for tests parameterized on driver names.
class CtsTestBase : public ::testing::TestWithParam<std::string> {
protected:
+ static void SetUpTestSuite() {
+ IREE_CHECK_OK(register_test_driver(iree_hal_driver_registry_default()));
+ }
+
virtual void SetUp() {
const std::string& driver_name = GetParam();
- if (driver_block_list_.find(driver_name) != driver_block_list_.end()) {
- IREE_LOG(WARNING) << "Skipping test as '" << driver_name
- << "' driver is explicitly disabled for this test";
- GTEST_SKIP();
- return;
- }
// Get driver with the given name and create its default device.
// Skip drivers that are (gracefully) unavailable, fail if creation fails.
@@ -43,6 +46,7 @@
GTEST_SKIP();
return;
}
+ IREE_ASSERT_OK(status);
driver_ = driver;
iree_hal_device_t* device;
@@ -66,15 +70,15 @@
virtual void TearDown() {
if (device_allocator_) {
iree_hal_allocator_release(device_allocator_);
- device_allocator_ = nullptr;
+ device_allocator_ = NULL;
}
if (device_) {
iree_hal_device_release(device_);
- device_ = nullptr;
+ device_ = NULL;
}
if (driver_) {
iree_hal_driver_release(driver_);
- driver_ = nullptr;
+ driver_ = NULL;
}
}
@@ -119,17 +123,9 @@
return status;
}
- iree_hal_driver_t* driver_ = nullptr;
- iree_hal_device_t* device_ = nullptr;
- iree_hal_allocator_t* device_allocator_ = nullptr;
- // Allow skipping tests for driver under development.
- void declareUnimplementedDriver(const std::string& driver_name) {
- driver_block_list_.insert(driver_name);
- }
- // Allow skipping tests for unsupported features.
- void SkipUnavailableDriver(const std::string& driver_name) {
- driver_block_list_.insert(driver_name);
- }
+ iree_hal_driver_t* driver_ = NULL;
+ iree_hal_device_t* device_ = NULL;
+ iree_hal_allocator_t* device_allocator_ = NULL;
private:
// Gets a HAL driver with the provided name, if available.
@@ -157,7 +153,6 @@
}
return status;
}
- std::set<std::string> driver_block_list_;
};
struct GenerateTestName {
diff --git a/iree/hal/cts/cts_test_template.cc.in b/iree/hal/cts/cts_test_template.cc.in
new file mode 100644
index 0000000..73dd0f2
--- /dev/null
+++ b/iree/hal/cts/cts_test_template.cc.in
@@ -0,0 +1,35 @@
+// Copyright 2021 The IREE Authors
+//
+// Licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// clang-format off
+#cmakedefine IREE_CTS_TEST_FILE_PATH "@IREE_CTS_TEST_FILE_PATH@"
+#cmakedefine IREE_CTS_DRIVER_REGISTRATION_HDR "@IREE_CTS_DRIVER_REGISTRATION_HDR@"
+#cmakedefine IREE_CTS_DRIVER_REGISTRATION_FN @IREE_CTS_DRIVER_REGISTRATION_FN@
+#cmakedefine IREE_CTS_TEST_CLASS_NAME @IREE_CTS_TEST_CLASS_NAME@
+#cmakedefine IREE_CTS_DRIVER_NAME "@IREE_CTS_DRIVER_NAME@"
+// clang-format on
+
+#include IREE_CTS_TEST_FILE_PATH
+
+#include IREE_CTS_DRIVER_REGISTRATION_HDR
+#include "iree/hal/cts/cts_test_base.h"
+#include "iree/testing/gtest.h"
+
+namespace iree {
+namespace hal {
+namespace cts {
+
+iree_status_t register_test_driver(iree_hal_driver_registry_t* registry) {
+ return IREE_CTS_DRIVER_REGISTRATION_FN(registry);
+}
+
+INSTANTIATE_TEST_SUITE_P(CTS, IREE_CTS_TEST_CLASS_NAME,
+ ::testing::Values(IREE_CTS_DRIVER_NAME),
+ GenerateTestName());
+
+} // namespace cts
+} // namespace hal
+} // namespace iree
diff --git a/iree/hal/cts/descriptor_set_layout_test.cc b/iree/hal/cts/descriptor_set_layout_test.h
similarity index 83%
rename from iree/hal/cts/descriptor_set_layout_test.cc
rename to iree/hal/cts/descriptor_set_layout_test.h
index 735f475..8c01082 100644
--- a/iree/hal/cts/descriptor_set_layout_test.cc
+++ b/iree/hal/cts/descriptor_set_layout_test.h
@@ -4,14 +4,12 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include <cstddef>
-#include <string>
-#include <vector>
+#ifndef IREE_HAL_CTS_DESCRIPTOR_SET_LAYOUT_TEST_H_
+#define IREE_HAL_CTS_DESCRIPTOR_SET_LAYOUT_TEST_H_
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -19,11 +17,11 @@
namespace hal {
namespace cts {
-class DescriptorSetLayoutTest : public CtsTestBase {};
+class descriptor_set_layout_test : public CtsTestBase {};
// Note: bindingCount == 0 is valid in VkDescriptorSetLayoutCreateInfo:
// https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkDescriptorSetLayoutCreateInfo.html
-TEST_P(DescriptorSetLayoutTest, CreateWithNoBindings) {
+TEST_P(descriptor_set_layout_test, CreateWithNoBindings) {
iree_hal_descriptor_set_layout_t* descriptor_set_layout;
IREE_ASSERT_OK(iree_hal_descriptor_set_layout_create(
device_, IREE_HAL_DESCRIPTOR_SET_LAYOUT_USAGE_TYPE_IMMUTABLE,
@@ -32,7 +30,7 @@
iree_hal_descriptor_set_layout_release(descriptor_set_layout);
}
-TEST_P(DescriptorSetLayoutTest, CreateWithOneBinding) {
+TEST_P(descriptor_set_layout_test, CreateWithOneBinding) {
iree_hal_descriptor_set_layout_t* descriptor_set_layout;
iree_hal_descriptor_set_layout_binding_t descriptor_set_layout_bindings[] = {
{/*binding=*/0, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
@@ -44,7 +42,7 @@
iree_hal_descriptor_set_layout_release(descriptor_set_layout);
}
-TEST_P(DescriptorSetLayoutTest, CreateWithTwoBindings) {
+TEST_P(descriptor_set_layout_test, CreateWithTwoBindings) {
iree_hal_descriptor_set_layout_t* descriptor_set_layout;
iree_hal_descriptor_set_layout_binding_t descriptor_set_layout_bindings[] = {
{/*binding=*/0, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
@@ -57,7 +55,7 @@
iree_hal_descriptor_set_layout_release(descriptor_set_layout);
}
-TEST_P(DescriptorSetLayoutTest, CreateWithPushDescriptorType) {
+TEST_P(descriptor_set_layout_test, CreateWithPushDescriptorType) {
iree_hal_descriptor_set_layout_t* descriptor_set_layout;
iree_hal_descriptor_set_layout_binding_t descriptor_set_layout_bindings[] = {
{/*binding=*/0, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
@@ -70,11 +68,8 @@
iree_hal_descriptor_set_layout_release(descriptor_set_layout);
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, DescriptorSetLayoutTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_DESCRIPTOR_SET_LAYOUT_TEST_H_
diff --git a/iree/hal/cts/descriptor_set_test.cc b/iree/hal/cts/descriptor_set_test.h
similarity index 82%
rename from iree/hal/cts/descriptor_set_test.cc
rename to iree/hal/cts/descriptor_set_test.h
index bae3a9f..4cb811a 100644
--- a/iree/hal/cts/descriptor_set_test.cc
+++ b/iree/hal/cts/descriptor_set_test.h
@@ -4,14 +4,12 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include <cstddef>
-#include <string>
-#include <vector>
+#ifndef IREE_HAL_CTS_DESCRIPTOR_SET_TEST_H_
+#define IREE_HAL_CTS_DESCRIPTOR_SET_TEST_H_
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -19,12 +17,12 @@
namespace hal {
namespace cts {
-class DescriptorSetTest : public CtsTestBase {};
+class descriptor_set_test : public CtsTestBase {};
// TODO(scotttodd): enable once any driver implements non-push descriptor sets
// * also test with buffers in the bindings
// * also test usage in iree_hal_command_buffer_bind_descriptor_set
-TEST_P(DescriptorSetTest, DISABLED_CreateWithTwoBindings) {
+TEST_P(descriptor_set_test, DISABLED_CreateWithTwoBindings) {
iree_hal_descriptor_set_layout_t* descriptor_set_layout;
iree_hal_descriptor_set_layout_binding_t descriptor_set_layout_bindings[] = {
{/*binding=*/0, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
@@ -49,11 +47,8 @@
iree_hal_descriptor_set_layout_release(descriptor_set_layout);
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, DescriptorSetTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_DESCRIPTOR_SET_TEST_H_
diff --git a/iree/hal/cts/driver_test.cc b/iree/hal/cts/driver_test.h
similarity index 81%
rename from iree/hal/cts/driver_test.cc
rename to iree/hal/cts/driver_test.h
index f4c7baa..6c2084d 100644
--- a/iree/hal/cts/driver_test.cc
+++ b/iree/hal/cts/driver_test.h
@@ -4,16 +4,15 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include <cstddef>
+#ifndef IREE_HAL_CTS_DRIVER_TEST_H_
+#define IREE_HAL_CTS_DRIVER_TEST_H_
+
#include <iostream>
-#include <ostream>
#include <string>
-#include <vector>
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -21,9 +20,9 @@
namespace hal {
namespace cts {
-class DriverTest : public CtsTestBase {};
+class driver_test : public CtsTestBase {};
-TEST_P(DriverTest, QueryAndCreateAvailableDevices) {
+TEST_P(driver_test, QueryAndCreateAvailableDevices) {
iree_hal_device_info_t* device_infos;
iree_host_size_t device_info_count;
IREE_ASSERT_OK(iree_hal_driver_query_available_devices(
@@ -47,11 +46,8 @@
iree_allocator_free(iree_allocator_system(), device_infos);
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, DriverTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_DRIVER_TEST_H_
diff --git a/iree/hal/cts/event_test.cc b/iree/hal/cts/event_test.h
similarity index 88%
rename from iree/hal/cts/event_test.cc
rename to iree/hal/cts/event_test.h
index 5344215..505e0f7 100644
--- a/iree/hal/cts/event_test.cc
+++ b/iree/hal/cts/event_test.h
@@ -4,15 +4,14 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include <cstddef>
+#ifndef IREE_HAL_CTS_EVENT_TEST_H_
+#define IREE_HAL_CTS_EVENT_TEST_H_
+
#include <cstdint>
-#include <string>
-#include <vector>
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -20,22 +19,15 @@
namespace hal {
namespace cts {
-class EventTest : public CtsTestBase {
- public:
- EventTest() {
- // TODO(#4680): command buffer recording so that this can run on sync HAL.
- SkipUnavailableDriver("dylib-sync");
- SkipUnavailableDriver("vmvx-sync");
- }
-};
+class event_test : public CtsTestBase {};
-TEST_P(EventTest, Create) {
+TEST_P(event_test, Create) {
iree_hal_event_t* event;
IREE_ASSERT_OK(iree_hal_event_create(device_, &event));
iree_hal_event_release(event);
}
-TEST_P(EventTest, SignalAndReset) {
+TEST_P(event_test, SignalAndReset) {
iree_hal_event_t* event;
IREE_ASSERT_OK(iree_hal_event_create(device_, &event));
@@ -59,7 +51,7 @@
iree_hal_command_buffer_release(command_buffer);
}
-TEST_P(EventTest, SubmitWithChainedCommandBuffers) {
+TEST_P(event_test, SubmitWithChainedCommandBuffers) {
iree_hal_event_t* event;
IREE_ASSERT_OK(iree_hal_event_create(device_, &event));
@@ -124,11 +116,8 @@
iree_hal_event_release(event);
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, EventTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_EVENT_TEST_H_
diff --git a/iree/hal/cts/executable_layout_test.cc b/iree/hal/cts/executable_layout_test.h
similarity index 86%
rename from iree/hal/cts/executable_layout_test.cc
rename to iree/hal/cts/executable_layout_test.h
index 2e35d55..83200a5 100644
--- a/iree/hal/cts/executable_layout_test.cc
+++ b/iree/hal/cts/executable_layout_test.h
@@ -4,14 +4,12 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include <cstddef>
-#include <string>
-#include <vector>
+#ifndef IREE_HAL_CTS_EXECUTABLE_LAYOUT_TEST_H_
+#define IREE_HAL_CTS_EXECUTABLE_LAYOUT_TEST_H_
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -19,9 +17,9 @@
namespace hal {
namespace cts {
-class ExecutableLayoutTest : public CtsTestBase {};
+class executable_layout_test : public CtsTestBase {};
-TEST_P(ExecutableLayoutTest, CreateWithNoLayouts) {
+TEST_P(executable_layout_test, CreateWithNoLayouts) {
iree_hal_executable_layout_t* executable_layout;
IREE_ASSERT_OK(iree_hal_executable_layout_create(
device_, /*push_constants=*/0, /*set_layout_count=*/0, NULL,
@@ -30,7 +28,7 @@
iree_hal_executable_layout_release(executable_layout);
}
-TEST_P(ExecutableLayoutTest, CreateWithPushConstants) {
+TEST_P(executable_layout_test, CreateWithPushConstants) {
iree_hal_executable_layout_t* executable_layout;
// Note: The Vulkan maxPushConstantsSize limit must be at least 128 bytes:
// https://www.khronos.org/registry/vulkan/specs/1.2/html/vkspec.html#limits-minmax
@@ -41,7 +39,7 @@
iree_hal_executable_layout_release(executable_layout);
}
-TEST_P(ExecutableLayoutTest, CreateWithOneLayout) {
+TEST_P(executable_layout_test, CreateWithOneLayout) {
iree_hal_descriptor_set_layout_t* descriptor_set_layout;
iree_hal_descriptor_set_layout_binding_t descriptor_set_layout_bindings[] = {
{/*binding=*/0, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
@@ -61,7 +59,7 @@
iree_hal_descriptor_set_layout_release(descriptor_set_layout);
}
-TEST_P(ExecutableLayoutTest, CreateWithTwoLayouts) {
+TEST_P(executable_layout_test, CreateWithTwoLayouts) {
iree_hal_descriptor_set_layout_t* descriptor_set_layouts[2];
iree_hal_descriptor_set_layout_binding_t layout_bindings_0[] = {
{/*binding=*/0, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
@@ -92,11 +90,8 @@
iree_hal_descriptor_set_layout_release(descriptor_set_layouts[1]);
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, ExecutableLayoutTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_EXECUTABLE_LAYOUT_TEST_H_
diff --git a/iree/hal/cts/semaphore_submission_test.cc b/iree/hal/cts/semaphore_submission_test.h
similarity index 90%
rename from iree/hal/cts/semaphore_submission_test.cc
rename to iree/hal/cts/semaphore_submission_test.h
index b39d5b9..ac15536 100644
--- a/iree/hal/cts/semaphore_submission_test.cc
+++ b/iree/hal/cts/semaphore_submission_test.h
@@ -4,15 +4,14 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include <cstddef>
+#ifndef IREE_HAL_CTS_SEMAPHORE_SUBMISSION_TEST_H_
+#define IREE_HAL_CTS_SEMAPHORE_SUBMISSION_TEST_H_
+
#include <cstdint>
-#include <string>
-#include <vector>
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -20,18 +19,9 @@
namespace hal {
namespace cts {
-class SemaphoreSubmissionTest : public CtsTestBase {
- public:
- SemaphoreSubmissionTest() {
- // Disable cuda backend for this test as semaphores are not implemented yet.
- SkipUnavailableDriver("cuda");
- // TODO(#4680): command buffer recording so that this can run on sync HAL.
- SkipUnavailableDriver("dylib-sync");
- SkipUnavailableDriver("vmvx-sync");
- }
-};
+class semaphore_submission_test : public CtsTestBase {};
-TEST_P(SemaphoreSubmissionTest, SubmitWithNoCommandBuffers) {
+TEST_P(semaphore_submission_test, SubmitWithNoCommandBuffers) {
// No waits, one signal which we immediately wait on after submit.
iree_hal_submission_batch_t submission_batch;
submission_batch.wait_semaphores.count = 0;
@@ -58,7 +48,7 @@
iree_hal_semaphore_release(signal_semaphore);
}
-TEST_P(SemaphoreSubmissionTest, SubmitAndSignal) {
+TEST_P(semaphore_submission_test, SubmitAndSignal) {
iree_hal_command_buffer_t* command_buffer;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
@@ -95,7 +85,7 @@
iree_hal_semaphore_release(signal_semaphore);
}
-TEST_P(SemaphoreSubmissionTest, SubmitWithWait) {
+TEST_P(semaphore_submission_test, SubmitWithWait) {
// Empty command buffer.
iree_hal_command_buffer_t* command_buffer;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
@@ -145,7 +135,7 @@
iree_hal_semaphore_release(signal_semaphore);
}
-TEST_P(SemaphoreSubmissionTest, SubmitWithMultipleSemaphores) {
+TEST_P(semaphore_submission_test, SubmitWithMultipleSemaphores) {
iree_hal_command_buffer_t* command_buffer;
IREE_ASSERT_OK(iree_hal_command_buffer_create(
device_, IREE_HAL_COMMAND_BUFFER_MODE_ONE_SHOT,
@@ -212,11 +202,8 @@
iree_hal_semaphore_release(signal_semaphore_2);
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, SemaphoreSubmissionTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_SEMAPHORE_SUBMISSION_TEST_H_
diff --git a/iree/hal/cts/semaphore_test.cc b/iree/hal/cts/semaphore_test.h
similarity index 90%
rename from iree/hal/cts/semaphore_test.cc
rename to iree/hal/cts/semaphore_test.h
index 9a2765a..95cfaf5 100644
--- a/iree/hal/cts/semaphore_test.cc
+++ b/iree/hal/cts/semaphore_test.h
@@ -4,16 +4,15 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include <cstddef>
+#ifndef IREE_HAL_CTS_SEMAPHORE_TEST_H_
+#define IREE_HAL_CTS_SEMAPHORE_TEST_H_
+
#include <cstdint>
-#include <string>
#include <thread>
-#include <vector>
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
-#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -21,14 +20,10 @@
namespace hal {
namespace cts {
-class SemaphoreTest : public CtsTestBase {
- public:
- // Disable cuda backend for this test as semaphores are not implemented yet.
- SemaphoreTest() { SkipUnavailableDriver("cuda"); }
-};
+class semaphore_test : public CtsTestBase {};
// Tests that a semaphore that is unused properly cleans itself up.
-TEST_P(SemaphoreTest, NoOp) {
+TEST_P(semaphore_test, NoOp) {
iree_hal_semaphore_t* semaphore;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 123ull, &semaphore));
@@ -40,7 +35,7 @@
}
// Tests that a semaphore will accept new values as it is signaled.
-TEST_P(SemaphoreTest, NormalSignaling) {
+TEST_P(semaphore_test, NormalSignaling) {
iree_hal_semaphore_t* semaphore;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 2ull, &semaphore));
@@ -62,7 +57,7 @@
// while others may accept the new, decreasing, values.
// Tests semaphore failure handling.
-TEST_P(SemaphoreTest, Failure) {
+TEST_P(semaphore_test, Failure) {
iree_hal_semaphore_t* semaphore;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 2ull, &semaphore));
@@ -83,7 +78,7 @@
}
// Tests waiting on no semaphores.
-TEST_P(SemaphoreTest, EmptyWait) {
+TEST_P(semaphore_test, EmptyWait) {
IREE_ASSERT_OK(iree_hal_device_wait_semaphores(
device_, IREE_HAL_WAIT_MODE_ANY, NULL,
iree_make_deadline(IREE_TIME_INFINITE_FUTURE)));
@@ -101,7 +96,7 @@
// Tests waiting on a semaphore that has already been signaled.
// **Never completes when using SwiftShader**
-TEST_P(SemaphoreTest, DISABLED_WaitAlreadySignaled) {
+TEST_P(semaphore_test, DISABLED_WaitAlreadySignaled) {
iree_hal_semaphore_t* semaphore;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 2ull, &semaphore));
@@ -120,7 +115,7 @@
}
// Tests waiting on a semaphore that has not been signaled.
-TEST_P(SemaphoreTest, WaitUnsignaled) {
+TEST_P(semaphore_test, WaitUnsignaled) {
iree_hal_semaphore_t* semaphore;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 2ull, &semaphore));
@@ -137,7 +132,7 @@
// return UnknownError while others may succeed.
// Tests IREE_HAL_WAIT_MODE_ALL when not all are signaled.
-TEST_P(SemaphoreTest, WaitAllButNotAllSignaled) {
+TEST_P(semaphore_test, WaitAllButNotAllSignaled) {
iree_hal_semaphore_t* semaphore_a;
iree_hal_semaphore_t* semaphore_b;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 0ull, &semaphore_a));
@@ -162,7 +157,7 @@
}
// Tests IREE_HAL_WAIT_MODE_ALL when all are signaled.
-TEST_P(SemaphoreTest, WaitAllAndAllSignaled) {
+TEST_P(semaphore_test, WaitAllAndAllSignaled) {
iree_hal_semaphore_t* semaphore_a;
iree_hal_semaphore_t* semaphore_b;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 1ull, &semaphore_a));
@@ -188,7 +183,7 @@
// Tests IREE_HAL_WAIT_MODE_ANY.
// **Fails using timeline semaphore emulation**
-TEST_P(SemaphoreTest, DISABLED_WaitAny) {
+TEST_P(semaphore_test, DISABLED_WaitAny) {
iree_hal_semaphore_t* semaphore_a;
iree_hal_semaphore_t* semaphore_b;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 0ull, &semaphore_a));
@@ -211,7 +206,7 @@
// Tests threading behavior by ping-ponging between the test main thread and
// a little thread.
-TEST_P(SemaphoreTest, PingPong) {
+TEST_P(semaphore_test, PingPong) {
iree_hal_semaphore_t* a2b;
iree_hal_semaphore_t* b2a;
IREE_ASSERT_OK(iree_hal_semaphore_create(device_, 0ull, &a2b));
@@ -235,11 +230,8 @@
iree_hal_semaphore_release(b2a);
}
-INSTANTIATE_TEST_SUITE_P(
- AllDrivers, SemaphoreTest,
- ::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
- GenerateTestName());
-
} // namespace cts
} // namespace hal
} // namespace iree
+
+#endif // IREE_HAL_CTS_SEMAPHORE_TEST_H_
diff --git a/iree/hal/cuda/cts/CMakeLists.txt b/iree/hal/cuda/cts/CMakeLists.txt
new file mode 100644
index 0000000..d0c6f59
--- /dev/null
+++ b/iree/hal/cuda/cts/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+iree_hal_cts_test_suite(
+ DRIVER_NAME
+ cuda
+ DRIVER_REGISTRATION_HDR
+ "iree/hal/cuda/registration/driver_module.h"
+ DRIVER_REGISTRATION_FN
+ "iree_hal_cuda_driver_module_register"
+ DEPS
+ iree::hal::cuda::registration
+ EXCLUDED_TESTS
+ # Semaphores are not implemented in the CUDA backend yet.
+ "semaphore_submission"
+ "semaphore"
+)
diff --git a/iree/hal/dylib/cts/CMakeLists.txt b/iree/hal/dylib/cts/CMakeLists.txt
new file mode 100644
index 0000000..61c8efe
--- /dev/null
+++ b/iree/hal/dylib/cts/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+if(${IREE_HAL_DRIVER_DYLIB})
+
+iree_hal_cts_test_suite(
+ DRIVER_NAME
+ dylib
+ DRIVER_REGISTRATION_HDR
+ "iree/hal/dylib/registration/driver_module.h"
+ DRIVER_REGISTRATION_FN
+ "iree_hal_dylib_driver_module_register"
+ DEPS
+ iree::hal::dylib::registration
+)
+
+endif()
+
+if(${IREE_HAL_DRIVER_DYLIB_SYNC})
+
+iree_hal_cts_test_suite(
+ DRIVER_NAME
+ dylib-sync
+ DRIVER_REGISTRATION_HDR
+ "iree/hal/dylib/registration/driver_module_sync.h"
+ DRIVER_REGISTRATION_FN
+ "iree_hal_dylib_sync_driver_module_register"
+ DEPS
+ iree::hal::dylib::registration::sync
+ EXCLUDED_TESTS
+ # TODO(#4680): command buffer recording so that these can run on sync HAL
+ "command_buffer"
+ "event"
+ "semaphore_submission"
+)
+
+endif()
diff --git a/iree/hal/testing/BUILD b/iree/hal/testing/BUILD
deleted file mode 100644
index 22dbdc1..0000000
--- a/iree/hal/testing/BUILD
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2019 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-# Test utilities for HAL-specific code.
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "driver_registry",
- testonly = True,
- hdrs = ["driver_registry.h"],
- deps = [
- "//iree/hal",
- "//iree/hal/drivers",
- ],
-)
diff --git a/iree/hal/testing/CMakeLists.txt b/iree/hal/testing/CMakeLists.txt
deleted file mode 100644
index 3ca3506..0000000
--- a/iree/hal/testing/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/hal/testing/BUILD #
-# #
-# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
-# CMake-only content. #
-# #
-# To disable autogeneration for this file entirely, delete this header. #
-################################################################################
-
-iree_add_all_subdirs()
-
-iree_cc_library(
- NAME
- driver_registry
- HDRS
- "driver_registry.h"
- DEPS
- iree::hal
- iree::hal::drivers
- TESTONLY
- PUBLIC
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/hal/testing/driver_registry.h b/iree/hal/testing/driver_registry.h
deleted file mode 100644
index e3e3be9..0000000
--- a/iree/hal/testing/driver_registry.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2020 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_HAL_TESTING_DRIVER_REGISTRY_H_
-#define IREE_HAL_TESTING_DRIVER_REGISTRY_H_
-
-#include <mutex>
-#include <string>
-#include <vector>
-
-#include "iree/hal/api.h"
-#include "iree/hal/drivers/init.h"
-
-namespace iree {
-namespace hal {
-namespace testing {
-
-// Returns an unordered list of all available drivers in the binary.
-// May return empty if there are no available drivers.
-static std::vector<std::string> EnumerateAvailableDrivers() {
- // TODO(benvanik): replace with a wrapper fn that uses iree_call_once.
- static std::once_flag register_once;
- std::call_once(register_once, [] {
- IREE_CHECK_OK(iree_hal_register_all_available_drivers(
- iree_hal_driver_registry_default()));
- });
- iree_hal_driver_info_t* driver_infos = NULL;
- iree_host_size_t driver_info_count = 0;
- IREE_CHECK_OK(iree_hal_driver_registry_enumerate(
- iree_hal_driver_registry_default(), iree_allocator_system(),
- &driver_infos, &driver_info_count));
- std::vector<std::string> driver_names(driver_info_count);
- for (iree_host_size_t i = 0; i < driver_info_count; ++i) {
- driver_names[i] = std::string(driver_infos[i].driver_name.data,
- driver_infos[i].driver_name.size);
- }
- iree_allocator_free(iree_allocator_system(), driver_infos);
- return driver_names;
-}
-
-// Filters out a driver from the given |drivers| set with the given name.
-static std::vector<std::string> RemoveDriverByName(
- std::vector<std::string> drivers, const char* filter_name) {
- std::vector<std::string> result;
- result.reserve(drivers.size());
- for (auto& driver : drivers) {
- if (driver != filter_name) result.push_back(driver);
- }
- return result;
-}
-
-} // namespace testing
-} // namespace hal
-} // namespace iree
-
-#endif // IREE_HAL_TESTING_DRIVER_REGISTRY_H_
diff --git a/iree/hal/vmvx/cts/CMakeLists.txt b/iree/hal/vmvx/cts/CMakeLists.txt
new file mode 100644
index 0000000..7bc5db1
--- /dev/null
+++ b/iree/hal/vmvx/cts/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+if(${IREE_HAL_DRIVER_VMVX})
+
+iree_hal_cts_test_suite(
+ DRIVER_NAME
+ vmvx
+ DRIVER_REGISTRATION_HDR
+ "iree/hal/vmvx/registration/driver_module.h"
+ DRIVER_REGISTRATION_FN
+ "iree_hal_vmvx_driver_module_register"
+ DEPS
+ iree::hal::vmvx::registration
+)
+
+endif()
+
+if(${IREE_HAL_DRIVER_VMVX_SYNC})
+
+iree_hal_cts_test_suite(
+ DRIVER_NAME
+ vmvx-sync
+ DRIVER_REGISTRATION_HDR
+ "iree/hal/vmvx/registration/driver_module_sync.h"
+ DRIVER_REGISTRATION_FN
+ "iree_hal_vmvx_sync_driver_module_register"
+ DEPS
+ iree::hal::vmvx::registration::sync
+ EXCLUDED_TESTS
+ # TODO(#4680): command buffer recording so that these can run on sync HAL
+ "command_buffer"
+ "event"
+ "semaphore_submission"
+)
+
+endif()
diff --git a/iree/hal/vulkan/cts/CMakeLists.txt b/iree/hal/vulkan/cts/CMakeLists.txt
new file mode 100644
index 0000000..7385754
--- /dev/null
+++ b/iree/hal/vulkan/cts/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright 2021 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+iree_hal_cts_test_suite(
+ DRIVER_NAME
+ vulkan
+ DRIVER_REGISTRATION_HDR
+ "iree/hal/vulkan/registration/driver_module.h"
+ DRIVER_REGISTRATION_FN
+ "iree_hal_vulkan_driver_module_register"
+ DEPS
+ iree::hal::vulkan::registration
+)