Skip to content
This repository was archived by the owner on Apr 29, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions riscof/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ def testlist(ctx,config,work_dir,suite,env):
@click.option('--no-ref-run',is_flag=True,help="Do not run tests on Reference")
@click.option('--no-dut-run',is_flag=True,help="Do not run tests on DUT")
@click.option('--no-clean',is_flag=True,help="Do not clean work directory(if exists).")
@click.option(
'--filter', metavar='PATH', type=str,
help="Filter testcases to be run by regex")
@click.pass_context
def run(ctx,config,work_dir,suite,env,no_browser,dbfile,testfile,no_ref_run,no_dut_run,no_clean):
def run(ctx,config,work_dir,suite,env,no_browser,dbfile,testfile,no_ref_run,no_dut_run,no_clean,filter=None):
exitcode = 0
clean = (testfile is not None or dbfile is not None or no_clean)
setup_directories(work_dir,clean)
Expand Down Expand Up @@ -319,7 +322,7 @@ def run(ctx,config,work_dir,suite,env,no_browser,dbfile,testfile,no_ref_run,no_d
report_objects['platform_specs'] = pspecs

report_objects['results'] = framework.run(dut, base, ctx.obj.isa_file,
ctx.obj.platform_file, work_dir, cntr_args)
ctx.obj.platform_file, work_dir, cntr_args, filter)

report_objects['num_passed'] = 0
report_objects['num_failed'] = 0
Expand Down Expand Up @@ -381,8 +384,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)
Expand All @@ -404,7 +410,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()
Expand Down
9 changes: 4 additions & 5 deletions riscof/framework/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -160,7 +159,7 @@ def run_coverage(base, dut_isa_spec, dut_platform_spec, work_dir, cgf_file=None,

return results, for_html, test_stats, coverpoints

def run(dut, base, dut_isa_spec, dut_platform_spec, work_dir, cntr_args):
def run(dut, base, dut_isa_spec, dut_platform_spec, work_dir, cntr_args, filter):
'''
Entry point for the framework module. This function initializes and sets up the required
variables for the tests to run.
Expand Down Expand Up @@ -206,7 +205,7 @@ def run(dut, base, dut_isa_spec, dut_platform_spec, work_dir, cntr_args):
logger.info("Running Build for Reference")
base.build(dut_isa_spec, dut_platform_spec)

results = test.run_tests(dut, base, ispec['hart0'], pspec, work_dir, cntr_args)
results = test.run_tests(dut, base, ispec['hart0'], pspec, work_dir, cntr_args, filter)

return results

Expand Down
8 changes: 5 additions & 3 deletions riscof/framework/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,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.
Expand All @@ -326,6 +326,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 = []
Expand Down Expand Up @@ -397,7 +399,7 @@ def generate_test_pool(ispec, pspec, workdir, dbfile = None):
return (test_list, test_pool)


def run_tests(dut, base, ispec, pspec, work_dir, cntr_args):
def run_tests(dut, base, ispec, pspec, work_dir, cntr_args, filter):
'''
Function to run the tests for the DUT.

Expand All @@ -421,7 +423,7 @@ def run_tests(dut, base, ispec, pspec, work_dir, cntr_args):
if cntr_args[1] is not None:
test_list = utils.load_yaml(cntr_args[1])
else:
test_list, test_pool = generate_test_pool(ispec, pspec, work_dir, cntr_args[0])
test_list, test_pool = generate_test_pool(ispec, pspec, work_dir, cntr_args[0], filter=filter)
dut_test_list = {}
base_test_list = {}
for entry in test_list:
Expand Down