[Fuego] [PATCH 24/30] run-test: support dynamic variables

Tim.Bird at sony.com Tim.Bird at sony.com
Wed Jun 6 02:44:32 UTC 2018


OK - I got to here in my code review.  I've applied previous
patches up to this point (1 through 23), with a few issues
I tagged to come back and check on.

I'll discuss those issues in a separate e-mail tomorrow.
My brain is kind of full tonight, so I don't trust myself to
finish this without some additional thought.  One issue
with this patch is mentioned below.

I'll try to finish off the series and do some testing tomorrow.
 -- Tim


> -----Original Message-----
> From: Daniel Sangorrin
> 
> A spec is created and saved in the logdir folder. This is
> good not only for dynamic variables but also for static specs
> because we can easily package the logdir folder with all
> the important data.
> 
> Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
> ---
>  engine/scripts/ftc | 47
> ++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> index 7da4f27..bfdc3d4 100755
> --- a/engine/scripts/ftc
> +++ b/engine/scripts/ftc
> @@ -3164,6 +3164,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]
> @@ -3171,7 +3183,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')
>      else:
> @@ -3369,6 +3382,38 @@ def do_run_test(conf, options):
>      build_data.timestamp = timestamp
>      os.environ["BUILD_TIMESTAMP"] = build_data.timestamp
> 
> +    # create a folder for this run
> +    run_dir = job_dir + "/builds/" + build_data.build_number
> +    if not os.path.isdir(run_dir):
> +        if fuego_caller == "jenkins":
> +            error_out("Jenkins did not create run folder " + run_dir)
> +        os.mkdir(run_dir)
> +
> +    # prepare a per-run spec.json file
> +    specpath = '%s/engine/tests/%s/spec.json' % (conf.FUEGO_CORE,
> test_name)

I had also intended to support per-board spec files (like we do with
per-board criteria files).  But that can be added later.  With dynamic
variables, the need for this is significantly reduced.

> +    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 != spec_name:
> +            del test_spec_data['specs'][key]
> +
> +    if dyn_vars:
> +        if spec_name not in test_spec_data['specs']:
> +            test_spec_data['specs'][spec_name] = dyn_vars
> +        else:
> +            for key in dyn_vars.keys():
> +                test_spec_data['specs'][spec_name][key] = dyn_vars[key]
> +
> +    # 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)
> +
>      # create log file
>      console_log_filename = "consolelog.txt"
>      log_filename = run_dir + os.sep + console_log_filename
> --
> 2.7.4
> 
> 
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego


More information about the Fuego mailing list