在嵌入式设备中使用检查测试单元框架?
有没有人在嵌入式设备中使用 check 作为单元测试框架,这也需要交叉编译?
这是一个好主意,还是我应该使用其他东西(例如 embunit 或类似的)?
如果是的话,我应该如何编写Makefile.ams和configure.ac?我一开始就没有使用过自动工具,所以所有这些交叉编译的东西肯定没有帮助...
我可以简单地跳过所有实际的配置检查,因为我只在一个或两个环境中编译,但是我需要编译检查目标?我无法从说明中弄清楚如何将实际框架链接到我的测试代码。
我需要的最少文件是什么?这些示例完成了所有配置工作,我不知道可以省略什么。
Has anyone used check as the unit test framework in an embedded device which also requires cross-compilation?
Is it even a good idea, or should I just use something else (e.g. embunit or similar)?
If so, how should I write the Makefile.ams and configure.ac? I haven't used autotools to begin with so all this cross-compilation stuff certainly doesn't help...
I could simply skip all the actual configuration checking since I only compile in one or two environments but do I need to compile check to the target? I can't figure from the instructions how to link the actual framework to my test code.
What would be the minimal files that I need? The examples do all the configuration stuff and I can't figure out what I can leave out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,“检查”使用 fork() 系统调用。当您的嵌入式目标上没有使用基于 UNIX 的操作系统时,您将在这里遇到问题。在第 2.1 章的检查手册页上,您会发现替代单元的详细概述测试框架。大多数框架依赖于某些操作系统调用或某些标准库函数,这些函数可能不存在于您的嵌入式目标上。
我发现宏表达式单元测试框架 MAESTRA 在嵌入式平台上非常有用。几年前,embedded.com 上有一篇有趣的文章: 在小范围内进行 C 代码单元测试。
但是,如果您正在处理大量第三方代码或现有代码库,MAESTRA 可能不是最佳选择,因为它强制执行特殊的编码标准以使代码插装能够正常工作。这也可能与您公司自己的编码标准相冲突。
As far as I can see "check" uses the fork() system call. When you are not using a UNIX-based operating system on your embedded target you shall encounter problems here. On the check manual page in Chapter 2.1 you will find a nice overview of alternative unit testing frameworks. Most frameworks rely on either some operating system calls or some standard library functions which may not be present on your embedded target.
I found macroexpressions unit testing framework MAESTRA very useful on embedded platforms. There was an interesting article on embedded.com some years ago: Doing C code unit testing on a shoestring.
But if you are dealing with lot of third-party code or an existing code base MAESTRA might not be the best choice, for it enforces a special coding standard for code instrumentation to work. This might as well collide with your companies own coding standard.