views:

144

answers:

3

My new project is targeting an embedded ARM processor. I have a build system that uses a cross-compiler running on an Ubuntu linux box. I like to use unit testing as much as possible, but I'm a little bit confused about how to proceed with this setup.

I can't see how to run unit tests on the ARM device itself (somebody correct me if I'm wrong). I think that my best option is to compile the code on the build machine using its own native compiler for the unit tests. Is this approach fundamentally flawed? Is unit testing on a different platform a waste of time?

I'm planning to use CppUnit on the build machine using the native compiler for the unit tests. Then I'll cross compile the code for the ARM processor and do integration and system testing on the target device itself. How would you structure the source code and the test code to keep this from turning into a tangled mess?

+3  A: 

With embedded device it depends on what interfaces (hardware) you have.

For example the motion control cards I deal with uses a command line interface. The IDE they ship uses it as it primary method of interacting with the cards. It works the same way regardless if I am using PCI, IDE, Serial, or Ethernet.

The DLL they ship for programming give access to the command line interface. So I can send a string, and read back the response. So what I do for my unit tests is have a physical card hooked (or in) my development machine. I send it commands after uploading the software, read the response and if they are correct it passes the test.

I also have extra hardware, a black box if you will, that simulates a machine that motion control card is normally hooked up too. It helps with the automated sets but there is a manual phase as I have to set switches to simulate different setups on the machine.

I have achieved a greater degree of automation by taking a digital I/O card and using it outputs to feed into the inputs of the motion control card and the same in reverse.

I found that for most hardware you have to have some type of simulator hardware.

The exception being the rare package that comes with a software simulator.

I know this isn't probably ideal as not every developer can have one of these on their desk. My hardware simulator so I can give it to whoever it working on the motion control software at the time. If it can't be portable then having a dedicated testing or hardware development computer would be in order.

Finally it boils down on the specifics of your hardware and what support the manufacturer gives in terms of software and simulators. To help you more you will need to post more specifics.

RS Conley
All of the hardware communications I'm going to do are over serial ports, so I'll be able to do that directly on the build machine. Unfortunately, I don't have an emulator for the ARM device.
Bill the Lizard
Serial is good if have the ability to send and receive commands. For example set outputs and read input independently of the software/firmware you have running on the Arm. Also read memory location, registers as well. If you have that you should be able to rig up some hardware to do manual tests.
RS Conley
If you are able to rig up hardware then you could write a wizard telling the tester what to setup for each test. It is not ideal but when you deal with hardware it is sometimes the only thing that you can do.Also make sure there isn't some ARM emulator out there as you are running Linux.
RS Conley
+1  A: 

What are the limits on running the test code on the target?

  • Memory?
  • Time?
  • Hassle?

Can you use an emulator, and run the test suite on that---accepting the additional risk from emulation bugs?

dmckee
Hassle and time. I don't have an emulator for the target device. :(
Bill the Lizard
Ouch. Not much help then.
dmckee
+2  A: 

In ten-plus years in the embedded industry, I've seen it done quite a few ways. At my current company:

  • one of our products has enough horsepower (and space) to run tests on the target board. It's somewhat slow, and we can't stick all the python on the box we'd like, but it works well.
  • one of our products doesn't have the space, so we compile all the libs we can in x86 (anything that isn't hardware-dependent) and run unit tests on desktops. It's not perfect, but far better than nothing.
  • one of our components is a super-lightweight power-miser on exotic hardware, so virtually no unit tests are possible. Core algorithms (DES, etc.) are tested on x86 as above, but much of the code simply has to be tested as a whole, in situ. This entails lot of code reviews.
introp