ATF-devel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: set variables at runtime with atf-run

On Fri, Apr 30, 2010 at 10:05 PM, Stathis Kamperis 
<> wrote:
> Hi all,
> is it possible to declare a variable inside an atf test program,
> assign it a default value and be able to change it during runtime ?

Yes, it is.  You can use the atf_tc_{has,get}_config_var functions for
this purpose.  See the atf-c/tc.h header file.

If you want the variables to always be external (i.e. provided by the
user as there is no reasonable default value), you can also set the
"require.config" property in the metadata to list such variables.  See
atf-test-case(4).  By defining this, the test case will automatically
be skipped unless proper values are provided.

> And then invoke it like this:
> atf-run -v iterations=2000, fuzzing=1

Yup; just with a slightly different syntax:

atf-run -v iterations=2000 -v fuzzing=1

These variables can either be set on the command line, on the
test-suite configuration file (e.g. /etc/atf/NetBSD.conf) or on the
Atffile.  They take precedence in this order.  I'd suggest looking at
the t_atf_run test program; it's a bit convoluted but will show you
the expected semantics (blame me for lack of proper documentation...)

> If what I'm describing isn't feasible, what else would you recommend?
> Just use some #define and settle with compile-time ?

Please avoid defines/ifdefs if at all possible!  Keep in mind that the
test programs get installed under /usr/tests, so their execution
should be flexible for those without the source code.

Julio Merino

Home | Main Index | Thread Index | Old Index