| # ------------------------------------------------------------------------- |
| # Vulkan Conformance Tests |
| # ------------------------ |
| # |
| # Copyright (c) 2022 Google Inc. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # |
| # -------------------------------------------------------------------- |
| |
| load( |
| "@rules_fuchsia//fuchsia:defs.bzl", |
| "fuchsia_component_manifest", |
| "fuchsia_test_component", |
| "fuchsia_test_package", |
| ) |
| load("@bazel_skylib//rules:expand_template.bzl", "expand_template") |
| |
| def _selectccinfo_impl(ctx): |
| out = None |
| for file in ctx.attr.srcs.files.to_list(): |
| if file.path.endswith(ctx.attr.filename): |
| out = file |
| break |
| if not out: |
| files_str = ",\n".join([ |
| str(f.path) |
| for f in ctx.attr.srcs.files.to_list() |
| ]) |
| fail("Can not find specified file in [%s]" % files_str) |
| return [DefaultInfo(files = depset([out])), ctx.attr.srcs[CcInfo]] |
| |
| selectccinfo = rule( |
| implementation = _selectccinfo_impl, |
| doc = "Selects a single file from the outputs of a target by given relative path. Also passes along the CcInfo", |
| attrs = { |
| "srcs": attr.label( |
| allow_files = True, |
| mandatory = True, |
| doc = "The target producing the file among other outputs", |
| ), |
| "filename": attr.string( |
| mandatory = True, |
| doc = "The filename to select", |
| ), |
| }, |
| ) |
| |
| def split_cts(name): |
| """Generate a package containing multiple test components that together run the entire CTS. |
| |
| Args: |
| name: A unique name for this rule. |
| """ |
| test_components = [] |
| SPLIT_COUNT = 8 |
| for i in range(SPLIT_COUNT): |
| split_name = name + "-" + str(i) |
| expand_template( |
| name = "_" + split_name + "_manifest_file", |
| template = "meta/vulkan-cts-split.cml.tmpl", |
| substitutions = {"{{INDEX}}": str(i)}, |
| out = split_name + ".cml", |
| ) |
| fuchsia_component_manifest( |
| name = "_" + split_name + "_manifest", |
| src = ":_" + split_name + "_manifest_file", |
| includes = [ |
| "//:cts-shard", |
| "@fuchsia_sdk//pkg/sys/testing:elf_test_runner", |
| "@fuchsia_sdk//pkg/sys/testing:system-test", |
| "@fuchsia_sdk//pkg/syslog:client", |
| "@fuchsia_sdk//pkg/vulkan:client", |
| ], |
| ) |
| |
| fuchsia_test_component( |
| name = split_name + "_component", |
| manifest = "_" + split_name + "_manifest", |
| deps = [ |
| "//:data_include", |
| "//:mustpass_include", |
| "//:vulkan-cts-wrapped", |
| "@fuchsia_sdk//pkg/fdio", |
| "@fuchsia_sdk//pkg/vulkan", |
| ], |
| ) |
| test_components.append(":" + split_name + "_component") |
| |
| fuchsia_test_package( |
| name = name, |
| package_name = name, |
| deps = test_components, |
| ) |