Want to see Parasoft in action? Sign up for our Monthly Demos! See Demos & Events >>
Software testing is an integral part of software development. Every industry that develops and executes code can benefit from using structural code coverage testing tools. These tools are especially useful in industries for embedded development of safety-critical applications where software systems cannot fail — or lives will be lost. Parasoft C/C++test 2020.2 comes with a coverage advisor to help users create that elusive test case that is difficult and time consuming to form.
Obtaining 100% code coverage metrics in embedded safety- and security-critical systems serves multiple purposes. The primary purpose is to conform to verification and validation (V&V) requirements defined in process standards like DO-178C, IEC 62304, and others.
The value that code coverage provides is an add-on V&V activity that flushes out defects in the code. It makes sure that every line of code has been executed and hence examined through testing. This gives you an additional safety net on code quality and reliability.
Also, if you execute all your test cases and only obtain 60%, it becomes obvious that you haven’t created enough test cases. As a result, hidden defects might lurk in these untouched areas.
Another concern is “dead code”. That means code that would never be executed because no pathway to it exists. This can happen when a feature/capability is implemented but at some point, the requirement for the feature is removed. If you don’t completely remove the code, it can result in dead code. Finding dead code within functions or operations can also highlight bad code logic that you must address. In this situation, the dead code indicates no reachable, logical path exists.
You can achieve code coverage through various methods of testing or a combination of:
I’ve participated in the following two approaches, which Parasoft easily supports:
There are various coverage metrics to consider. Knowing which specific type to apply depends on the software integrity level (SIL) as defined in IEC 61508. Another example is Design Assurance Level (DAL) for DO-178B/C. For embedded systems, the control metrics referenced are statements, branch, modified condition decision coverage (MC/DC) and for the strictest requirements, there is Object/Assembly code. Parasoft supports gathering all these coverage metrics, including terms other industries use like block, call, function, path, decision, and more.
Parasoft C/C++test has made huge productivity impacts in automating the process of obtaining code coverage. The first is in automated test case generation. With one click and a menu selection, the testing solution analyzes the code and automatically generates smart unit test cases. These unit test cases can then be executed. Depending on code size and complexity, teams can instantly achieve up to 90%.
For complex code, there are always those elusive code statements of which it’s exceedingly difficult to obtain coverage. It’s likely there are multiple input values with various permutations and possible paths that make it mind-twisting and time-consuming to decipher. But only one combination can get you the coverage you need. Parasoft C/C++test 2020.2 has enhanced its coverage advisor, making it easier to obtain coverage of those difficult to reach lines of code.
Within your editor, right-click on the line of code that you want coverage for and select Parasoft -> Show in Coverage Advisor.
Figure 3 below shows an analysis report providing the user with a solution. The Pre-conditions field express:
Upon creating the unit test case with these set parameter values and stubs for external calls, the user will obtain coverage of the line selected, plus the additional lines expressed in the Expected Coverage field.
Performing structural code coverage is necessary when building embedded safety- and security-critical software systems. Together with requirements test coverage, it ensures that:
Parasoft C/C++test is a unified testing solution that provides teams with testing method capabilities and automated productivity features like Coverage Advisor. Using this feature, developers can reach their code coverage goals quickly. Accordingly, software directors and managers can achieve business goals for time-to-market, labor cost reduction, audit safeguards, and ease in product certification.
Sr. Technical Product Marketing Manager for Parasoft’s embedded testing solutions. He has expertise in the SDLC and test automation of embedded real-time, safety- and security-critical applications, and software compliance to industry standards.