-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Create a dejagnu bazel rule and add the fg-scan test suite.
- Loading branch information
Showing
6 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package(default_visibility = ["//:__subpackages__"]) | ||
|
||
cc_binary( | ||
name = "scan", | ||
testonly = True, | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Dejagnu test runner.""" | ||
|
||
def _dejagnu_test_impl(ctx): | ||
"""Implementation of dejagnu test suite.""" | ||
executable_path = "{name}_/{name}".format(name = ctx.label.name) | ||
executable = ctx.actions.declare_file(executable_path) | ||
|
||
tool = ctx.label.name | ||
srcdir = ctx.files.srcs[0].dirname | ||
|
||
content = _runtest(tool = tool, srcdir = srcdir) | ||
ctx.actions.write( | ||
output = executable, | ||
content = content, | ||
) | ||
|
||
# gather runfiles | ||
runfiles = ctx.runfiles(files = ctx.files.srcs + ctx.files.data + ctx.files.tool_exec + ctx.files.deps) | ||
|
||
return [ | ||
DefaultInfo( | ||
runfiles = runfiles, | ||
executable = executable, | ||
), | ||
] | ||
|
||
dejagnu_test = rule( | ||
implementation = _dejagnu_test_impl, | ||
attrs = { | ||
"srcs": attr.label_list( | ||
allow_files = [".exp"], | ||
doc = "Main test file for dejagnu runtests.", | ||
), | ||
"deps": attr.label_list(allow_files = True), | ||
"data": attr.label_list( | ||
allow_files = True, | ||
), | ||
"tool_exec": attr.label(), | ||
}, | ||
test = True, | ||
) | ||
|
||
def _runtest(tool, srcdir): | ||
"""Generates the runtest wrapper script.""" | ||
return DEJAGNU_TEST_RUNNER_TEMPLATE.format(tool = tool, srcdir = srcdir) | ||
|
||
DEJAGNU_TEST_RUNNER_TEMPLATE = """ | ||
set -o errexit | ||
cleanup () {{ | ||
mv $TEST_UNDECLARED_OUTPUTS_DIR/{tool}.xml $XML_OUTPUT_FILE | ||
}} | ||
trap cleanup EXIT | ||
/bin/runtest --xml --status -all --debug -v -v --tool {tool} --srcdir {srcdir} --outdir $TEST_UNDECLARED_OUTPUTS_DIR | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("//testsuite:dejagnu.bzl", "dejagnu_test") | ||
|
||
dejagnu_test( | ||
name = "fg-scan", | ||
srcs = glob(["**/*.exp"]), | ||
data = glob( | ||
[ | ||
"**/*.in", | ||
"include*.d/**", | ||
], | ||
exclude_directories = 0, | ||
) + ["include"], | ||
tool_exec = "//input/filtergen/t:scan", | ||
deps = ["//testsuite/lib:fg-scan-dg"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
filegroup( | ||
name = "filtergen", | ||
srcs = glob(["*.filter"]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package( | ||
default_visibility = ["//:__subpackages__"], | ||
) | ||
|
||
filegroup( | ||
name = "filtergen-dg", | ||
srcs = ["filtergen-dg.exp"], | ||
) | ||
|
||
filegroup( | ||
name = "fg-scan-dg", | ||
srcs = ["fg-scan-dg.exp"], | ||
) |