Test variables

Introduction [edit section]

When Fuego executes a test, shell environment variables are used to provide information about the test environment, test execution parameters, communications methods and parameters, and other items.

These pieces of information are originate from numerous different places. An initial set of test variables comes in the shell environment from either Jenkins or from the shell in which ftc is executed (depending on which one is used to invoke the test).

The information about the board being tested comes primarily from two sources:

Additional information comes from the testplan and test spec that are used for this particular test run. Finally, test variables can be defined on the 'ftc' command line. These test variables (know as "dynamic variables", override variables that come from other sources.

Test variables can be simple strings, or they may be shell functions.

When a test is run, Fuego gathers information from all these sources, and makes them available to the test (and uses them itself) to control test execution.

Board file [edit section]

The board file contains static information about a board. It is processed by the overlay system, and the values inside it appear as variables in the environment of a test, during test execution.

The board file resides in:

There are a number of variables which are used by the Fuego system itself, and there may also be variables that are used by individual tests.

Common board variables [edit section]

Here is a list of the variables which might be found in a board file:

See Adding a board for more details about these variables.

A board may also have additional variables, including variables that are used for results evaluation for specific tests.

Overlay system [edit section]

The overlay system gathers variables from several places, and puts them all together into a single file which is then source'ed into the running test's environment.

It takes information from:

The overlay system is described in greater detail here: Overlay_Generation

Stored variables [edit section]

Stored board variables are test variables that are defined on a per-board basis, and can be modified and managed under program control.

Stored variables allow the Fuego system, a test, or a user to store information that can be used by tests. This essentially creates an information cache about the board, that can be both manually and programmatically generated and managed.

The information that needs to be held for a particular board depends on the tests that are installed in the system. Thus the system needs to support ad-hoc collections of variables. Just putting everything into the static board file would not scale, as the number of tests increases.

Note: the LAVA test framework has a similar concept called a "board dictionary".

One use case for this to have a "board setup" test, that scans for lots of different items, and populates the stored variables with values that are used by other tests. Some items that are useful to know about a board take time to discover (using e.g. 'find' on the target board), and using a board dynamic variable can help reduce the time required to check these items.

The board stored variables are kept in the file:

These variables are included in the test by the overlay generator.

Commands for interacting with stored variables [edit section]

A user or a test can manipulate a board stored variable using the ftc command. The following commands can be used to set, query and delete variables:

ftc query-board [edit section]

'ftc query-board' is used to view the variables associated with a Fuego board. You can use the command to see all the variables, or just a single variable.

Note that 'ftc query-board' shows the variables for a test that come from both the board file and board stored variables file (that is, both 'static' board variables and stored variables). It does not show variables which come from testplans or spec files, as those are specific to a test.

The usage is:

Examples: $ ftc query-board myboard $ ftc query-board myboard -n PROGRAM_BC

The first example would show all board variables, including functions. The second example would show only the variable PROGRAM_BC, if it existed, for board 'myboard'.

ftc set-var [edit section]

'ftc set-var' allows setting or updating the value of a board stored variable.

The usage is:

By convention, variable names are all uppercase, and function names are lowercase, with words separated by underscores.

Example: $ ftc set-var PROGRAM_BC=/usr/bin/bc

ftc delete-var [edit section]

'ftc delete-var' removes a variable from the stored variables file.

Example: $ ftc delete-var PROGRAM_BC

Example usage [edit section]

Functional.fuego_board_check could detect the path for the 'foo' binary, (e.g. is_on_target foo PROGRAM_FOO) and call 'ftc set-var $NODE_NAME PROGRAM_FOO=$PROGRAM_FOO'. This would stay persistently defined as a test variable, so other tests could use $PROGRAM_FOO (with assert_defines, or in 'report' or 'cmd' function calls.)

Example Stored variables [edit section]

Here are some examples of variables that can be kept as stored variables, rather than static variables from the board file:

Spec variables [edit section]

A test spec can define one or more variables to be used with a test. These are commonly used to control test variations, and are specified in a spec.json file.

When a spec file defines a variable associated with a named test spec, the variable is read by the overlay generator on test execution, and the variable name is prefixed with the name of the test, and converted to all upper case.

For example, support a test called "Functional.foo" had a test spec that defined the variable 'args' with a line like the following in its spec.json file:

When the test was run with this spec (the "default" spec), then the variable FUNCTIONAL_FOO_ARGS would be defined, with the value "-v -p2".

See Test_Specs_and_Plans for more information about specs and plans.

Note that spec variables are overridden by

Dynamic variables [edit section]

Another category of variables used during testing are dynamic variables. These variables are defined on the command line of 'ftc run-test' using the '--dynamic-vars' option.

The purpose of these variables is to allow scripted variations when running 'ftc run-test' The scripted variables are processed and presented the same way as Spec variables, which is to say that the variable name is prefixed with the test name, and converted to all upper case.

For example, if the following command was issued:

then during test execution the variable "FUNCTIONAL_FOO_ARGS" would be defined with the value "-p".

See Dynamic Variables for more information.

Variable precedence [edit section]

Here is the precedence of variable definition for Fuego, during test execution:

(from lowest to highest)

Spec and dynamic variables are prefixed with the test name, and converted to upper case. That tends to keep them in a separate name space from the rest of the test variables.