From eda6a7e1ccf1137de442e88e2897191d67ddb2ae Mon Sep 17 00:00:00 2001 From: S Pawan Kumar Date: Mon, 13 Sep 2021 13:37:04 +0530 Subject: [PATCH 1/2] Added return code of 1 on errors. --- riscof/Templates/setup/model/riscof_model.py | 4 ++-- .../Templates/setup/reference/riscof_model.py | 8 ++++---- .../setup/sail_cSim/riscof_sail_cSim.py | 10 +++++----- riscof/cli.py | 19 +++++++++++-------- riscof/framework/test.py | 8 ++++---- riscof/utils.py | 2 +- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/riscof/Templates/setup/model/riscof_model.py b/riscof/Templates/setup/model/riscof_model.py index fddb267..b75e11b 100644 --- a/riscof/Templates/setup/model/riscof_model.py +++ b/riscof/Templates/setup/model/riscof_model.py @@ -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 @@ -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. diff --git a/riscof/Templates/setup/reference/riscof_model.py b/riscof/Templates/setup/reference/riscof_model.py index f7a51ad..f0c2002 100644 --- a/riscof/Templates/setup/reference/riscof_model.py +++ b/riscof/Templates/setup/reference/riscof_model.py @@ -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 @@ -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'] @@ -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 @@ -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 diff --git a/riscof/Templates/setup/sail_cSim/riscof_sail_cSim.py b/riscof/Templates/setup/sail_cSim/riscof_sail_cSim.py index 258ee1f..3ee8659 100644 --- a/riscof/Templates/setup/sail_cSim/riscof_sail_cSim.py +++ b/riscof/Templates/setup/sail_cSim/riscof_sail_cSim.py @@ -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"), @@ -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): diff --git a/riscof/cli.py b/riscof/cli.py index ac3806e..2dbf844 100644 --- a/riscof/cli.py +++ b/riscof/cli.py @@ -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): @@ -69,7 +69,7 @@ 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) @@ -77,7 +77,7 @@ def prepare_models(config_dir,config): 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) @@ -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) @@ -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 @@ -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 @@ -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()) @@ -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) @@ -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) @@ -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() diff --git a/riscof/framework/test.py b/riscof/framework/test.py index 7e7c745..a493d68 100644 --- a/riscof/framework/test.py +++ b/riscof/framework/test.py @@ -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() @@ -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') @@ -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) diff --git a/riscof/utils.py b/riscof/utils.py index e8b60a2..546651f 100644 --- a/riscof/utils.py +++ b/riscof/utils.py @@ -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): """ From 7d2947b4b0de83f1f5e8fbcc834fa6311636ca46 Mon Sep 17 00:00:00 2001 From: S Pawan Kumar Date: Mon, 13 Sep 2021 13:38:01 +0530 Subject: [PATCH 2/2] =?UTF-8?q?Bump=20version:=201.22.0=20=E2=86=92=201.22?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ riscof/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c28f67..bdf58fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/riscof/__init__.py b/riscof/__init__.py index c720815..88d9bc0 100644 --- a/riscof/__init__.py +++ b/riscof/__init__.py @@ -4,4 +4,4 @@ __author__ = """InCore Semiconductors Pvt Ltd""" __email__ = 'info@incoresemi.com' -__version__ = '1.22.0' +__version__ = '1.22.1' diff --git a/setup.cfg b/setup.cfg index cbb8393..90e26cd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.22.0 +current_version = 1.22.1 commit = True tag = True diff --git a/setup.py b/setup.py index da09f18..48d72a1 100644 --- a/setup.py +++ b/setup.py @@ -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=[