Skip to content

Set parameterized values on command line

Richard R. Drake edited this page Jun 8, 2022 · 1 revision

The -S option allows runtime control of the parameter values for parameterized tests. For example, the test

#VVT: parameterize: np = 512
import vvtest_util as vvt
print( "np="+vvt.np )

could be run with np equal to 8 by using

$ vvtest -S np=8

In this case, the test would print "np=8".

In general,

  • All tests that define the parameter name have the values of that name replaced by the value given on the command line
  • Tests that use the name in grouped parameters are skipped (not run)
  • Tests that do not define a parameter with that name are run unmodified

Behavior on staged tests

If a test defines multiple values for a parameter, then using -S name=value will cause the test to only use that one value. So with the test

#VVT: parameterize: np = 1 2 4 8
...

and the command line value -S np=3, the test will only be run with one value, np=3.

This behavior is different with staged tests. For staged tests, the original number of values will be retained, but their values will all be equal to the value given by -S name=value. For example, with this test

#VVT: parameterize (staged): np = 1 2 4 8
...

and if -S np=3 was given, then vvtest would treat the test as if it was this:

#VVT: parameterize (staged): np = 3 3 3 3
...

Specifying multiple values

But wait - there's more! The -S option supports multiple parameter values, such as

$ vvtest -S "np=3 9"

For a non-staged test, the behavior is as you would expect - the test parameter values are replaced with the multiple values (rather than just the one as before).

For staged tests, the -S values are repeated as needed to retain the original number of values. For example,

#VVT: parameterize (staged): np = 1 2 4 8
...

with -S "np=3 9" would be treated like this:

#VVT: parameterize (staged): np = 3 9 3 9
...

For staged tests, here are example combinations of test file parameters, command line -S specified values, and the way vvtest would treat the parameters.

test file parameters -S values vvtest treatment
1 2 4 8 3 9 3 9 3 9
1 2 4 8 16 3 9 3 9 3 9 3
1 2 3 9 3 9
1 2 4 3 3 3 3
1 2 3 9 27 3 9 27

Of note is that if the number of -S values exceeds the number of test file values, then the total number of values will respect the -S values.

Clone this wiki locally