Skip to content

Instantly share code, notes, and snippets.

@daparic
Last active September 23, 2025 19:06
Show Gist options
  • Select an option

  • Save daparic/16c3f7baa8cbceb7bb94a6c6774152fa to your computer and use it in GitHub Desktop.

Select an option

Save daparic/16c3f7baa8cbceb7bb94a6c6774152fa to your computer and use it in GitHub Desktop.

https://discord.gg/awPTNeCm

These are my CLI notes both for Linux and Windows. The cpptestcli can understand a Visual Studio 2019 solution, therefore, there is no need to generate a bdf file. Other projet types (make, cmake, etc) needs to have a generated bdf file.

Beware of cpptestcli vs bin/cli/cpptestcli differences

# Two ways it can be done:

# First way
# Mere presence of cpptestcli.properties in pwd is NOT honored. First need to create associated workspace.
cpptestcli -data ~/parasoft/workspace/democicd -bdf cpptestscan.bdf
cpptestcli -config "builtin://Effective C++" -data ~/parasoft/workspace/democicd/ -report report -property report.format=sarif -settings /some/path/cpptestcli.properties

# Second way
# Mere presence of cpptestcli.properties in pwd is honored. No need of an associated workspace. The compiler has to be specified.
bin/cli/cpptestcli -config "builtin://Effective C++" -compiler gcc_11-64 -input cpptestscan.bdf -report report3 -property report.format=sarif [-settings /some/path/cpptestcli.properties]

NOTES

TODO: To clarify further below to indicate whether cpptestcli or bin/cli/cpptestcli is meant:

SA directly a Visual Studio 2019 Solution

cpptestcli -config "builtin://Recommended Rules" -solution demo-visualstudio.sln -report reports

Generate a bdf file for the project and name the project hello

cpptesttrace --cpptesttraceProjectName=hello make

Create an associated Eclipse workspace for a project to a desired workspace path

cpptestcli -data "D:\wp1" -bdf cpptestscan.bdf

Autogenerate unit testcases for one file ATM.cxx in a project

cpptestcli -data "D:\wp1" -config "builtin://Generate Unit Tests" -resource "hello/ATM/ATM.cxx" 

Autogenerate unit testcases for all files in a project

cpptestcli -data "D:\wp1" -config "builtin://Generate Unit Tests"

Run unit testcases in a project

cpptestcli -data "D:\wp1" -config "builtin://Run Unit Tests"

Run unit testcases in a Keil project

cpptestcli -data "D:\wp1" -config "builtin://Run Keil uVision Tests - ULINKPro or Simulator (ITM)"

Run static analyses of a Visual Studio project

cpptestcli -solution demo-visualstudio.sln -config "builtin://Effective C++"

Powershell execution policy

Set-ExecutionPolicy Unrestricted
Get-ExecutionPolicy

Do SA for a project from its Makefile (and without any bdf yet)

cpptestcli -config "builtin://Effective C++" -compiler gcc_11-64 -trace make
# or
cpptestcli -config "builtin://Effective C++" -settings ~/cpptestcli.properties -compiler gcc_11-64 -trace make CC=gcc CXX=g++

https://asciinema.org/a/Knto0fLCwru6RrxqRoba5Lakl

Do SA Visual Studio Solution

"/c/Program Files (x86)/Parasoft/C++test for Visual Studio/10.6"/cpptestcli.exe -config "builtin://Effective C++" -solution demo-visualstudio.sln -report d:/report
"/c/Program Files (x86)/Parasoft/C++test for Visual Studio/10.6"/cpptestcli.exe -config "builtin://Effective C++" -solution demo-visualstudio.sln -report d:/report -property report.format=sarif

Use URL as config for SA

bin/cli/cpptestcli -config https://gist.githubusercontent.com/daparic/3f754066fde95fccaa050d61a052c7fa/raw/4d799966cae3c1190d7028d8a25172dc5940e80b/MYCWE362.properties -bdf cpptest
scan.bdf -compiler gcc_11-64

User file as config for SA

cpptestcli -config /tmp/MYCWE362.properties -bdf cpptestscan.bdf 

VxWorks

$ type wr-cc
wr-cc is /opt/wndrvr/wrsdk-vxworks7-qemu-1.13.2_23.09/vxsdk/host/x86_64-linux/bin/wr-cc

