简体   繁体   English

嵌入式系统的单元测试

[英]Unit testing for embedded system

I am having a product which runs on Vxworks on end product hardware. 我有一个在最终产品硬件上的Vxworks上运行的产品。 But development is done in Visual studio using cross compiler and downloaded to hardware for testing. 但是开发是在Visual Studio中使用交叉编译器完成的,并下载到硬件进行测试。 I am planning to write unit test cases for product. 我打算编写产品的单元测试用例。 My question is because my development is done on windows and how can I run unit test cases as it is not resemebling real scenario? 我的问题是,因为我的开发是在Windows上完成的,并且由于它没有重新划分真实的场景,我该如何运行单元测试用例?

Any inputs are welcome 欢迎任何输入

I suspect that you have code that interacts a lot with VxWorks through system calls. 我怀疑您有通过系统调用与VxWorks进行了大量交互的代码。 Putting a layer of abstraction in there will be hard. 在其中放置抽象层将很困难。

Are you using c or c++? 您正在使用c还是c ++?

If you are using c++ and you can identify parts of the system that: 如果您使用的是c ++,则可以确定系统的以下部分:

  • are subject to frequent change; 经常更改; and
    • are mostly handling internal data; 主要处理内部数据; or 要么
    • just relating to a predefined/formalized subset of the surrounding system (eg protocol handling or individual PLC control logic modules). 仅与周围系统的预定义/形式化子集有关(例如协议处理或单个PLC控制逻辑模块)。

Then you should first inject c++ interface(s) between the module and the rest of the system. 然后,您应该首先在模块和系统的其余部分之间注入c ++接口。 This module should only relate to the interface(s)/adapter(s). 该模块应仅与接口/适配器有关。 Then you have an isolated piece that can be strapped into a visual studio test harness. 然后,您可以得到一个隔离的部件,可以将其绑扎到Visual Studio测试工具中。

Then you should try to identify areas in your system that are error prone to bugs, subject to (frequent) change or audit. 然后,您应该尝试确定系统中容易发生错误且容易(频繁)更改或审核的区域。 You will probably never achieve even 50% coverage on the target system, but you can achieve a system where 90% of the daily coding happens within the covered 40% of the code base. 您可能永远都无法在目标系统上实现50%的覆盖,但是您可以实现一个系统,其中90%的日常编码发生在40%的代码库内。

Not possible without additional effort ( new project; compile twice; for your host and let it run on your host ) In this case search for an development environment that support your target for unit tests, for example http://www.parasoft.com/jsp/products/embedded_cpptest.jsp 没有额外的努力就不可能( 新项目;两次编译;对于您的主机,然后让它在您的主机上运行 )在这种情况下,搜索支持单元测试目标的开发环境,例如http://www.parasoft.com /jsp/products/embedded_cpptest.jsp

Go on reading at parasoft C++ unit test question . 继续阅读parasoft C ++单元测试问题

You do it just like any other system: 您可以像其他任何系统一样进行操作:

  • Write the unit tests 编写单元测试
  • compile and load into target system 编译并加载到目标系统中
  • run unit tests 运行单元测试
  • verify results 验证结果

Where it runs is immaterial. 它运行的位置无关紧要。 The biggest difficulty is on an embedded system with limited output capability. 最大的困难是在输出能力有限的嵌入式系统上。 But even if there is only a single LED, it should still be possible to signal success and failure. 但是,即使只有一个LED,也应该可以发出成功和失败的信号。 Only it is a little more abstract than showing "passed". 只是它比显示“ passed”更抽象。

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

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