Passing environment variables to test programs

15 views
Skip to first unread message

Johnny Lam

unread,
Apr 25, 2017, 12:18:06 PM4/25/17
to kyua-discuss
Is there a way to pass environment variables to the test programs invoked by kyua?  I have a directory of test programs that use an environment variable to point to a directory where it can find its files.  I use the environment variable so that the test programs can locate its files whether they are in the build directory or in the final installed destination.  If I setup the environment before invoking "kyua test", then things work fine, but I'd like to be able to setup the installed Kyuafile to set the environment variable used by the tests.

Thanks,

Johnny C. Lam

Alan Somers

unread,
Apr 25, 2017, 12:26:33 PM4/25/17
to kyua-d...@googlegroups.com
It sounds like you want to use a Kyua configuration variable. You can
define them in /usr/local/etc/kyua/kyua.conf like this:

test_suites.FreeBSD.disks="/dev/da0 /dev/da1 /dev/da2 /dev/da3
/dev/da4 /dev/da5"

Though you should replace FreeBSD with the name of your own test
suite. In an atf-sh program, you can get the value by doing

atf_config_get disks

In an atf-c program, there are a few functions to get the value named
"atf-tc-get_config_var*". See atf-c-api(3) for details.

-Alan
> --
> You received this message because you are subscribed to the Google Groups
> "kyua-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kyua-discuss...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Julio Merino

unread,
Apr 25, 2017, 1:48:40 PM4/25/17
to kyua-d...@googlegroups.com
On Tue, Apr 25, 2017 at 12:26 PM, Alan Somers <aso...@freebsd.org> wrote:
> It sounds like you want to use a Kyua configuration variable.

Well... configuration variables are intended for user-facing tunables,
and in this case, it seems Johnny wants a way to tune the tests so
that they can run in two different scenarios: one before installation
and one after installation. This is not something the end user should
be messing around with.

Kyua's own test suite does this so "make check" tests Kyua before
anything is installed (or bypasses any installed files), and "make
installcheck" tests the installed product. The way this works is: the
Kyua code and the self-tests carry the final paths to the installed
files. However, they support "undocumented" internal environment
variables to override the builtin final paths with the temporary paths
to the uninstalled build products. "make check" then just sets those
variables before running "kyua test", which works fine. See
CHECK_ENVIRONMENT in Kyua's own Makefile.am.

--
Julio Merino -- http://julio.meroh.net/
Reply all
Reply to author
Forward
0 new messages