You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

This lesson explains how to create a C++test project in the Eclipse-based version of C++test (standalone or plugin)  The projects are created using the general project import Eclipse facilities and a C++test-specific module for processing proprietary project files. C++test supports the following project types:

  • Standalone make-based projects
  • Eclipse-managed make projects
  • Green Hills Software projects
  • IAR Embedded Workbench projects
  • Keil uVision projects
  • Microsoft eMbedded Visual C++ 4.0 projects
  • Microsoft Visual Studio 6 projects (.dsp)
  • Renesas High-performance Embedded Workshop projects
  • TI Code Composer Studio projects
  • Wind River Tornado projects

The following exercises assume that a supported compiler is available on your machine, and the ATM example training project has been copied to an appropriate directory.

Objective

Learn how to create a C++test project to use in code analysis and testing from a standard make-based built project.

Exercise 1: Creating a Project From a Make-Based Build

  1. Launch C++test (or open your Eclipse) and switch to the C++test perspective, if it is not already open.
  2. Create a new Standard Make project as follows:
    1. Choose File> New> Project.
    2. Choose C/C++> C++ Project.
    3. Click Next. The project wizard will open.
    4. Enter a name for the project (ATM) in the Project name field.
    5. Under Project type, choose Makefile project> Empty project.
    6. Clear the Use default location check box.
    7. Click Browse and navigate to the directory containing the copied example project using the file browser (or type the path into the text field), then click Finish. For this exercise, set the top project directory to examples\ATM. The new project will appear in the Project Explorer view, which is on the left hand side of the GUI.
  3. Right-click the project node, choose Properties from the shortcut menu, then select the Parasoft> C++test> Build Settings category in the panel that opens.
  4. Review the build settings. The Project Settings area contains options that C++test will use to execute make with the specified makefile and collect project build options from that process. Note that C++test replaces the compiler by reassigning the value to the appropriate variables (as specified in the build command line).
  5. Modify the build command line accordingly if your main build target is not a default, or if your makefiles use compiler/linker variables that are different than the default ones provided with C++test.


Important note about the -B Switch

The build command line is preset to include the -B switch option (unconditionally make all targets). Only GNU Make 3.80+ supports this option.

If you are using an earlier make, clean the build before creating a project. Keep the -k switch.

If you are using a make that does not support -B,  further modification of the command line is required. The default build command line used in the project properties does not have any targets. We recommend that you modify this command line with the target(s) used to build the code you want analyzed  For example:

make -i CXX=\${CPPTEST_SCAN} ... all (where all is a target).

Also, add a clean step prior to the normal build target. For example:

make -i CXX={CPPTEST_SCAN} ... clean all

This would first make the clean target, then all target. Although the make run from C++test will not actually build object files, the clean step will actually clean th

Exercise 2: Importing an Existing Project from Disk

Projects for C++test need to be created only once; they can then be checked into source control and shared. All other team members can reuse the existing project setup. Therefore, for the most part, C++test users will not be creating projects by themselves, but rather importing existing projects that  were checked into source control.


Tip: Checking in Files for Reusable Projects

For a reusable C++test project, check in the following files, which are created in the project location:

  • .project (contains Eclipse project definition).
  • .cproject (contains Eclipse CDT project definition).
  • .parasoft (contains customized C++test project preferences, file will be created when any customization is done in the C++test settings on the project and/or file level).

To import an existing project from disk:

  1. Right-click the ATM project node in the Project Explorer view, then choose Delete. Leave the Delete project contents on disk option unchecked. This will remove the project from the Eclipse workspace, but it will leave the project contents (with the .project / .cproject / .parasoft files) on the disk.
  2. Choose File> Import.
  3. Select General> Existing Projects into Workspace, then click Next.



  4. Browse to the directory where the ATM project is located, then select the project to import.



  5. Click Finish. Your project should now be ready to use.
 

Exercise 3: Sanity Checking the Correctness of the Created Project


  1. Configure the output verbosity level by choosing Parasoft> Preferences, selecting Parasoft> Console, then setting the verbosity level to Normal.
  2. Select your project in the project tree.
  3. Choose Parasoft> Test Using> Built-in> Static Analysis> Parasoft’s Recommended Rules. The progress dialog will indicate when the test is completed. The dialog should report that checking has been performed on 8 files. TheConsolelog should report a summary of violations found. (If you do not see theConsoleview, choose Window> Show View> Console).

  • No labels