How to use unit test framework for embedded systems?

I'm a little acquainted with how you would use a unit test framework when the code you're testing runs natively on your host. So how do you use a unit test framework when the code is intended to run on a target system?

For example, the Cxxtest framework is a perl script that parses your code base, looking for any function that begins with "test" to add to the test suite, and it creates an executable that will run those tests. I haven't used it myself, though I'm told you typically tie it in to your build system so whenever you build you get your normal executable plus your tests are build and executed. If the tests fail, the build fails, and it reports stats and points you to where the failures happened.

So when you use a unit test framework for embedded software, what changes? Do you build with your cross-compiler, get an executable with the tests, download them to your target, and run them? Or do you build them natively on your host and run them there? Or some of each?

Thanks,

- J

Reply to
jasper77
Loading thread data ...

Some of each . We typically run tests first in our host environment (where possible) to iron out most of the procedural type problems in an easy debugging environment. We then repeat the tests actually on the target hardware. The test is not marked as PASSED until it has been successfully executed with the correct compiler, on the correct hardware, with the correct timing, etc., so the first step is purely for our convenience.

By their nature embedded systems have a lot of interactions with the hardware, and therefore many tests can only be executed on the target anyway.

--
Regards,
Richard.

+ http://www.FreeRTOS.org & http://www.FreeRTOS.org/shop
17 official architecture ports, more than 5000 downloads per month.

+ http://www.SafeRTOS.com
Certified by TÜV as meeting the requirements for safety related systems.
Reply to
FreeRTOS.org

Thanks, Richard.

Can you tell me/us which unit testing framework you use, what you think of it, and why it was chosen?

Thanks,

- J

Reply to
jasper77

Another possibility is automatically running them on a simulator, if it's available and considered accurate enough.

Reply to
cs_posting

Expand on 'framework'. What are you wanting it to do?

We use a single small C function that runs through a table of function pointers (points to the individual tests) and collects the results. I would not call it a framework.

Regards, Richard.

  • formatting link
    &
    formatting link
17 official architecture ports, more than 5000 downloads per month.

  • formatting link
    Certified by TÜV as meeting the requirements for safety related systems.

Reply to
FreeRTOS.org

As for what I'm wanting it to do, this article is a good one to go on:

formatting link

I'm considering using UnitTest++

formatting link
formatting link

- J

Reply to
jasper77

I briefly glanced through the article. Perhaps you will find thi framework useful. Its not for C++ and not on native though

formatting link

Br, Martin

Reply to
martinsteen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.