From: leonardo.sandoval.gonzalez@linux.intel.com
To: libc-alpha@sourceware.org
Cc: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Subject: [PATCH 3/3] benchtests: Catch exceptions in input arguments
Date: Fri, 25 May 2018 15:58:00 -0000 [thread overview]
Message-ID: <20180525155830.6864-4-leonardo.sandoval.gonzalez@linux.intel.com> (raw)
In-Reply-To: <20180525155830.6864-1-leonardo.sandoval.gonzalez@linux.intel.com>
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_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
--
2.17.0
next prev parent reply other threads:[~2018-05-25 15:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-25 15:58 [PATCH 0/3] benchtests: Increase interoperability and robustness leonardo.sandoval.gonzalez
2018-05-25 15:58 ` [PATCH 2/3] benchtests: Add --no-header option to omit header leonardo.sandoval.gonzalez
2018-05-27 12:35 ` Siddhesh Poyarekar
2018-05-25 15:58 ` leonardo.sandoval.gonzalez [this message]
2018-05-25 19:54 ` [PATCH 3/3] benchtests: Catch exceptions in input arguments Leonardo Sandoval
2018-05-25 15:58 ` [PATCH 1/3] benchtests: Add --no-diff option to avoid diff calculation leonardo.sandoval.gonzalez
2018-05-27 12:32 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180525155830.6864-4-leonardo.sandoval.gonzalez@linux.intel.com \
--to=leonardo.sandoval.gonzalez@linux.intel.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).