ext,tests: Add --build-targets option to ./main.py list
This allows for build target information (i.e., the gem5 binary to be built for the tests) to be returned. Change-Id: I6638b54cbb1822555f58e74938d36043c11108ba
This commit is contained in:
@@ -744,6 +744,12 @@ class ListParser(ArgParser):
|
||||
default=False,
|
||||
help="List all tags.",
|
||||
).add_to(parser)
|
||||
Argument(
|
||||
"--build-targets",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="List all the gem5 build targets.",
|
||||
).add_to(parser)
|
||||
Argument(
|
||||
"-q",
|
||||
dest="quiet",
|
||||
@@ -752,12 +758,11 @@ class ListParser(ArgParser):
|
||||
help="Quiet output (machine readable).",
|
||||
).add_to(parser)
|
||||
Argument(
|
||||
'--uid',
|
||||
action='store',
|
||||
"--uid",
|
||||
action="store",
|
||||
default=None,
|
||||
help='UID of a specific test item to list.'
|
||||
help="UID of a specific test item to list.",
|
||||
).add_to(parser)
|
||||
|
||||
|
||||
common_args.directories.add_to(parser)
|
||||
common_args.bin_path.add_to(parser)
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
import testlib.helper as helper
|
||||
from testlib.configuration import constants
|
||||
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class SkipException(Exception):
|
||||
def __init__(self, fixture, testitem):
|
||||
@@ -80,6 +82,18 @@ class Fixture(object):
|
||||
def teardown(self, testitem):
|
||||
pass
|
||||
|
||||
def get_get_build_info(self) -> Optional[dict]:
|
||||
# If this is a gem5 build it will return the target gem5 build path
|
||||
# and any additional build information. E.g.:
|
||||
#
|
||||
# /path/to/gem5/build/NULL/gem5.opt--default=NULL PROTOCOL=MI_example
|
||||
#
|
||||
# In this example this may be passed to scons to build gem5 in
|
||||
# accordance to the test's build requirements.
|
||||
#
|
||||
# If this fixtures is not a build of gem5, None is returned.
|
||||
return None
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} fixture"
|
||||
|
||||
|
||||
@@ -245,10 +245,12 @@ def do_list():
|
||||
if configuration.config.uid:
|
||||
uid_ = uid.UID.from_uid(configuration.config.uid)
|
||||
if isinstance(uid_, uid.TestUID):
|
||||
log.test_log.error('Unable to list a standalone test.\n'
|
||||
'Gem5 expects test suites to be the smallest unit '
|
||||
' of test.\n\n'
|
||||
'Pass a SuiteUID instead.')
|
||||
log.test_log.error(
|
||||
"Unable to list a standalone test.\n"
|
||||
"Gem5 expects test suites to be the smallest unit "
|
||||
" of test.\n\n"
|
||||
"Pass a SuiteUID instead."
|
||||
)
|
||||
return
|
||||
test_schedule = loader_mod.Loader().load_schedule_for_suites(uid_)
|
||||
if get_config_tags():
|
||||
@@ -273,10 +275,13 @@ def do_list():
|
||||
qrunner.list_tags()
|
||||
elif configuration.config.fixtures:
|
||||
qrunner.list_fixtures()
|
||||
elif configuration.config.build_targets:
|
||||
qrunner.list_build_targets()
|
||||
else:
|
||||
qrunner.list_suites()
|
||||
qrunner.list_tests()
|
||||
qrunner.list_tags()
|
||||
qrunner.list_build_targets()
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -57,11 +57,23 @@ class QueryRunner(object):
|
||||
|
||||
def list_fixtures(self):
|
||||
log.test_log.message(terminal.separator())
|
||||
log.test_log.message('Listing all Test Fixtures.', bold=True)
|
||||
log.test_log.message("Listing all Test Fixtures.", bold=True)
|
||||
log.test_log.message(terminal.separator())
|
||||
for fixture in self.schedule.all_fixtures():
|
||||
log.test_log.message(fixture, machine_readable=True)
|
||||
|
||||
def list_build_targets(self):
|
||||
log.test_log.message(terminal.separator())
|
||||
log.test_log.message("Listing all gem5 Build Targets.", bold=True)
|
||||
log.test_log.message(terminal.separator())
|
||||
builds = []
|
||||
for fixture in self.schedule.all_fixtures():
|
||||
build = fixture.get_get_build_info()
|
||||
if build and build not in builds:
|
||||
builds.append(build)
|
||||
for build in builds:
|
||||
log.test_log.message(build, machine_readable=True)
|
||||
|
||||
def list_suites(self):
|
||||
log.test_log.message(terminal.separator())
|
||||
log.test_log.message("Listing all Test Suites.", bold=True)
|
||||
|
||||
Reference in New Issue
Block a user