This topic explains how to build a Docker container image for running C/C++test Standard.

Requirements

  • Linux 64-bit
  • Docker
  • C/C++test Standard installation package for Linux 64-bit

Building a Container Image

C/C++test ships with support for building a Docker container image in the <INSTALL_DIR>/integration/docker directory. The directory contains an example Dockerfile you can easily customize.

To build a Docker container image that includes C/C++test:

  1. Copy the C/C++test installation package (tar.gz) to the <INSTALL_DIR>/integration/docker directory.
  2. Open the Dockerfile in the <INSTALL_DIR>/integration/docker directory.
  3. Review and modify the contents of the Dockerfile. It allows you to:
    • specify the tools you want to include in the Docker container image (by default, the GCC 9 compiler is included).
    • license and configure C/C++test (see Licensing and Configuring C/C++test).
  4. Run the following command in the <INSTALL_DIR>/integration/docker directory to build the image:

    docker build -t cpptestcli:latest

    The image will include runnable C/C++test and other tools you specified in the Dockerfile.

Licensing and Configuring C/C++test

You can license and configure C/C++test before the container image is built. This allows you to provide a default C/C+test configuration to all users of the image.

  1. Create a cpptestcli.properties file in the <INSTALL_DIR>/integration/docker directory.
  2. Add the license settings and other configuration settings to the cpptestcli.properties file.

    You must configure a network license to run C/C++test in a Docker container. The local license is not supported. See Setting the License for details.

  3. Open the Dockerfile in the <INSTALL_DIR>/integration/docker directory.
  4. Uncomment the following line: COPY cpptestcli.properties /opt/parasoft/cpptest. This will add the cpptestcli.properties file to the /opt/parasoft/cpptest directory in the container image.

See Configuration for details about configuring C/C++test and a complete list of available settings.

Running C/C++test from the Container Image

Once you built the Docker container image that includes C/C++test, you can utilize all of the C/C++test's capabilities available from the command line interface. If C/C++test was not licensed and configured when the image was built, you need to create a cpptestcli.properties file in the current directory ($PWD) and configure the license and other options before you run C/C++test (see Configuration).

Use the following command to run C/C++test from the image:

docker run --rm -v $PWD:$PWD -w $PWD cpptestcli [C/C++test's command line options]

Examples

The following command prints the available test configurations:

docker run --rm -v $PWD:$PWD -w $PWD cpptestcli -list-configs

The following command executes analysis on a project located on the host in the current working directory ($PWD):

docker run --rm -v $PWD:$PWD -w $PWD cpptestcli -compiler gcc_9-64 -module . -trace make clean all

The following command runs static analysis on an example ATM project located inside the container (/opt/parasoft/cpptest/examples/ATM) using a cpptestcli.properties settings file that is located on the host in the current working directory ($PWD):

docker run --rm -v $PWD:$PWD -w /opt/parasoft/cpptest/examples/ATM cpptestcli -settings $PWD/cpptestcli.properties -compiler gcc_9-64 -module . -trace make clean all

See Command Line Options for a complete list of C/C++test's command line options.


  • No labels