Unit Testing on ARM

armunit testing

We are developing application level code that runs on an ARM processor. The BSP (low level code) is being delivered by a 3d party so our code sits just on top of this abstraction layer (code is written in c++).

To do unit testing, I assume we will have to mock/stub out the BSP library(essentially abstracting out the HW), but what I'm not sure of is if I write/run the unit test on my pc, do I compile it with for example GCC? Normally we use Realview compiler to compile our code for the ARM. Can I assume that if I compile and run the code with x86 compiler and the unit tests pass that it will also pass when compiled with RealView compiler?

I'm not sure how much difference the compiler makes and if you can trust that if the x86 compiled code pass the unit tests that you can also be confident that the Realview compiled code is ok.

Best Answer

Although compilers contain bugs just like any other piece of software, the chances that you encounter one of those bugs while creating your own software are close to zero and the chance that such a bug manifests itself as misbehaving software is even smaller.

Apart from compiler bugs, you could get different behavior because the two compilers interpret your code differently. As long as you stay away from the murky corners of the language and especially avoid using undefined or unspecified behavior or non-portable assumptions (such as the size of basic types), then all C++ compilers are actually very good at producing consistent behavior when compiling the same code with different compilers.

In general, unless you are doing something very special, if your code compiles with all the relevant compilers then you can be sure that the produced executables also show consistent behavior with each other.

Related Topic