VxWorks is an embedded operating system provided by Wind River and is widely used for building safety systems. The development environment is based on Eclipse and uses a GCC compiler.
This article will present how to integrate Squish Coco with VxWorks. It is based on a video embedded into this article that shows a step-by-step approach to the integration. This article is meant as a supplement to the video. The information shown here and in the video can also be used as an example for enabling the support of Squish Coco for any Eclipse-based system.
We will proceed with the following steps:
- Enable the general support of the CoverageScanner.
- Generate the user application with code coverage activated.
- Collect and analyze the test metrics.
Installing Squish Coco in Eclipse
To build with code coverage support, it is necessary to use the CoverageScanner compiler wrapper instead of GCC. With this, it is possible to continue to build the product, and the build produces a binary that works as before, but the GCC compiler is extended to support new switches starting with the prefix –cs-, which configure code coverage.
The Wind River support generates the corresponding wrapper for VxWorks on Linux automatically. The wrapper is located in the Coco install directory as the ‘bin‘ folder containing the GNU compiler, and its name is ‘squishcoco‘. So it is just necessary to replace ‘bin‘ with ‘squishcoco‘ at the end of the C++ compiler, C compiler, linker and library tool chain paths.
We continue as follows in the Wind River Workbench:
- Select your project in the « Project Explorer » window, and click on the entry « Properties » in the context menu.
- Select the build properties, the compiler tool chain, and click on the « Variables » tab.
- Search for the
TOOL_PATHvariable, and replace the
/binstring at the end with
Building with Code Coverage Enabled
Once the Squish Coco wrappers are installed into Eclipse, it is only necessary to add –cs-on to the linker and compiler to activate them. The best practice is to create a dedicated build mode. This allows you to switch between the debug, release and instrumented modes without a complete rebuild of the project. Other arguments can also be added like –cs-mcc to enable the Multiple Decision Coverage, the highest code coverage metric.
More concretely, proceed as follows:
- Select your project in the « Project Explorer » window, and click on « Properties » of the context menu.
- Select the build properties, the compiler tool chain, and click on the « Tools » tab.
- Select the entry « C-Compiler » in the « Build Tool » combo box and add to the content of the « Tool Flags… » field the argument –cs-on.
After this, it is necessary to rebuild the project, and a file with an extension .csmes is generated in the build directory. This file contains a copy of the whole target source code and the instrumentation’s locations. In the case where this directory cannot be found, a simple
find command permits us to identify it:
$ find workspace/ -name "*.vxe.csmes" -ls
This file can then be inspected with the CoverageBrowser:
$ ~/SquishCoco/bin/coveragebrowser <path to .vxe.csmes file>
The code can then be inspected, but because nothing has been executed, coverage information is unavailable.
Executing and Testing the Instrumented Application
On a real target, it is necessary to transfer the binaries to the target. The .csmes file should be left on the host and on every computer used for analyzing the results. After executing the application normally, a .csexe file is generated on the target’s file system. This needs to be transferred back to the host to import it and to process it. Starting the tests manually and retrieving the results manually is not very convenient. If the last operation is possible through a script (e.g., using SSH or FTP), it is possible to integrate this script in the CoverageBrowser and use a simple button to do the operation. The article Manual Testing on a Remote System with Coco explains how to configure this.
Of course, with the simulator, it is easier: the .csexe file is generated on the local file system in the workspace directory. It is just necessary to execute the application with the simulator and import the .vxe.csexe file into the CoverageBrowser.
Even though VxWorks is a highly configurable embedded system environment, it is possible to adapt Squish Coco to it easily, setting only few IDE variables and adding custom compilation switches to instrument it. For the testing phase, only retrieving an execution report file from the target’s file system is necessary.
To view a video which illustrates this article, go to froglogic’s YouTube channel: