简体   繁体   English

HWUT:命令行参数

[英]HWUT: parameters on command line

在命令行提示符下,是否可以将参数传递给 hwut 命令,例如,为了使用该参数作为标识符来打开特定的串行端口?

I guess, the easiest way is to use environment variables.我想,最简单的方法是使用环境变量。 Let's say your test is written in "C", then do假设您的测试是用“C”编写的,然后执行

   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其中文件“my-test.c”是“my-test.exe”的来源并包含

   #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.然而,为此的开销可能并不总是合理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM