Hoa Nguyen has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/34198 )

Change subject: ext: Add support for comma-separated inputs of testlib argparser
......................................................................

ext: Add support for comma-separated inputs of testlib argparser

Currently, the --isa, --variant and --length options of testlib
do not support comma-separated inputs. This commit adds the
support for such an input for those options.

The argument parser now supports specifying the parameters multiple
times as well as specifying multiple options at a time.

JIRA: https://gem5.atlassian.net/jira/software/c/projects/GEM5/issues/GEM5-770

Change-Id: I3c276a9b9d9c6b0b802ecf8e7f1f9a3dfafe45d1
Signed-off-by: Hoa Nguyen <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34198
Maintainer: Bobby R. Bruce <[email protected]>
Tested-by: kokoro <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
---
M ext/testlib/configuration.py
1 file changed, 14 insertions(+), 3 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/ext/testlib/configuration.py b/ext/testlib/configuration.py
index 1267c25..c9c10ea 100644
--- a/ext/testlib/configuration.py
+++ b/ext/testlib/configuration.py
@@ -486,6 +486,8 @@
     '''
     global common_args

+    parse_comma_separated_string = lambda st: st.split(',')
+
     # A list of common arguments/flags used across cli parsers.
     common_args = [
         Argument(
@@ -503,20 +505,23 @@
             help='A tag comparison used to select tests.'),
         Argument(
             '--isa',
-            action='append',
+            action='extend',
             default=[],
+            type=parse_comma_separated_string,
             help="Only tests that are valid with one of these ISAs. "
                  "Comma separated."),
         Argument(
             '--variant',
-            action='append',
+            action='extend',
             default=[],
+            type=parse_comma_separated_string,
help="Only tests that are valid with one of these binary variants"
                  "(e.g., opt, debug). Comma separated."),
         Argument(
             '--length',
-            action='append',
+            action='extend',
             default=[],
+            type=parse_comma_separated_string,
help="Only tests that are one of these lengths. Comma separated."),
         Argument(
             '--host',
@@ -596,6 +601,11 @@

 @add_metaclass(abc.ABCMeta)
 class ArgParser(object):
+    class ExtendAction(argparse.Action):
+        def __call__(self, parser, namespace, values, option_string=None):
+            items = getattr(namespace, self.dest, [])
+            items.extend(values)
+            setattr(namespace, self.dest, items)

     def __init__(self, parser):
         # Copy public methods of the parser.
@@ -603,6 +613,7 @@
             if not attr.startswith('_'):
                 setattr(self, attr, getattr(parser, attr))
         self.parser = parser
+        self.parser.register('action', 'extend', ArgParser.ExtendAction)
         self.add_argument = self.parser.add_argument

         # Argument will be added to all parsers and subparsers.

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34198
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I3c276a9b9d9c6b0b802ecf8e7f1f9a3dfafe45d1
Gerrit-Change-Number: 34198
Gerrit-PatchSet: 6
Gerrit-Owner: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to