Keil uVision Static Analysis Quick Start
In this post, I will go over how to get started with using C++test static analysis on Keil uVision projects. In this example, I will be using the C++test example MDK-ARM Sensor project. This can be found within ${CPPTEST_HOME}/Examples/Embedded/MDK-ARM/Sensor.
In this post I will use the following:
C++test 10.4.2 Professional Standalone Edition
Keil uVision 5
Note: some of the images within the post have been significantly reduced in size. Right-click on each of the images and select "Open image in new tab"
This tutorial works on older versions of C++test and Keil uVision 4:
- Copy the Example Folder into a new location.
- Open your uVision IDE.
- Go to File -> Open and navigate to the MDK-ARM Sensor project and open the Sensor.uvproj
- Right-Click on the Top level of your project and select "Options for Target" go to the Output Tab and make sure that the "Create Batch File" option is enabled.
- Go to Project -> Build Target. Your project should build without any errors and a new batch file should be generated in the project directory.
- Open your Command Prompt.
- Navigate to the MDK-ARM Sensor Project File and run the following command
cpptesttrace --cpptesttraceProjectName=Sensor --cpptesttraceOutputFile=Sensor.bdf --cpptesttraceResponseFileOption="--Via" "C++test - Simulator.BAT"
The cpptesttrace executable will trace throughout all of the project settings specified within the generated batch file and generate a bdf.
7b. Alternatively, we can import via Keil Project. Go to File -> New -> Other -> C/C++test -> Import Keil uVision project
Point to the location of your .uvproj or .uvprojx then select next then select the location for the imported project (we recommend using the workspace location if possible)
Enabling Use Path Variable to define linker folder locations (if applicable) and re-define the Path Variable Name so that it's easily recognizable and could be shared with other team members.
Ensure that Path Variable Value to the hard-coded path of your Keil Project on your machine.
In the Project target Settings select Use other build target (if applicable) and select C++test - Simulator
- Open C++test. You can either open C++test from the command line or on the C++test shortcut on your Desktop. From the command line, you can open C++test by running cpptest.exe
Import the Sensor.bdf. This can be done by going to New -> Other -> C/C++test -> Create project from a build data file.
Click on the top left to select have C++test point to the Sensor.bdf file then select Finish
The Sensor project will now appear within the Navigator view.
- Select the Top of the project.
- Go to Parasoft -> Test Configurations -> Builtin -> Static Analysis -> Effective C++.
- Select Run Test
You should see that 62/62 files have been scanned with 865 Tasks Reported
Review your Quality Tasks View to review the violations reported from C++test.
This concludes the Quick Start guide for Static Analysis with Keil uVision. Happy Testing!