是否有推荐的方法来设置 CUnit 测试的环境变量?
我们想要使用 CUnit 来测试我们开发的共享库。
共享库通过标准 Solaris LD_PRELOAD 机制加载,其中它使用环境变量将包含文件路径的字符串重新映射到基于文件路径的新日期和时间。
初始测试将使用环境变量的单个值来控制文件路径的重新映射。
是否有建议的方法(也许是配方?)将我们的环境变量传递到 CUnit 环境中?
我正在考虑在可选的测试套件设置功能中设置测试值。
编辑:按照@eaanon01的要求提供更多详细信息。 (-:
我们的 shlib 实现了一个函数,该函数采用目录路径,例如,
/home/www/my_tld
然后使用 Unix 纪元时间戳,将其转换为我们存档中的目录路径,例如
/home/www/my_tld/1088589843
20040630 10:04:03 GMT 的该 tld 的内容 由于我们无法控制被拦截的系统调用的参数,因此
我们必须使用环境变量来传递所需的时间戳,在本例中为值 1088589843。
我们希望对我们正在拦截的所有 Unix 系统调用进行单元测试。 shlib,我们想使用 CUnit 框架进行单元测试,并通过环境变量传递固定的时间戳值,
是否有推荐的方法为每个单元测试设置环境变量?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在“init suite”功能和“clean suite”功能中初始化设置和删除。不确定我能否完全理解这个问题,请详细说明。
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.