From 2aa2b340d333842c60b95b0507c70d2741c9c8be Mon Sep 17 00:00:00 2001 From: MingZhu Yan <69898423+trdthg@users.noreply.github.com> Date: Tue, 19 Nov 2024 03:11:59 +0000 Subject: [PATCH] Add new cli param '--filter' Add a new command line parameter to cli to filter the test cases to be run based on regex, which helps debugging --- riscof/cli.py | 7 +++++-- riscof/framework/main.py | 5 ++--- riscof/framework/test.py | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/riscof/cli.py b/riscof/cli.py index c1a9d11..cc74122 100644 --- a/riscof/cli.py +++ b/riscof/cli.py @@ -381,8 +381,11 @@ def run(ctx,config,work_dir,suite,env,no_browser,dbfile,testfile,no_ref_run,no_d type=click.Path(resolve_path=True,readable=True,exists=True), help="YAML macro file to include" ) +@click.option( + '--filter', metavar='PATH', type=str, + help="Filter testcases to be run by regex") @click.pass_context -def coverage(ctx,config,work_dir,suite,env,no_browser,cgf_file,header_file): +def coverage(ctx,config,work_dir,suite,env,no_browser,cgf_file,header_file,filter): setup_directories(work_dir) ctx.obj.mkdir = False ctx.obj.config, ctx.obj.config_dir = read_config(config) @@ -404,7 +407,7 @@ def coverage(ctx,config,work_dir,suite,env,no_browser,cgf_file,header_file): with open(platform_file, "r") as platfile: pspecs = platfile.read() report, for_html, test_stats, coverpoints = framework.run_coverage(base, isa_file, platform_file, - work_dir, cgf_file, header_file) + work_dir, cgf_file, header_file, filter) report_file = open(work_dir+'/suite_coverage.rpt','w') utils.dump_yaml(report, report_file) report_file.close() diff --git a/riscof/framework/main.py b/riscof/framework/main.py index 33e4356..e68db77 100644 --- a/riscof/framework/main.py +++ b/riscof/framework/main.py @@ -78,7 +78,7 @@ def find_elf_size(elf): # size = e_shoff + e_ehsize + (e_phnum * e_phentsize) + (e_shnum * e_shentsize) return (sum([segment['p_memsz'] for segment in elffile.iter_segments()]),code_size,data_size,sign_size) -def run_coverage(base, dut_isa_spec, dut_platform_spec, work_dir, cgf_file=None, header_file=None): +def run_coverage(base, dut_isa_spec, dut_platform_spec, work_dir, cgf_file=None, header_file=None, filter=None): ''' Entry point for the framework module. This function initializes and sets up the required variables for the tests to run. @@ -110,8 +110,7 @@ def run_coverage(base, dut_isa_spec, dut_platform_spec, work_dir, cgf_file=None, logger.debug("Running Build for Reference") base.build(dut_isa_spec, dut_platform_spec) - - test_list, test_pool = test.generate_test_pool(ispec, pspec, work_dir) + test_list, test_pool = test.generate_test_pool(ispec, pspec, work_dir, filter=filter) logger.info("Running Tests on Reference.") base.runTests(test_list, cgf_file, header_file) diff --git a/riscof/framework/test.py b/riscof/framework/test.py index 4179d1f..f28ce66 100644 --- a/riscof/framework/test.py +++ b/riscof/framework/test.py @@ -279,7 +279,7 @@ def prod_isa(dut_isa, test_isa): raise TestSelectError("Test Selected without the relevant extensions being available on DUT.") return '' -def generate_test_pool(ispec, pspec, workdir, dbfile = None): +def generate_test_pool(ispec, pspec, workdir, dbfile = None, filter = None): ''' Funtion to select the tests which are applicable for the DUT and generate the macros necessary for each test. @@ -303,6 +303,8 @@ def generate_test_pool(ispec, pspec, workdir, dbfile = None): else: db = utils.load_yaml(constants.framework_db) for file in db: + if filter is not None and re.search(filter, file) is None: + continue macros = [] cov_labels = [] cgf_macros = []