Message ID | 20180525155830.6864-4-leonardo.sandoval.gonzalez@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | benchtests: Increase interoperability and robustness | expand |
please ignore this patch (the rest of the series is fine). Will send a V2. Leo On Fri, 2018-05-25 at 10:58 -0500, leonardo.sandoval.gonzalez@linux.intel.com wrote: > From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> > > Catch runtime exceptions in case the user provided either wrong base > function or attribute(s). In any of the latter, quit immediately with > non-zero return code. > > * benchtests/scripts/compare_string.py: (process_results) Catch > exception in non-existent base_func. > (process_results) Catch exception in non-existent attribute. > --- > ChangeLog | 6 ++++++ > benchtests/scripts/compare_strings.py | 16 ++++++++++++++-- > 2 files changed, 20 insertions(+), 2 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index cc3e50e3b8d..20d55a47759 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,9 @@ > +2018-05-25 Leonardo Sandoval <leonardo.sandoval.gonzalez@intel.com > > > + > + * benchtests/scripts/compare_string.py: (process_resu > lts) Catch > + exception in non-existent base_func. > + (process_results) Catch exception in non-existent attribute > + > 2018-05-25 Leonardo Sandoval <leonardo.sandoval.gonzalez@intel.com > > > > * benchtests/scripts/compare_string.py: Add --no-header > option > diff --git a/benchtests/scripts/compare_strings.py > b/benchtests/scripts/compare_strings.py > index c629bba77fa..077b53fa6c9 100755 > --- a/benchtests/scripts/compare_strings.py > +++ b/benchtests/scripts/compare_strings.py > @@ -93,7 +93,12 @@ def process_results(results, attrs, base_func, > graph, no_diff, no_header): > > base_index = 0 > if base_func: > - base_index = > results['functions'][f]['ifuncs'].index(base_func) > + try: > + base_index = > results['functions'][f]['ifuncs'].index(base_func) > + except ValueError as ve: > + sys.stderr.write('Invalid -b "%s" parameter. > Options: %s.\n' % (base_func, > + > ', '.join(results['functions'][f]['ifuncs']))) > + sys.exit(os.EX_DATAERR) > > if not no_header: > print('Function: %s' % f) > @@ -103,7 +108,12 @@ def process_results(results, attrs, base_func, > graph, no_diff, no_header): > > graph_res = {} > for res in results['functions'][f]['results']: > - attr_list = ['%s=%s' % (a, res[a]) for a in attrs] > + try: > + attr_list = ['%s=%s' % (a, res[a]) for a in attrs] > + except KeyError as ke: > + sys.stderr.write('Invalid -a %s parameter. Options: > %s.\n' % (ke, > + > ', '.join([a for a in res.keys() if a != 'timings']))) > + sys.exit(os.EX_DATAERR) > i = 0 > key = ', '.join(attr_list) > sys.stdout.write('%36s: ' % key) > @@ -163,3 +173,5 @@ if __name__ == '__main__': > > args = parser.parse_args() > main(args) > + > + return os.EX_OK
diff --git a/ChangeLog b/ChangeLog index cc3e50e3b8d..20d55a47759 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-05-25 Leonardo Sandoval <leonardo.sandoval.gonzalez@intel.com> + + * benchtests/scripts/compare_string.py: (process_results) Catch + exception in non-existent base_func. + (process_results) Catch exception in non-existent attribute + 2018-05-25 Leonardo Sandoval <leonardo.sandoval.gonzalez@intel.com> * benchtests/scripts/compare_string.py: Add --no-header option diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py index c629bba77fa..077b53fa6c9 100755 --- a/benchtests/scripts/compare_strings.py +++ b/benchtests/scripts/compare_strings.py @@ -93,7 +93,12 @@ def process_results(results, attrs, base_func, graph, no_diff, no_header): base_index = 0 if base_func: - base_index = results['functions'][f]['ifuncs'].index(base_func) + try: + base_index = results['functions'][f]['ifuncs'].index(base_func) + except ValueError as ve: + sys.stderr.write('Invalid -b "%s" parameter. Options: %s.\n' % (base_func, + ', '.join(results['functions'][f]['ifuncs']))) + sys.exit(os.EX_DATAERR) if not no_header: print('Function: %s' % f) @@ -103,7 +108,12 @@ def process_results(results, attrs, base_func, graph, no_diff, no_header): graph_res = {} for res in results['functions'][f]['results']: - attr_list = ['%s=%s' % (a, res[a]) for a in attrs] + try: + attr_list = ['%s=%s' % (a, res[a]) for a in attrs] + except KeyError as ke: + sys.stderr.write('Invalid -a %s parameter. Options: %s.\n' % (ke, + ', '.join([a for a in res.keys() if a != 'timings']))) + sys.exit(os.EX_DATAERR) i = 0 key = ', '.join(attr_list) sys.stdout.write('%36s: ' % key) @@ -163,3 +173,5 @@ if __name__ == '__main__': args = parser.parse_args() main(args) + + return os.EX_OK
From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Catch runtime exceptions in case the user provided either wrong base function or attribute(s). In any of the latter, quit immediately with non-zero return code. * benchtests/scripts/compare_string.py: (process_results) Catch exception in non-existent base_func. (process_results) Catch exception in non-existent attribute. --- ChangeLog | 6 ++++++ benchtests/scripts/compare_strings.py | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)