Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test Automation with Embedded Hardware

Tags:

Has anyone had success automating testing directly on embedded hardware?

Specifically, I am thinking of automating a battery of unit tests for hardware layer modules. We need to have greater confidence in our hardware layer code. A lot of our projects use interrupt driven timers, ADCs, serial io, serial SPI devices (flash memory) etc..

Is this even worth the effort?

We typically target:

Processor: 8 or 16 bit microcontrollers (some DSP stuff)
Language: C (sometimes c++).

like image 424
JeffV Avatar asked Sep 22 '08 14:09

JeffV


People also ask

What is embedded test automation?

Embedded Testing is a process to check the functional and non-functional factors in an embedded system. The testing ensures both software and hardware aspects of the system is fully functional and free from defect. Meaning, the product is all set for the final release.

What is hardware test automation?

What is Automated Hardware Testing? Automated hardware testing validates or verifies a product's performance before it leaves the factory, using special automated test hardware and software. The product being tested is generally called the UUT (Unit Under Test), or sometimes DUT (Device Under Test).

What is embedded device testing?

Embedded Testing is a process where functional and non-functional attributes of both software and hardware are checked to make sure that the final product is free of defects. Embedded testing validates if the final product (of embedded hardware and software) fulfills the business requirements.


2 Answers

Sure. In the automotive industry we use $100,000 custom built testers for each new product to verify the hardware and software are operating correctly.

The developers, however, also build a cheaper (sub $1,000) tester that includes a bunch of USB I/O, A/D, PWM in/out, etc and either use scripting on the workstation, or purpose built HIL/SIL test software such as MxVDev.

Hardware in the Loop (HIL) testing is probably what you mean, and it simply involves some USB hardware I/O connected to the I/O of your device, with software on the computer running tests against it.

Whether it's worth it depends.

In the high reliability industry (airplane, automotive, etc) the customer specifies very extensive hardware testing, so you have to have it just to get the bid.

In the consumer industry, with non complex projects it's usually not worth it.

With any project where there's more than a few programmers involved, though, it's really nice to have a nightly regression test run on the hardware - it's hard to correctly simulate the hardware to the degree needed to satisfy yourself that the software testing is enough.

The testing then shows immediately when a problem has entered the build.

Generally you perform both black box and white box testing - you have diagnostic code running on the device that allows you to spy on signals and memory in the hardware (which might just be a debugger, or might be code you wrote that reacts to messages on a bus, for instance). This would be white box testing where you can see what's happening internally (and even cause some things to happen, such as critical memory errors which can't be tested without introducing the error yourself).

We also run a bunch of 'black box' tests where the diagnostic path is ignored and only the I/O is stimulated/read.

For a much cheaper setup, you can get $100 microcontroller boards with USB and/or ethernet (such as the Atmel UC3 family) which you can connect to your device and run basic testing.

It's especially useful for product maintenance - when the project is done, store a few working boards, the tester, and a complete set of software on CD. When you need to make a modification or debug a problem, it's easy to set it all back up and work on it with some knowledge (after testing) that the major functionality was not affected by your changes.

-Adam

like image 112
Adam Davis Avatar answered Sep 24 '22 05:09

Adam Davis


Yes. I have had success, but it is not a stragiht-forward problem to solve. In a nutshell here is what my team did:

  1. Defined a variety of unit tests using a home-built C unit-testing framework. Basically, just a lot of macros, most of which were named TEST_EQUAL, TEST_BITSET, TEST_BITVLR, etc.

  2. Wrote a boot code generator that took these compiled tests and orchestrated them into an execution environment. It's just a small driver that executes our normal startup routine - but instead of going into the control loop, it executes a test suite. When done, it stores the last suite to run in flash memory, then it resets the CPU. It will then run then next suite. This is to provide isolation incase a suite dies. (However, you may want to disable this to make sure your modules cooperate. But that's an integration test, not a unit test.)

  3. Individual tests would log their output using the serial port. This was OK for our design because the serial port was free. You will have to find a way to store your results if all your IO is consumed.

It worked! And it was great to have. Using our custom datalogger, you could hit the "Test" button, and a couple minutes later, you would have all the results. I highly recommend it.

Updated to clarify how the test driver works.

like image 44
Frank Krueger Avatar answered Sep 21 '22 05:09

Frank Krueger