Skip to content

Commit

Permalink
Merge pull request #21 from riscv-software-src/fix-return-code
Browse files Browse the repository at this point in the history
Fix Return Code
  • Loading branch information
neelgala authored Sep 13, 2021
2 parents cfa79f9 + 7d2947b commit c2a1346
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 27 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.22.1] - 2021-09-13
- Added return code of 1 on error

## [1.22.0] - 2021-09-10
- Fixed signature alignment to begin and end at 16-byte boundaries for all header templates.

Expand Down
4 changes: 2 additions & 2 deletions riscof/Templates/setup/model/riscof_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, *args, **kwargs):
# the paths to the ispec and pspec files
if config is None:
print("Please enter input file paths in configuration.")
raise SystemExit
raise SystemExit(1)

# In case of an RTL based DUT, this would be point to the final binary executable of your
# test-bench produced by a simulator (like verilator, vcs, incisive, etc). In case of an iss or
Expand Down Expand Up @@ -176,7 +176,7 @@ def runTests(self, testList):
# if target runs are not required then we simply exit as this point after running all
# the makefile targets.
if not self.target_run:
raise SystemExit
raise SystemExit(0)

#The following is an alternate template that can be used instead of the above.
#The following template only uses shell commands to compile and run the tests.
Expand Down
8 changes: 4 additions & 4 deletions riscof/Templates/setup/reference/riscof_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialise(self, suite, work_dir, archtest_env):
self.suite = suite
if shutil.which(self.ref_exe) is None:
logger.error('Please install Executable for DUTNAME to proceed further')
sys.exit(0)
raise SystemExit(1)
self.work_dir = work_dir

#TODO: The following assumes you are using the riscv-gcc toolchain. If
Expand All @@ -55,7 +55,7 @@ def initialise(self, suite, work_dir, archtest_env):

# set all the necessary variables like compile command, elf2hex
# commands, objdump cmds. etc whichever you feel necessary and required
# for your plugin.
# for your plugin.

def build(self, isa_yaml, platform_yaml):
ispec = utils.load_yaml(isa_yaml)['hart0']
Expand Down Expand Up @@ -90,7 +90,7 @@ def runTests(self, testList, cgf_file=None):
test_name = test.rsplit('/',1)[1][:-2]

elf = 'ref.elf'

execute = "@cd "+testentry['work_dir']+";"

cmd = self.compile_cmd.format(testentry['isa'].lower(), self.xlen) + ' ' + test + ' -o ' + elf
Expand All @@ -105,7 +105,7 @@ def runTests(self, testList, cgf_file=None):

#TODO: You will need to add any other arguments to your DUT
# executable if any in the quotes below
execute += self.ref_exe + ''
execute += self.ref_exe + ''