$ wr-cc --version
clang version 16.0.0.1 (git://ala-cngitmirror-prod.wrs.com/llvm/clang.git 577521ca9d20893fb1725e736eee6c9442c4a8f9) (git://ala-cngitmirror-prod.wrs.com/llvm/llvm.git 27addbd28ded33590a03920414e8ec600e9e752c)
Target: x86_64
Thread model: posix
InstalledDir: /opt/wndrvr/wrsdk-vxworks7-qemu-1.13.2_23.09/vxsdk/host/x86_64-linux/bin/../../../../compilers/llvm-16.0.0.1/LINUX64/bin

make CC='cpptestscan --cpptestscanOutputFile=trace.bdf wr-cc' CXX='cpptestscan --cpptestscanOutputFile=trace.bdf wr-c++'
cpptestcli -config "builtin://Recommended Rules" -compiler wrclang_9_0-x86_64 -input trace.bdf

Try we must, for UT:

$ cat opts.properties 
bdf.import.compiler.family=wrclang_9_0-x86_64
bdf.import.c.compiler.exec=wr-cc
bdf.import.cpp.compiler.exec=wr-c++
bdf.import.linker.exec=wr-cc

$ mkdir /tmp/oo/
$ /opt/parasoft/cpptest_professional-2023.2.0-linux.x86_64/cpptestcli -data /tmp/oo/ -config "builtin://Generate Unit Tests" -bdf trace.bdf -localsettings opts.properties
$ /opt/parasoft/cpptest_professional-2023.2.0-linux.x86_64/cpptestcli -data /tmp/oo/ -config "builtin://Run Unit Tests" -bdf trace.bdf -localsettings opts.properties

Wind River

https://forums.parasoft.com/discussion/4369/working-with-wind-river-workbench-in-command-line?utm_source=community-search&utm_medium=organic-search&utm_term=Wind+River+

# SA
cpptestcli -data /PATH/TO/WORKSPACE -resource /SpeedSensor/SpeedSensor.c -config "builtin://Recommended Rules"

# UT
cpptestcli -data /PATH/TO/WORKSPACE -resource /SpeedSensor/tests/TestSuite_SpeedSensor.c -config "builtin://Run Unit Tests"

Suppress

The presence of parasoft.suppress beside ATM.cpp is honored in the report.html. The -module . seems to play a role here in suppression, without it, the parasoft.suppress is ignored and additionally, no header file is analyzed.

bin/cli/cpptestcli -config "builtin://Effective C++" -compiler gcc_13-64 -input cpptestscan.bdf -module . -module misc/bbb/ccc -report report9

SA: exclude

cpptestcli -config "builtin://Effective C++" -compiler gcc_13-64 -input cpptestscan.bdf -report report/ -exclude **/misc/**

UT: exclude (must be at generate time and once only)

cpptestcli -data ~/home/dx/parasoft/2024.2.0/demo-eclipse/ -config "builtin://Generate Unit Test" -exclude **/misc/aaa/* -report report/

Custom Flow Analysis Configuration

cpptestcli -config /path/to/my.properties

@daparic

daparic commented Jun 26, 2023

Copy link
Copy Markdown
Author

My reminder gitlab setup:

  • gitlab-runner must have path of cpptestcli
  • Set PATH /etc/profile.d/myenv.sh (ok)
  • Copy to /home/gitlab-runner/cpptestcli.properties
  • Register 30-days Vulnerability Report Feature in gitlab?
  • Beware of the Runner bug

@daparic

daparic commented Jun 28, 2023

Copy link
Copy Markdown
Author

@daparic

daparic commented Jun 28, 2023

Copy link
Copy Markdown
Author

Github Demo visualstudio2019.yml

@daparic

daparic commented Jun 28, 2023

Copy link
Copy Markdown
Author

Once the Parasoft C/C++test tool is installed, run the below command to get your machine ID:
cpptestcli -machineid

@daparic

daparic commented Nov 16, 2023

Copy link
Copy Markdown
Author

A DOS bat script to do SA on every compiler families:

@echo off
setlocal enabledelayedexpansion

set "compilers_file=D:\compilers.txt"

for /f %%c in (%compilers_file%) do (
    set "r=D:\reports\%%c"
    mkdir !r!
    echo "*** %%c ****"
    cpptestcli -config "builtin://Recommended Rules" -settings d:/cpptestcli.properties -report !r! -compiler %%c -bdf cpptestscan.bdf > !r!\cpptestcli.log 2>&1
    timeout /t 1 > nul
)

endlocal

@daparic

daparic commented Nov 16, 2023

Copy link
Copy Markdown
Author

A bash script to do SA on every compiler families:

#!/bin/sh
#

while read c;do
    r=/tmp/sa/reports/$c
    mkdir $r
    echo "*** $c ****"
    bin/cli/cpptestcli -config "builtin://Recommended Rules" -settings /path/to/cpptestcli.properties -report $r -compiler $c -bdf cpptestscan.bdf > $r/cpptestcli.log 2>&1
    sleep 1
done < /tmp/compilers

@daparic

daparic commented Dec 19, 2023

Copy link
Copy Markdown
Author

@daparic

daparic commented Jan 16, 2024

Copy link
Copy Markdown
Author

@daparic

daparic commented Jan 16, 2024

Copy link
Copy Markdown
Author

@daparic

daparic commented Aug 23, 2024

Copy link
Copy Markdown
Author
bin/cli/cpptestcli -config "builtin://Effective C++" -compiler gcc_8-64 -bdf c:/Users/dx/parasoft2024.1.0-workspace/demo-eclipse/.cpptest/.dtpengine/session_20240823_083922/demo-eclipse.bdf # scans c/c++ files listed in bdf
cpptestcli -config "builtin://Effective C++" -data c:/Users/dx/parasoft2024.1.0-workspace/demo-eclipse # scans all c/c++ files

@daparic

daparic commented Dec 16, 2024

Copy link
Copy Markdown
Author

@daparic

daparic commented Jan 20, 2025

Copy link
Copy Markdown
Author

@daparic

daparic commented May 26, 2025

Copy link
Copy Markdown
Author

Static Analysis:

cpptestcli -data /home/dx/parasoft/2024.2.1/democ-eclipse-arm -config "builtin://Effective C++" -report report
cpptestcli -data /home/dx/parasoft/2024.2.1/democ-eclipse-arm -config "builtin://Effective C++" -report report2 -property report.format=sarif

Dynamic Analysis:

cpptestcli -data /home/dx/parasoft/2024.2.1/democ-eclipse-arm -config "user://Run Tests for ARM64 target" -report report4

@daparic

daparic commented Sep 23, 2025

Copy link
Copy Markdown
Author

Unit testing in CLI

type cpptestcli
cpptesttrace make
cpptestcli -data ~/test-workspace/ -bdf cpptestscan.bdf
cpptestcli -data ~/test-workspace/ -config "builtin://Generate Unit Tests"
cpptestcli -data ~/test-workspace/ -config "builtin://Run Unit Tests" -report report
cpptestcli -data ~/test-workspace/ -config "user://My Run Unit Tests" -report report2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment