Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new cli param '--filter' #127

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
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
7 changes: 5 additions & 2 deletions riscof/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
5 changes: 2 additions & 3 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
4 changes: 3 additions & 1 deletion riscof/framework/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 = []
Expand Down