#TODO: The following is useful only if your reference model can
# support coverage extraction from riscv-isac. Else leave it
Expand Down
10 changes: 5 additions & 5 deletions riscof/Templates/setup/sail_cSim/riscof_sail_cSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, *args, **kwargs):
config = kwargs.get('config')
if config is None:
logger.error("Config node for sail_cSim missing.")
raise SystemExit
raise SystemExit(1)
self.num_jobs = str(config['jobs'] if 'jobs' in config else 1)
self.pluginpath = os.path.abspath(config['pluginpath'])
self.sail_exe = { '32' : os.path.join(config['PATH'] if 'PATH' in config else "","riscv_sim_RV32"),
Expand Down Expand Up @@ -66,17 +66,17 @@ def build(self, isa_yaml, platform_yaml):
objdump = "riscv{0}-unknown-elf-objdump".format(self.xlen)
if shutil.which(objdump) is None:
logger.error(objdump+": executable not found. Please check environment setup.")
raise SystemExit
raise SystemExit(1)
compiler = "riscv{0}-unknown-elf-gcc".format(self.xlen)
if shutil.which(compiler) is None:
logger.error(compiler+": executable not found. Please check environment setup.")
raise SystemExit
raise SystemExit(1)
if shutil.which(self.sail_exe[self.xlen]) is None:
logger.error(self.sail_exe[self.xlen]+ ": executable not found. Please check environment setup.")
raise SystemExit
raise SystemExit(1)
if shutil.which(self.make) is None:
logger.error(self.make+": executable not found. Please check environment setup.")
raise SystemExit
raise SystemExit(1)


def runTests(self, testList, cgf_file=None):
Expand Down
2 changes: 1 addition & 1 deletion riscof/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = """InCore Semiconductors Pvt Ltd"""
__email__ = '[email protected]'
__version__ = '1.22.0'
__version__ = '1.22.1'
19 changes: 11 additions & 8 deletions riscof/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def read_config(configfile):
config.read(configfile)
except FileNotFoundError as err:
logger.error(err)
raise SystemExit
raise SystemExit(1)
return config,os.path.dirname(os.path.abspath(configfile))

def prepare_models(config_dir,config):
Expand All @@ -69,15 +69,15 @@ def prepare_models(config_dir,config):
except KeyError as key:
logger.error("Error in config file. Possible missing keys.")
logger.error(key)
raise SystemExit
raise SystemExit(1)

logger.debug("Importing " + dut_model + " plugin from: "+str(dut_model_path))
sys.path.append(dut_model_path)
try:
dut_plugin = importlib.import_module("riscof_" + dut_model)
except ImportError as msg:
logger.error("Error while importing "+dut_model+".\n"+str(msg))
raise SystemExit
raise SystemExit(1)
dut_class = getattr(dut_plugin, dut_model)
if dut_model in config:
dut = dut_class(name="DUT", config=config[dut_model], config_dir=config_dir)
Expand All @@ -90,7 +90,7 @@ def prepare_models(config_dir,config):
base_plugin = importlib.import_module("riscof_" + base_model)
except ImportError as msg:
logger.error("Error while importing "+base_model+".\n"+str(msg))
raise SystemExit
raise SystemExit(1)
base_class = getattr(base_plugin, base_model)
if base_model in config:
base = base_class(name="Reference", config=config[base_model], config_dir=config_dir)
Expand Down Expand Up @@ -183,7 +183,7 @@ def validate(ctx,config,work_dir):
platform_file = checker.check_platform_specs( platform_file, work_dir, True)
except ValidationError as msg:
logger.error(msg)
raise SystemExit
raise SystemExit(1)
ctx.obj.isa_file = isa_file
ctx.obj.platform_file = platform_file

Expand Down Expand Up @@ -261,6 +261,7 @@ def testlist(ctx,config,work_dir,suite,env):
@click.option('--no-dut-run',is_flag=True,help="Do not run tests on DUT")
@click.pass_context
def run(ctx,config,work_dir,suite,env,no_browser,dbfile,testfile,no_ref_run,no_dut_run):
exitcode = 0
setup_directories(work_dir,(testfile is not None or dbfile is not None))
ctx.obj.mkdir = False
constants.env = env
Expand Down Expand Up @@ -326,6 +327,7 @@ def run(ctx,config,work_dir,suite,env,no_browser,dbfile,testfile,no_ref_run,no_d
report_objects['num_passed'] += 1
else:
report_objects['num_failed'] += 1
exitcode = 1

with open(constants.html_template, "r") as report_template:
template = Template(report_template.read())
Expand All @@ -345,8 +347,9 @@ def run(ctx,config,work_dir,suite,env,no_browser,dbfile,testfile,no_ref_run,no_d
import webbrowser
logger.info("Openning test report in web-browser")
webbrowser.open(reportfile)
raise SystemExit(exitcode)
except:
raise SystemExit
raise SystemExit(exitcode)



Expand Down Expand Up @@ -437,7 +440,7 @@ def coverage(ctx,config,work_dir,suite,env,no_browser,cgf_file):
logger.info("Openning test report in web-browser")
webbrowser.open(reportfile)
except:
raise SystemExit
raise SystemExit(0)



Expand Down Expand Up @@ -541,7 +544,7 @@ def setup(dutname,refname,work_dir):
configfile.close()
except FileExistsError as err:
logger.error(err)
raise SystemExit
raise SystemExit(1)

if __name__=="__main__":
cli()
8 changes: 4 additions & 4 deletions riscof/framework/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def compare_signature(file1, file2):
'''
if not os.path.exists(file1) :
logger.error('Signature file : ' + file1 + ' does not exist')
sys.exit(1)
raise SystemExit(1)
file1_lines = open(file1, "r").readlines()
res = ("".join(
difflib.unified_diff(file1_lines,open(file2, "r").readlines(), file1, file2))).strip()
Expand Down Expand Up @@ -302,7 +302,7 @@ def generate_test_pool(ispec, pspec, workdir, dbfile = None):
test_list[entry[0]]=temp
if (len(test_list) == 0):
logger.error('No Tests Selected')
raise SystemExit
raise SystemExit(1)

with open(os.path.join(workdir,"test_list.yaml"),"w") as tfile:
tfile.write('# testlist generated on ' + (datetime.now(pytz.timezone('GMT'))).strftime("%Y-%m-%d %H:%M GMT")+'\n')
Expand Down Expand Up @@ -351,12 +351,12 @@ def run_tests(dut, base, ispec, pspec, work_dir, cntr_args):
logger.info("Running Tests on DUT.")
dut.runTests(dut_test_list)
logger.info("Tests run on DUT done.")
raise SystemExit
raise SystemExit(0)
elif cntr_args[3]:
logger.info("Running Tests on Reference Model.")
base.runTests(base_test_list)
logger.info("Tests run on Reference done.")
raise SystemExit
raise SystemExit(0)
else:
logger.info("Running Tests on DUT.")
dut.runTests(dut_test_list)
Expand Down
2 changes: 1 addition & 1 deletion riscof/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def load_yaml(foo):
logger = logging.getLogger(__name__)
error = "\n".join(str(msg).split("\n")[2:-7])
logger.error(error)
raise SystemExit
raise SystemExit(1)

def absolute_path(config_dir, entry_path):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.22.0
current_version = 1.22.1
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def read_requires():
test_requirements = [ ]

setup(name="riscof",
version='1.22.0',
version='1.22.1',
description="RISC-V Architectural Test Framework",
long_description=readme + '\n\n',
classifiers=[
Expand Down

0 comments on commit c2a1346

Please sign in to comment.