Skip to content

Commit

Permalink
Merge pull request #13 from incoresemi/print-num-instructions
Browse files Browse the repository at this point in the history
count num of instructions executed per test and cummulative number
  • Loading branch information
neelgala authored Dec 12, 2023
2 parents b83d7c1 + fe1f694 commit ed58597
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.4.1] - 2023-12-12
- count num of instructions executed per test and cummulative number

## [1.4.0] - 2023-04-25
- use riscv-config isa validator for checking the isa string

Expand Down
2 changes: 1 addition & 1 deletion river_core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def check_config():
return str(os.getcwd()) + '/river_core.ini'
else:
logger.error("Couldn't find config file anywhere. Exiting")
raise SystemExit
raise SystemExit(1)


@click.group()
Expand Down
12 changes: 8 additions & 4 deletions river_core/rivercore.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def generate_report(output_dir, gen_json_data, target_json_data, ref_json_data,
## Get the proper stats about passed and failed test
# NOTE: This is the place where you determine when your test passed fail, just add extra things to compare in the if condition if the results become to high
num_passed = num_total = num_unav = num_failed = 0
total_instr = 0
for test in test_dict:
num_total = num_total + 1
try:
Expand All @@ -169,6 +170,7 @@ def generate_report(output_dir, gen_json_data, target_json_data, ref_json_data,
num_passed = num_passed + 1
else:
num_failed = num_failed + 1
total_instr += test_dict[test]['num_instr']
except:
logger.warning("Couldn't get a result from the Test List Dict")

Expand All @@ -193,6 +195,7 @@ def generate_report(output_dir, gen_json_data, target_json_data, ref_json_data,
html_objects['num_passed'] = num_passed
html_objects['num_failed'] = num_failed
html_objects['num_unav'] = num_unav
html_objects['total_instr'] = total_instr

if not os.path.exists(report_dir):
os.makedirs(report_dir)
Expand Down Expand Up @@ -623,7 +626,7 @@ def rivercore_compile(config_file, test_list, coverage, verbosity, dut_flags,
test_dict[test]['log'] = "REF dump is missing"
success = False
continue
result, log = utils.compare_signature(test_wd + '/dut.dump', test_wd + '/ref.dump')
result, log, insnsize = utils.compare_signature(test_wd + '/dut.dump', test_wd + '/ref.dump')
else:
if not os.path.isfile(test_wd + 'dut.signature'):
logger.error(f'{test:<30} : DUT signature is missing')
Expand All @@ -634,6 +637,7 @@ def rivercore_compile(config_file, test_list, coverage, verbosity, dut_flags,
result, log = utils.self_check(test_wd + '/dut.signature')
test_dict[test]['result'] = result
test_dict[test]['log'] = log
test_dict[test]['num_instr'] = insnsize
if result == 'Passed':
logger.info(f"{test:<30} : TEST {result.upper()}")
else:
Expand Down Expand Up @@ -785,7 +789,7 @@ def rivercore_merge(verbosity, db_folders, output, config_file):
logger.info(output + ' directory deleted')
else:
logger.info('Alright\nBailing out.')
raise SystemExit
raise SystemExit(1)
os.makedirs(output)
asm_dir = output + '/asm'
common_dir = output + '/common'
Expand Down Expand Up @@ -819,7 +823,7 @@ def rivercore_merge(verbosity, db_folders, output, config_file):
folder_yaml[test]['work_dir'], test_asm))
if ret_val != 0:
logger.error('Failed to copy files\nFiles donot exist')
raise SystemExit
raise SystemExit(1)
# Check if something common is there
if folder_yaml[test].get('extra_compile'):
for extra in range(0, len(folder_yaml[test]['extra_compile'])):
Expand Down Expand Up @@ -898,7 +902,7 @@ def rivercore_merge(verbosity, db_folders, output, config_file):
logger.error(
"Sorry, loading the requested plugin has failed, please check the configuration"
)
raise SystemExit
raise SystemExit(1)

# Perform Merge only if coverage enabled
if (utils.str_2_bool(config['coverage']['code']) or
Expand Down
5 changes: 4 additions & 1 deletion river_core/templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,13 @@ <h3><a href="{{ reference }}.html">Reference Results</a></h3>
<h2>Log comparison result:</h2>
<p class="filter" hidden="true">(Un)check the boxes to filter the results.</p><input checked="true" class="filter" data-test-result="passed" name="filter_checkbox" onChange="filter_table(this)" type="checkbox"/><span class="passed">{{ num_passed }} Passed</span>, <input checked="true" class="filter" data-test-result="failed" name="filter_checkbox" onChange="filter_table(this)" type="checkbox"/><span class="failed">{{ num_failed }} Failed</span><input checked="true" class="filter" data-test-result="unavailable" name="filter_checkbox" onChange="filter_table(this)" type="checkbox"/><span class="unavailable"> {{ num_unav }} Unavailable</span>
<h3> Out of Total: {{ num_failed + num_passed + num_unav }} Tests </h3>
<h3> Total Instructions Execute: {{ total_instr }} Instructions </h3>

<table id="results-table">
<thead id="simple-table-head">
<tr>
<th class="sortable" col="name">Test-name</th>
<th col="numinsns">No. of Insns</th>
<th col="path">Directory</th>
<th class="sortable result initial-sort" col="result">Result</th>
</tr>
Expand All @@ -307,11 +309,12 @@ <h3> Out of Total: {{ num_failed + num_passed + num_unav }} Tests </h3>
<tbody class= "{{ test_dict[test]['result'].lower() }} simple-table-row" >
<tr>
<td class="col-name">{{ test }}</td>
<td class="col-numinsns">{{ test_dict[test]['num_instr'] }}</td>
<td class="col-path">{{ test_dict[test]['work_dir']}}</td>
<td class="col-result">{{ test_dict[test]['result']}}</td>
</tr>
<tr>
<td class="extra" colspan="4">
<td class="extra" colspan="5">
<div class="log">{{ test_dict[test]['log']}}</br></div></td>
</tr>
</tbody>
Expand Down
7 changes: 5 additions & 2 deletions river_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def compare_signature(file1, file2):
status = 'Failed'
else:
status = 'Passed'
with open(f'{file1}','r') as fd:
rcount = len(fd.readlines())


# file1_lines = open(file1, "r").readlines()
# file2_lines = open(file2, "r").readlines()
Expand Down Expand Up @@ -86,7 +89,7 @@ def compare_signature(file1, file2):
# include = False
# prev = rline
## res = error_report
return status, rout
return status, rout, rcount

def str_2_bool(string):
"""
Expand Down Expand Up @@ -136,7 +139,7 @@ def load_yaml(input_yaml):
with open(input_yaml, "r") as file:
return dict(yaml.load(file))
except ruamel.yaml.constructor.DuplicateKeyError as msg:
raise SystemExit
raise SystemExit(1)


def check_isa(isa):
Expand Down

0 comments on commit ed58597

Please sign in to comment.