Skip to content

Commit

Permalink
[bazel] Add bazel rules for manual tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alphan Ulusoy <[email protected]>
  • Loading branch information
alphan authored and timothytrippel committed Sep 15, 2022
1 parent c09e78f commit 7200ca3
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
39 changes: 39 additions & 0 deletions rules/opentitan_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,42 @@ def opentitan_functest(
# For more see https://bazel.build/reference/be/general#test_suite.tags
],
)

def _manual_test_impl(ctx):
executable = ctx.actions.declare_file("manual_test_wrapper")
ctx.actions.write(
output = executable,
content = "{runner} {testplan}".format(
runner = ctx.executable._runner.short_path,
testplan = ctx.file.testplan.short_path,
),
)
return [
DefaultInfo(
runfiles = ctx.runfiles(
files = [
ctx.executable._runner,
ctx.file.testplan,
],
).merge(ctx.attr._runner[DefaultInfo].default_runfiles),
executable = executable,
),
]

manual_test = rule(
_manual_test_impl,
attrs = {
"testplan": attr.label(
allow_single_file = [".hjson"],
doc = "Testplan with manual testpoints",
mandatory = True,
),
"_runner": attr.label(
default = "//util:run_manual_tests",
executable = True,
cfg = "exec",
),
},
doc = "Walks through the manual testpoints in a testplan",
test = True,
)
10 changes: 10 additions & 0 deletions sw/device/silicon_creator/rom/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ load("//rules:exclude_files.bzl", "exclude_files")
load("//rules:linker.bzl", "ld_library")
load(
"//rules:opentitan_test.bzl",
"manual_test",
"opentitan_functest",
)
load("//rules:cross_platform.bzl", "dual_cc_library", "dual_inputs")
Expand Down Expand Up @@ -318,3 +319,12 @@ pkg_files(
srcs = [":pre_package"],
prefix = "earlgrey/rom",
)

manual_test(
name = "manual_test",
tags = [
"manual",
"no-cache",
],
testplan = "//sw/device/silicon_creator/rom/data:rom_manual_testplan.hjson",
)
10 changes: 10 additions & 0 deletions sw/device/silicon_creator/rom/data/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

package(default_visibility = ["//visibility:public"])

exports_files([
"rom_e2e_testplan.hjson",
"rom_manual_testplan.hjson",
])
13 changes: 13 additions & 0 deletions util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,16 @@ py_test(
"generate_compilation_db_test.py",
],
)

py_binary(
name = "run_manual_tests",
srcs = [
"run_manual_tests.py",
],
deps = [
requirement("typer"),
requirement("hjson"),
requirement("rich"),
requirement("pluralizer"),
],
)

0 comments on commit 7200ca3

Please sign in to comment.