ATF-devel archive

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

Re: config vars from shell scripts?



On Thu, Mar 3, 2011 at 5:11 PM, Jeff Rizzo <riz%tastylime.net@localhost> wrote:
> What's the correct way to use a config var from within a shell script test?
>
> I tried:
>
> $(atf_get testvar)
>
> which I set with:
>
> atf-run -v testvar=foo
>
> ... but I only got an empty string.  What am I doing wrong?

You should be using atf_config_get.

I see that the manual page mentions atf_get but it does not describe
what it does.  I am not even sure if this function should be exposed
at all.  (atf_get is the counterpart of atf_set, which just returns
the value of a metadata property.)

> Does this mean that if I use a variable AT ALL, I have to make sure it's set
> in every instance?  That seems... suboptimal.  Perhaps I'm misunderstanding.

This comment is not applicable to atf_config_get, but to prevent
confusion I'll clarify:

Keep in mind that running test programs by hand is "not supported".
The way to run test cases is by means of atf-run.  If you want to
define a consistent value for a variable across test cases, you can do
so by sticking such value in the Atffile (see the prop: keyword).  The
end user can always override such value by defining an override in
/etc/atf/<testsuite>.conf

-- 
Julio Merino / @jmmv


Home | Main Index | Thread Index | Old Index