[Fuego] [nirrognas][fuego-core][next] ftc: assume local if no board is specified

Tim.Bird at sony.com Tim.Bird at sony.com
Sat Sep 28 00:17:29 UTC 2019


> -----Original Message-----
> From Daniel Sangorrin
> 
> This is a small trick to execute tests locally in a more
> natural way. For example:
> 
> $ ftc run-test -t Functional.hello_world
> 
> Instead of the more verbose
> 
> $ ftc run-test -b local -t Functional.hello_world
> 
> Note: you can achieve the same by defining FUEGO_BOARD
> environment variable to "local", but defaulting to local
> seems even easier.
> 
> Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
> ---
>  scripts/ftc | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/ftc b/scripts/ftc
> index 01c8e21..7e50b87 100755
> --- a/scripts/ftc
> +++ b/scripts/ftc
> @@ -3804,7 +3804,7 @@ def do_run_test(conf, options):
>      global log, tail_fd
>      global server
> 
> -    board_names, options = get_board_arg("run-test", conf, options, '!,am')
> +    board_names, options = get_board_arg("run-test", conf, options, ',am')
> 
>      if len(board_names)>1:
>          # use recursion to loop over multiple boards
> @@ -3818,6 +3818,8 @@ def do_run_test(conf, options):
>              do_run_test(conf, recurse_options)
>      else:
>          board_name = board_names[0]
> +        if not board_name:
> +            board_name = "local"
> 
>      test_dict = {}
> 
> --
> 2.17.1

OK - I never accepted this patch, for the primary reason that it interferes
with error reporting for a malformed command line.  If the board is missing
from the command line, we don't know whether it's because we want to perform
the operation on a default 'local' board, or because the user just forgot.

I finally got around to implementing this functionality in a different way.  Well,
actually, I implemented this in July, and just got around to integrating
it into the Fuego master branch.

Here's how it works:
If you want support for operating on a default board, you specify a "default_board"
in the fuego configuration file.  If one is not specified, then if your 'ftc' command line
is missing a '-b <board>' option, then you'll get an error message, like usual.

If one *is* specified, and your 'ftc' command line is missing a '-b <board>' option, 
then the default board specified will be used.

If you only have a single board in your lab, or you are installing and using Fuego
natively (for local access), then you can set the default_board to save some typing.

Here's a sample line you could put in fuego-ro/conf/fuego.conf:
default_board=local

Here's the patch:
>From ec68ce093f0b877b53d406cb03f1fad2039c1945 Mon Sep 17 00:00:00 2001
From: Tim Bird <tim.bird at sony.com>
Date: Wed, 25 Sep 2019 11:47:02 -1000
Subject: [PATCH] ftc: add support for default_board in configuration file

If a 'default_board' is configured in the fuego configuration file
(fuego-ro/conf/fuego.conf), then use of the '-b <board>' argument
is optional for command lines that support the '-b' option.

The main purpose of this is to allow for shorter and easier command
lines when a fuego lab only has a single board.  This is particularly
useful for when Fuego is installed 'natively' on a board, to avoid
having to keep referencing the 'local' board on every command line.

Note that you can still specify a board using the environment
variable FUEGO_BOARD.  If that is specified, it takes precedence
over the value of 'default_board' specified in the fuego.conf file.

Signed-off-by: Tim Bird <tim.bird at sony.com>
---
 scripts/ftc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/scripts/ftc b/scripts/ftc
index 479f70f..6a57cdf 100755
--- a/scripts/ftc
+++ b/scripts/ftc
@@ -577,6 +577,7 @@ class config_class:
         self.host_name = conf_map.get("host_name", "localhost")
         self.server_type = conf_map.get("server_type", "fuego")
         self.server_domain = conf_map.get("server_domain", "fuegotest.org")
+        self.default_board = conf_map.get("default_board", "")
         #self.SERVER_URL_BASE = "http://%s/server/Fuego_Server?action=Fuego." % self.server_domain
         if self.server_type == "fuego":
             self.SERVER_URL_BASE = "http://%s/fserver.py/?action=" % self.server_domain
@@ -3741,7 +3742,12 @@ def get_board_arg(cmd, conf, options, flags):
         except:
             # ok - no board specified, is it required?
             if '!' in flags:
-                error_out("%s command requires a board" % cmd)
+                # ok, it's required, is a default board configured?
+                if conf.default_board:
+                    options.insert(0, conf.default_board)
+                    options.insert(0, "-b")
+                else:
+                    error_out("%s command requires a board" % cmd)
             else:
                 return ([None], options)
 
-- 
2.17.1



More information about the Fuego mailing list