views:

88

answers:

1

We want to use CUnit to test a shared library that we have developed.

The shared library is loaded via the standard Solaris LD_PRELOAD mechanism where it uses an environment variable to remap a string containing a file path to a new date and time based on the file path.

Initial testing will use a single value for the environment variable being used to control this remap of the file paths.

Is there a suggested way, a recipe maybe?, to pass our environment variable into the CUnit environment?

I'm thinking of setting the test value in the optional test suite setup function.

Edit: A bit more detail as requested by @eaanon01 below. (-:

Our shlib implements a function that takes a directory path, for example

/home/www/my_tld

and then using a Unix epoch timestamp, converts that to a directory path within our archive, for example

/home/www/my_tld/1088589843

for the contents of that tld at 20040630 10:04:03 GMT.

As we have no control over the parameters of the syscalls being intercepted, we must use an environment variable to pass in the required timestamp, in this example a value of 1088589843.

We want unit tests for all the Unix syscalls we are intercepting with this shlib and we want to use the CUnit framework for the unit tests and have a fixed value of the time stamp which is passed in via the environment variable.

Is there a recommended way of setting the environmental variable for each unit test?

+1  A: 

You have the posibility to to init setups and removal in an "init suite" function and an "clean suite" function. Not sure I can fully grasp the question, please elaborate more.

eaanon01
@eaanon01, added as requested. Hopefully, a bit clearer now. (-:
Rob Wells