Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

cpptestcli: files to analyse not found

Jan
Jan Posts: 2

We are using cpptestcli from eclipse Plugin and on the terminal. Using from eclipse and the cpptestcli based on eclipse is working too.
But we want to use cpptestcli in standard version for automation purpose. The cpptestcli is not working.
Our Project is a makefile project with a lot of software modules.

Project
|
-subModules
   |
   - Module1
      -Makefile
   - Module2
      -Makefile
   - ... 

We created a bdf file with cpptestscan for module1. The bdf file is placed in module1/out/cpptest/name.bdf
make is called from module1 folder.
CXX=cpptestscan --cpptestscanOutputFile=out/cpptest/module1.bdf --cpptestscanProjectName=module1 $(COMPILER_PREFIX)g++
CC=cpptestscan --cpptestscanOutputFile=out/cpptest/module1.bdf --cpptestscanProjectName=module1 $(COMPILER_PREFIX)gcc

We started cpptestcli likes this:
cpptestcli -compiler "COMPILER-ID" -config "builtin://Rule" -input absoluteWorkspacePath/Project/subModules/module1/out/cpptest/name.bdf

But no files will be analysed. We are getting for every file the following error message:

ERROR: Code Analysis for module1/../../subfolder/sourceFile.c finished with code 1 (ipro)
Error executing process: No such file or directory
Error preprocessing file " absoluteWorkspacePath/Project/subModules/module1/subFolder/sourceFile.c":
Process exited with status: 1
Could not preprocess source file

absoluteWorkspacePath/Project/subModules/module1/subFolder/sourceFile.c is located here.

bdf file:
WorkingDir=absoluteWorkspacePath/Project/subModules/module1
arg=subFolder/sourceFile.c

Tagged:

Best Answer

  • Bogdan Czwartkowski
    Bogdan Czwartkowski Posts: 146 admin
    edited May 13 Answer ✓

    @Jan,

    C/C++test internally uses compiler to preprocess analyzed files. The error message says that the preprocessing command did not succeed. Exit status 1 in this context is most often related to the compiler program not found by C/C++test.

    Could you double-check and make sure that the correct compiler "*gcc" and "*g++" are on the PATH before invoking cpptestcli?

    C/C++test Professional may have compiler path information stored in .parasoft file, i.e., in C/C++test Build Settings for the project. C/C++test Standard is detached from Eclipse and does not use Eclipse's project information, which may explain the difference in behavior. If adding compiler to the PATH does not help, we will look further into this.

Answers

  • Jan
    Jan Posts: 2

    @Bogdan Czwartkowski
    Thanks a lot for the detailed explaination.
    Now i understand the problem, but it would be nice if the error message points more out that the compiler could not be called.
    Maybe a part of the error message is Linux system error message.

    ERROR: Code Analysis for module1/../../subfolder/sourceFile.c finished with code 1 (ipro)
    Error executing process: No such file or directory
    Error preprocessing file " absoluteWorkspacePath/Project/subModules/module1/subFolder/sourceFile.c":
    Process exited with status: 1
    Could not preprocess source file
    

    In our bdf file there was arg=arm-linux-gnueabihf-gcc
    The path to the binary folder is not in the PATH var. So the compiler could not be called. I tried to add the compiler bin folder to the PATH var as you suggested. And it works. Great.

    An interessting thing is: We have other projects which are cmake based and i build a bdf for on those the projects. In this bdf file the arg=fullPathToCompilerBinFolder/arm-linux-gnueabihf-gcc. So the cpptestcli could find the compiler. I think i have to speak to my colleques who builded the make files for the other project where the arg=arm-linux-gnueabihf-gcc is like that. Maybe some changes to our make files could be made so that cpptestscan would put the full compiler path into the bdf file. Because we are using more than one compiler and to add every compiler to the path var i think it would be better to have the full compiler path in the bdf file.

    BTW. I am aware of using compile_commands.json file to use it with cpptestcli in cmake based projects.

  • Bogdan Czwartkowski
    Bogdan Czwartkowski Posts: 146 admin

    @Jan

    Thank you for the update. I am glad I could help with the issue.

    Indeed, it would be necessary to somehow arrange for C/C++test to see the compiler. Depending on the project it may be the PATH, or - if multiple compilers are used - maybe indeed embedding the path in the BDF will be easier. The question is if the compiler locations are fixed, and if the compiler program names are unique. If so, it could be perhaps still possible to add them to the PATH. I think it might be easier than altering make files. But again, it depends what works best for the project.

    Of course, using JSON files is also an option for static analysis. You can use it the same way as BDF with C/C++test 2021.1 and onwards. That would let you bypass the need to compile the project to get BDF, as compile_commands.json is generated right after cmake generator call.
    I just do not know if we can rely on the JSON files always using absolute compiler paths. We may still need to set the PATH to include the compiler.