All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
To: fuego@lists.linuxfoundation.org
Subject: [Fuego] [PATCH 3/3] ftc: add dynamic-vars to ftc run-test
Date: Tue,  4 Sep 2018 19:01:32 +0900	[thread overview]
Message-ID: <1536055292-34772-4-git-send-email-daniel.sangorrin@toshiba.co.jp> (raw)
In-Reply-To: <1536055292-34772-1-git-send-email-daniel.sangorrin@toshiba.co.jp>

This patch adds the ability to override parameters of a
base spec (if not specified, the default spec is used)
from ftc run-test. The values are logged into the run's
log folder as spec.json. It is useful to modify the
parameters given to a test in a quick manner.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
---
 engine/scripts/ftc | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index 2840f5c..875ed59 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -242,6 +242,7 @@ You can obtain a list of run_ids for runs on the local system with
     """Usage: ftc run-test -b <board> -t <test> [-s <spec>] [-p <phases>]
     [-k <kill timeout>] [--rebuild <true|false>] [--reboot <true|false>]
     [--precleanup <true|false>] [--postcleanup <true|false>]
+    [--dynamic-vars python_dict]
 Run the indicated test on the specified board.  Use the
 indicated spec, if one is provided.
 
@@ -251,6 +252,8 @@ rebuild: if true rebuild the test source even if it was already built.
 reboot: if true reboot the board before the test.
 precleanup: if true clean the board's test folder before the test.
 postcleanup: if true clean the board's test folder after the test.
+dynamic-vars: allows overriding the variables in a spec from the command line.
+  Example: ftc run-test -b bbb -t Benchmark.Dhrystone --dynamic-vars "{'LOOPS':'400000000'}"
 
 A list of phase characters may be provided, to execute only those phases
   p = pre_test, c=pre_check, b=build, d=deploy, r=run,
@@ -3219,6 +3222,18 @@ def do_run_test(conf, options):
     else:
         error_out("Run-test command requires a test name")
 
+    if '--dynamic-vars' in options:
+        try:
+            import ast
+            dyn_vars_str = options[options.index('--dynamic-vars') + 1]
+            dyn_vars = ast.literal_eval(dyn_vars_str)
+        except IndexError:
+            error_out('Dynamic vars not provided after --dynamic-vars.')
+        options.remove(dyn_vars_str)
+        options.remove('--dynamic-vars')
+    else:
+        dyn_vars = None
+
     if '-s' in options:
         try:
             spec_name = options[options.index('-s') + 1]
@@ -3226,7 +3241,8 @@ def do_run_test(conf, options):
             error_out('Testspec not provided after -s.')
         spec_list = get_specs(conf, test_name)
         if spec_name not in spec_list:
-            error_out('Unknown spec %s' % spec_name)
+            if not dyn_vars:
+                error_out('Unknown spec %s' % spec_name)
         options.remove(spec_name)
         options.remove('-s')
         test_dict["spec"] = spec_name
@@ -3405,6 +3421,12 @@ def do_run_test(conf, options):
         build_number = find_next_build_number_by_log_scan(logs_dir)
 
     build_data.build_number = build_number
+    build_data.test_logdir = conf.FUEGO_RW + '/logs/' + \
+        build_data.test_name    + '/' + \
+        build_data.board_name   + '.' + \
+        build_data.spec_name    + '.' + \
+        build_data.build_number + '.' + \
+        build_data.build_number
 
     os.environ["EXECUTOR_NUMBER"] = "0"
     os.environ["BUILD_ID"] = build_data.build_number
@@ -3437,6 +3459,36 @@ def do_run_test(conf, options):
     os.environ["Target_PreCleanup"] = build_data.precleanup_flag
     os.environ["Target_PostCleanup"] = build_data.postcleanup_flag
 
+    # prepare a per-run spec.json file
+    specpath = '%s/engine/tests/%s/spec.json' % (conf.FUEGO_CORE, test_name)
+    with open(specpath) as f:
+        try:
+            test_spec_data = json.load(f)
+        except:
+            error_out("Error parsing spec file %s" % specpath)
+
+    for key in test_spec_data['specs'].keys():
+        if key != test.spec:
+            del test_spec_data['specs'][key]
+
+    print "dynvars: " + str(dyn_vars)
+    if dyn_vars:
+        if test.spec not in test_spec_data['specs']:
+            test_spec_data['specs'][test.spec] = dyn_vars
+        else:
+            for key in dyn_vars.keys():
+                test_spec_data['specs'][test.spec][key] = dyn_vars[key]
+        # track what variables where modified
+        test_spec_data['specs'][test.spec]['dyn_vars'] = dyn_vars.keys()
+
+    print "test spec data" + str(test_spec_data)
+
+    # FIXTHIS: use a more pythonic way
+    os.system("mkdir -p " + build_data.test_logdir)
+
+    with open(build_data.test_logdir + '/spec.json', 'w+') as spec_file:
+        json.dump(test_spec_data, spec_file)
+
     # cd to buildzone directory
     saved_cur_dir = os.getcwd()
     os.chdir(build_data.workspace)
-- 
2.7.4


  parent reply	other threads:[~2018-09-04 10:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04 10:01 [Fuego] Dynamic variables Daniel Sangorrin
2018-09-04 10:01 ` [Fuego] [PATCH 1/3] of: use logdir argument instead of prolog.sh Daniel Sangorrin
2018-09-07 18:25   ` Tim.Bird
2018-09-04 10:01 ` [Fuego] [PATCH 2/3] OF: create a spec.json on each run Daniel Sangorrin
2018-09-07 18:31   ` Tim.Bird
2018-09-04 10:01 ` Daniel Sangorrin [this message]
2018-09-07 18:55   ` [Fuego] [PATCH 3/3] ftc: add dynamic-vars to ftc run-test Tim.Bird
2018-10-05  1:43     ` Daniel Sangorrin
2018-10-06  1:18       ` Tim.Bird

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=1536055292-34772-4-git-send-email-daniel.sangorrin@toshiba.co.jp \
    --to=daniel.sangorrin@toshiba.co.jp \
    --cc=fuego@lists.linuxfoundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.