2

I am trying to use Parasoft C/C++ Test to check "Coding Standards" with static tests. I found only "How to create bdf in Makefile projects" section in the Parasoft user guide.

How can I create a bdf for every project? Is it mandatory to use makefile project ?

Alperen
  • 3,772
  • 3
  • 27
  • 49

2 Answers2

6

Thanks for your answer, parasoft is not a reputed topic. Answers are worth a piece of gold. I couldn't find cpptesttrace. There are cpptest and cpptestscan. Could they be? I use an old version of parasoft.

You are correct. 'cpptesttrace' was added in Parasoft C++test version 9.4 (mid-2012), so likely you are using version 9.2 or earlier, where only 'cpptestscan' was present.

BTW, here is quick explanation of programs inside C++test standalone installation (not Visual Studio plugin):

  • cpptest - starts C++test GUI (Eclipse-based) usually for interactive work on a desktop
  • cpptestcli - C++test command line driver used to automate static analyses, e.g. running as a Jenkins job,
  • cpptestscan - used as a prefix to compiler command line to capture a single compilation information and add it to a BDF file
  • cpptesttrace - (since Parasoft C++test 9.4) used as a prefix to build command line, to capture all compilation commands and save in a BDF file

The main difference between cpptestscan and cpptesttrace is that:

  • cpptestscan had to be prepended to each compilation command line. This means, cpptestscan could capture single compilation only, and save one at a time into a BDF. This was done typically by overwriting make CC or CXX variable (specifying the compiler, e.g. "cpptestscan g++ -c foo.c -o foo.o").
  • cpptestrace was meant to be prepended once to the entire build command, and it tracked child processes invoked by the build command. Record of all processes recognized as compiler invocations were stored in a BDF.

cpptestscan was fine if makefile or a build script was flexible enough to allow overwriting compiler at the command line, e.g.

make CXX="cpptestscan g++" CC="cpptestscan gcc"

It is typically possible with make-based projects. As of custom or auto-generated build scripts, all bets are off. Often, the only option was to modify project build scripts, which people are usually nervous about. In such cases cpptesttrace can help, because it is completely non-intrusive, and can capture build information from almost any build process.

Going back to the original question of this post, if you have multiple projects:

  • using cpptestscan, you would need to somehow prefix compiler with cpptestscan in each projects' build scripts to create corresponding BDF
  • using cpptesttrace, you could run build for each project adding cpptesttrace in front of each projects' build command to create corresponding BDF The latter is often easier, but you would need newer C++test (the latest version is 10.3).

I hope that helps. BTW: Check with Parasoft if you could upgrade your C++test.

  • Thanks a lot. These explanations enlightened me. – Alperen Sep 26 '17 at 06:49
  • I have 2 project to use Parasoft. Your answer is so helpful for both. One them is perfectly works, but I have a problem at the other one. It still fails and gives parsing error in some files. I examined those files and I found out that they are all included same header in common, but Parasoft IDE gives "Unresolved inclusion" error. This project builds properly in its own IDE. And, I used the bdf file which is created by this build process. Because of this common header file is in include directories, build process works fine in its own IDE. Why doesn't that work? – Alperen Sep 27 '17 at 11:46
  • Also, I can see the related include directory in the bdf file. And, this header file has no C file, because it consists of some simple definitions. Let say its name is "asd.h", then, there is no "asd.o" word in the bdf file. – Alperen Sep 27 '17 at 11:49
1

Using make files is not mandatory. Parasoft C++test has a tool called 'cpptesttrace', that monitors build process and collects compiler invocations to create BDF file.
cpptesttrace can be used with any build process, be it make, shell script, or even build in the IDE (last resort if no command line build is available).

How cpptesttrace works:

  • you simply need to prefix your original build command line with 'cpptesttrace' and perhaps a couple options, and run your normal build
  • make sure to run full rebuild (e.g. 'make clean all') to make sure BDF contains information about all sources belonging to your build, and how they are compiled
  • cpptesttrace has a built-in set of supported compilers, and you can see compiler executable patterns by running 'cpptesttrace --cpptesttraceHelp'. In case your GNU GCC compiler name is "unusual", you can redefine pattern cpptesttrace is looking for.
  • in case of trouble, you can always contact Parasoft Support

Example 1:

I will give a make file example :), but it could be scons, jam, or Python script, or .bat: Assume, my full build is done like this:

 make clean all

I can run the build as follow, using cpptesttrace: cpptesttrace make clean all This will monitor the whole build and create a BDF file from the run.

Example 2:

If your build is multi-level process with script or make changing folders along the way, it might be good to tell cpptesttrace an absolute location for the BDF. Extending the above example, we could run:

cpptesttrace --cpptesttraceOutputFile=`pwd`/cpptest.bdf  make clean all

which will make sure that BDF path is absolute, no matter on which source tree level cpptesttrace is called.

Alperen
  • 3,772
  • 3
  • 27
  • 49
  • Thanks for your answer, parasoft is not a reputed topic. Answers are worth a piece of gold. I couldn't find cpptesttrace. There are cpptest and cpptestscan. Could they be? I use an old version of parasoft. – Alperen Sep 15 '17 at 13:41