Forums

External code coverage

Started by jyang72211 3 months ago4 replieslatest reply 3 months ago73 views

With black-box test cases running on an embedded target, is there a way to determine what lines of code are executed without compiling the embedded code with a special IDE and method?  I am looking at something external to the embedded target that can provide this coverage information while test cases are running.  Thank you!  

[ - ]
Reply by lmitchamApril 29, 2021

In the past, I have inserted serial messages at different points in the code, if there is an RS-232 interface to a computer.  If there is a display device on the embedded project, I have put numbers up on the display at strategic places in the code to indicate paths or progress.  The most basic method if there are no serial interfaces or displays is to use extra I/O pins and using an o-scope to monitor the I/O, I insert code to manipulate the I/O at the points of interest in the code.


Good luck.

[ - ]
Reply by CustomSargeApril 28, 2021

Howdy, back ~3 decades, hardware state analyzers were common. They "camped" on data and address lines, unbeknownst to the UUT and allowed full state tracing. They still make such objects, just Much cheaper and easier to run. Do some homework and get one.

I just built one specific to a machine with 68 I/O, ran 976 samples/sec for ~5 minutes to nail down a state machine sequence. Acquiring the data is trivial next to making it understandable. HINT: Get Real Good with spreadsheets... G.H. <<<)))

[ - ]
Reply by MichaelKellettApril 29, 2021

Some ARM micros have the embedded trace hardware and used with hardware tools from Keil, Segger or Lauterbach you should be able to do this.

I've used the Keil tools with very little success - the Ulink Pro frequently can't make/sustain contact. It does require you to use the Keil compiler.

I think Segger and Lauterbach hardware will work with a wider range of software tools.

Rapita in York specilaise in this sort of tracing. 

https://www.rapitasystems.com/products/rapicoverze...

Whatever tools you use there will be changes to process to get comprehensive code coverage analysis and it won't be cheap.


MK


[ - ]
Reply by jimbrosApril 29, 2021

The I/O pins method has the additional advantage of verifying execution period and duration of a given function or sequence of code.

Another method is reserve a small array of unsigned ints. (e.g. uint32_t A[8]). Create a "tracepoint" macro which increments a specific array element. (e.g. TRACEPOINT(2)). Inserting the macros in paths of interest.

At the end of the run, dump or print the array. This provides a count of the number of times execution through a given section of code.

The macro should be written such that it can be conditionally compiled off and collapse to an empty C statement.