在命令行提示符下,是否可以将参数传递给 hwut 命令,例如,为了使用该参数作为标识符来打开特定的串行端口?
I guess, the easiest way is to use environment variables. Let's say your test is written in "C", then do
set MY_VARIABLE=4711 # DOS
export MY_VARIABLE=4711 # Unix & Co
hwut my-test.exe
where the file "my-test.c" is the source of "my-test.exe" and contains
#include <stdlib.h>
...
int main(int argc, char** argv)
{
...
const char* MyVariable_str = getenv("MY_VARIABLE");
int my_variable;
my_variable = MyVariable_str ? atoi(MyVariable_str) : -1;
...
}
The propper solution, of course, is to have some configuration file which is configured globally and parsed by the test applications. The overhead for that, however, might not always be justified.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.