* The current issue is that unsafe headers is a target build on demand when the `allow_ddk_unsafe_headers` flag is set, for this reason this test uses a transition to force that flag to be set. * This introduces a new Bazel sub-package bazel/test which could be used later for more tests if needed. Tested: tools/bazel test //common/bazel/test Bug: 325638347 Change-Id: I47236bb625e5d114c0c383035b0e4da809b0ff31 Signed-off-by: Ulises Mendez Martinez <umendez@google.com>
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
# SPDX-License-Identifier: GPL-2.0 OR Apache-2.0
|
|
# Copyright (C) 2026 The Android Open Source Project
|
|
|
|
"""Tests on Kleaf using ACK / GKI as a baseline."""
|
|
|
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
|
|
|
_ALLOW_DDK_UNSAFE_HEADERS_SETTING = "//build/kernel/kleaf:allow_ddk_unsafe_headers"
|
|
|
|
def _ddk_unsafe_headers_transition_impl(_settings, _attr):
|
|
return {_ALLOW_DDK_UNSAFE_HEADERS_SETTING: True}
|
|
|
|
_ddk_unsafe_headers_transition = transition(
|
|
implementation = _ddk_unsafe_headers_transition_impl,
|
|
inputs = [],
|
|
outputs = [_ALLOW_DDK_UNSAFE_HEADERS_SETTING],
|
|
)
|
|
|
|
# This is a simple wrapper to trigger the transition to add unsafe headers.
|
|
def _ddk_headers_wrapper_impl(ctx):
|
|
return ctx.attr.target[DefaultInfo]
|
|
|
|
_ddk_headers_wrapper = rule(
|
|
implementation = _ddk_headers_wrapper_impl,
|
|
# test = True,
|
|
attrs = {
|
|
"target": attr.label(
|
|
cfg = "exec",
|
|
),
|
|
"_allowlist_function_transition": attr.label(
|
|
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
|
|
),
|
|
},
|
|
cfg = _ddk_unsafe_headers_transition,
|
|
)
|
|
|
|
def ddk_headers_build_test(
|
|
name,
|
|
**kwargs):
|
|
"""Define a test to check DDK headers build correctly.
|
|
|
|
Args:
|
|
name: Name of the test
|
|
**kwargs: additional kwargs common to all rules.
|
|
"""
|
|
|
|
_ddk_headers_wrapper(
|
|
name = name + "_ddk_headers_wrapped",
|
|
target = "//common:all_headers",
|
|
)
|
|
|
|
build_test(
|
|
name = name,
|
|
targets = [
|
|
name + "_ddk_headers_wrapped",
|
|
],
|
|
**kwargs
|
|
)
|