xref: /aosp_15_r20/external/executorch/backends/vulkan/test/compute_api_tests.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load("@fbcode//target_determinator/macros:ci.bzl", "ci")
2load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary")
3load("@fbsource//tools/build_defs:fb_xplat_cxx_test.bzl", "fb_xplat_cxx_test")
4load("@fbsource//tools/build_defs:platform_defs.bzl", "ANDROID", "MACOSX", "CXX")
5load(
6    "@fbsource//xplat/executorch/backends/vulkan:targets.bzl",
7    "get_labels",
8    "get_platforms",
9    "vulkan_spv_shader_lib",
10)
11
12def define_compute_api_test_targets():
13    for no_volk in [True, False]:
14        suffix = "_no_volk" if no_volk else ""
15
16        vulkan_spv_shader_lib(
17            name = "test_shader_lib{}".format(suffix),
18            spv_filegroups = {
19                ":test_shaders": "glsl",
20            },
21            no_volk = no_volk,
22        )
23
24        fb_xplat_cxx_binary(
25            name = "vulkan_compute_api_test_bin{}".format(suffix),
26            srcs = [
27                "utils/test_utils.cpp",
28                "vulkan_compute_api_test.cpp",
29            ],
30            headers = [
31                "utils/test_utils.h",
32            ],
33            apple_sdks = MACOSX,
34            labels = get_labels(no_volk),
35            platforms = get_platforms(no_volk),
36            visibility = ["PUBLIC"],
37            deps = [
38                ":test_shader_lib{}".format(suffix),
39                "//third-party/googletest:gtest_main",
40                "//xplat/executorch/backends/vulkan:vulkan_graph_runtime{}".format(suffix),
41                "//xplat/executorch/runtime/core/exec_aten:lib",
42            ],
43        )
44
45    # no_volk variant does not work under the flagfile used for instrumentation tests,
46    # but it is also not necessary to test it as an instrumentation test. Therefore do
47    # not generate a no_volk variant for the instrumentation test.
48    fb_xplat_cxx_test(
49        name = "vulkan_compute_api_test{}".format(suffix),
50        srcs = [
51            "utils/test_utils.cpp",
52            "vulkan_compute_api_test.cpp",
53        ],
54        headers = [
55            "utils/test_utils.h",
56        ],
57        contacts = ["[email protected]"],
58        fbandroid_additional_loaded_sonames = [
59            "test_shader_lib",
60            "vulkan_graph_runtime",
61            "vulkan_graph_runtime_shaderlib",
62        ],
63        # Since this is an Android instrumentation test, only generate for ANDROID
64        platforms = [ANDROID],
65        use_instrumentation_test = True,
66        visibility = ["PUBLIC"],
67        deps = [
68            ":test_shader_lib{}".format(suffix),
69            "//third-party/googletest:gtest_main",
70            "//xplat/executorch/backends/vulkan:vulkan_graph_runtime{}".format(suffix),
71            "//xplat/executorch/runtime/core/exec_aten:lib",
72        ],
73    )
74