Many embedded systems must be developed to an internationally recognized security standard. Part of the data required to prove that a test procedure meets these standards is achieving a certain level of code coverage. Lauterbach's Code Coverage Challenge is a fun way to learn about code coverage.
Measuring code coverage is a requirement for certification to evaluate the completeness of test cases and to demonstrate that there is no unintended functionality. The execution of linear code is easy to understand, but loops, conditions, decisions, and function calls represent branches where execution jumps to another part of the code, and it becomes more difficult to understand what part of the code has already been executed and if all possible branches have been tested at least once. Code coverage checks the percentage of code executed during a given test run.
Of course, one might ask why code coverage measurements are needed: Since dead code is not executed anyway, why avoid it at all? The answer is simple: code that is not executed during testing is not tested. As a result, there may be untested cases in branches, which can lead to unforeseen problems.
Another problem is when the program gets stuck in an unwanted infinite loop that was not called during a test run. These unanticipated scenarios reduce test quality because they no longer guarantee controlled execution of the application. Historically, code coverage is a best practice that has become a mandatory part of safety-related projects and is required by several safety standards such as ISO 26262 (automotive), DO-178 C (avionics), IEC 62304 (medical), and IEC 61508 (industrial).
The original Snake game is the most famous and popular single-player skill game of all time. The first version of these games was released as an arcade game in 1976. The premise of Snake games is simple: you control a snake and must eat food to grow. However, you must not hit walls or your own body, otherwise the game is over. In the case of the Lauterbach Code Coverage Challenge, however, the snake is not fed with fruit, but with bugs, acting as a kind of debugger.
During the game, which was reprogrammed by Lauterbach, the current code coverage of the individual functions is constantly measured and cumulated to an overall value in percent. The player with the highest code coverage at the end of each day will receive a surprise prize – but no player will go home empty-handed.
Real-time measurement of code coverage is limited or impossible in integration and system tests with conventional test tools due to the need for source code instrumentation, which results in larger code size, more RAM consumption, and a longer execution time due to the code overhead. In contrast, trace-based code coverage measurements with Lauterbach's »TRACE32« tools allow even complex coverage criteria to be measured non-invasively. In addition, when playing Snake, coverage data must be determined on the fly, a form of coverage data analysis that is only possible with Lauterbach's unique trace-based technology and can bring benefits to most other embedded applications besides Snake.
The biggest advantage of this approach, however, is that code coverage measurements can also be performed efficiently for real-time applications in all test phases. This means that much of the code coverage measurement can be shifted from unit testing to integration and system testing, taking the pressure off unit testing. The end result is fewer test cases, less test effort, and less overall effort.
If code coverage is of particular interest, Lauterbach's experts are happy to discuss your specific needs - but first, play Snake and have fun!