Author Topic: Unit testing C embedded code - systems and frameworks  (Read 12335 times)

0 Members and 1 Guest are viewing this topic.

Offline bson

  • Supporter
  • ****
  • Posts: 2756
  • Country: us
Re: Unit testing C embedded code - systems and frameworks
« Reply #25 on: November 18, 2021, 11:09:00 pm »
I create test programs that each contain a set of unit tests.  It gets flashed and run, and watched by a scripted GDB session which collects results and outputs a report. The harness that runs the tests is a simple python program that generates GDB scripts and runs them via openocd, then tallies up the reports for progress/pass-fail/etc.  All output is captured (openocd, GDB, SWO, and serial port) to help narrow down failures.

Also, and this is not limited to embedded/firmware, but also large software systems I've worked on: massive GDB invariant scans that can walk memory and check EVERYTHING.  Every heap allocation, pointer, data, values -- all state.  Since it's GDB and Unix it can also operate against a core dump, making it exceedingly handy in that it can tell you up front what state is corrupt so provides extremely useful clues on a segfault or bus error, or even hamfisted kills of stuck processes.  (Most likely deadlocked or they closed their listen port or something.)  At one place we had a hard rule: you're not done until you have a unit test, documentation, reviewed code, AND a GDB TCL script to invariant check your state (or updates to existing checkers) against a live system or core dump.
« Last Edit: November 18, 2021, 11:14:33 pm by bson »
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 5090
  • Country: gb
Re: Unit testing C embedded code - systems and frameworks
« Reply #26 on: November 19, 2021, 11:21:02 am »
I create test programs that each contain a set of unit tests.

any public example?
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1233
  • Country: fr
Re: Unit testing C embedded code - systems and frameworks
« Reply #27 on: November 19, 2021, 03:40:13 pm »
Thank you all for all additional discussion and contributions! :)

I create test programs that each contain a set of unit tests.

any public example?

Yes, that would be nice to see, to get an idea of how others with more experience, do it. :)

Thank you
« Last Edit: November 19, 2021, 03:42:51 pm by ricko_uk »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf