kyua icon indicating copy to clipboard operation
kyua copied to clipboard

Clean up environment variables when running test cases

Open jmmv opened this issue 11 years ago • 1 comments

From [email protected] on November 27, 2010 12:34:45

The Kyua runtime engine currently cleans up a particular subset of environment variables (HOME and those locale-related) when executing a test case but does not touch those variables it does not know about. This may make test cases expose different behaviors depending on the machine/system they are executed in. For example, the atf-c and atf-c++ test cases that check for the pkg-config files rely on the PKG_CONFIG_PATH environment variable to be appropriately set beforehand by the user. This is suboptimal because such tests will cause failures when the environment is not properly set. (Similarly, we can imagine tests which yield different results if, e.g. TZ has different values.)

Ideally, we should go the other way around: clear all environment variables and only define a good known subset. The very minimum includes HOME and PATH. This is tricky though because, depending on the system, the default values for PATH may be very different. We should also investigate if it is worth to let end users and/or specific tests allow some variables to be passed through. (E.g. how to deal with the PKG_CONFIG_PATH example from above?)

Original issue: http://code.google.com/p/kyua/issues/detail?id=1

jmmv avatar Feb 22 '14 21:02 jmmv

From yanegomi on February 06, 2011 21:03:19

Hi Julio!

I was looking at the isolate_process function and I was thinking, why not just filter through $HOME, $TERM, $USER and set $PATH to a sane value in the sample and let the distribution folks customize the path to meet their requirements, i.e. for Linux /bin:/usr/bin:, etc, for BSD /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin , etc? There's no one right answer because every system varies and the folks that can best define what the requirements are are the package maintainers for the system. Also, one should be able to capture these from the environ array like so (warning: this is a toy example):

$ ~/test_environ SSH_AGENT_PID => 2772 GLADE_PIXMAP_PATH => : TERM => xterm SHELL => /usr/local/bin/bash WINDOWID => 48991704 USER => gcooper GLADE_MODULE_PATH => : ENV => /usr/home/gcooper/.shrc SSH_AUTH_SOCK => /tmp/ssh-qHA03bA3RO/agent.2771 SESSION_MANAGER => local/bayonetta.local:/tmp/.ICE-unix/2780 PAGER => more FTP_PASSIVE_MODE => YES MAIL => /var/mail/gcooper PATH => /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/home/gcooper/bin:/usr/home/gcooper/bin BLOCKSIZE => K PWD => /usr/home/gcooper EDITOR => /usr/local/bin/vim SHLVL => 2 HOME => /usr/home/gcooper GTK_PATH => :/usr/local/lib/gtk-2.0 LOGNAME => gcooper XDG_DATA_DIRS => /usr/share:/usr/local/share DBUS_SESSION_BUS_ADDRESS => unix:path=/var/tmp/dbus-Tmu9Ifs7EO,guid=b837076b13d3a1bae2785bae0000005d WINDOWPATH => 9 DISPLAY => :0.0 GLADE_CATALOG_PATH => : LIBGLADE_MODULE_PATH => :/usr/local/lib/libglade/2.0 COLORTERM => Terminal

You probably already knew this, but I thought I'd just bring it up... :/.

Attachment: test_environ.c

jmmv avatar Feb 22 '14 21:02 jmmv