メインコンテンツ

Fix Project Build Errors in Polyspace Platform User Interface

Issue

A Polyspace Platform project consists of C/C++ source files, tests, and configuration information. All three aspects of a project come into play when you build a project. If a build error occurs, it can indicate an issue in one or more of these places.

All build errors are shown on the Logs pane, along with a View logs link to view the full build log and a right-click option on the link to view the log file in an external editor. Most of these errors can be caught and resolved earlier in the test authoring workflow, before you build your project. This topic discusses the various types of build errors and how they are reported in the user interface.

Possible Solutions

In a typical test authoring workflow, you add test data to test cases in your project and then build the project before running tests. When you build a project, you are building the test code that is generated from your test data. Since the test code invokes functions under test, building the project also builds functions that are tested.

Build errors can occur because of compilation issues in the functions under test, incorrect test data, or other reasons.

Check for Unsupported Compiler

If you see an error message such as:

Supported C/C++ host compiler not found. Install a supported compiler.
Make sure that a supported compiler is selected in your settings. For more information, see Specify C/C++ Compilers for Testing in Polyspace Platform User Interface.

Check for Source Code Errors

A build error can occur because of compilation issues in source files. To check your source code for compilation issues, select Parse Code on the Polyspace® Platform toolstrip. If your source files contain any compilation issues, the initial code analysis fails and emits the error messages on the Logs pane. Use the View logs link to see the full log. For more information on the initial code analysis, see Parse Source Code for Auto-Populating Test Information in Polyspace Platform User Interface.

These error messages refer to the error location by file name and line number. You can navigate to the relevant file and line, and investigate the error further. If you fix these errors and get to the point where you can start authoring tests, you should not see source code compilation errors during project build.

For instance, if there is a missing semicolon error in a source file, a message such as the following is shown during code analysis:

"D:\Repos\v22\src\file.c", line 7: error: expected a ";"
|            return 1;
|            ^

For more information on code analysis, see Parse Source Code for Auto-Populating Test Information in Polyspace Platform User Interface.

Check for Test Authoring Errors

A build error can occur because of missing or incorrect test data. To check for errors in your tests, click the Test Code button on the Test Case tab of the Polyspace Platform toolstrip. Polyspace Test™ validates the generated code for your tests. If there are any errors in your test code, the errors are shown in the Logs pane. If you fix these errors and see the generated test code, you should not see test data errors during project build.

These error messages refer to steps in specific test cases. You can navigate to those steps in the test case and check the input and assessment tables.

For instance, the following error about missing inputs and assessments in a test step is shown during test code generation:

Cannot open code view. Fix test(s) definition first.

Test case 'Step2': input 3 contains invalid value: ''
Test case 'Step2': assessment 2 contains invalid value: ''

For more information on viewing generated test code, see Build and Run Tests in Polyspace Platform User Interface.

Check for Other Errors

An error that is not caught during the initial code analysis or test code generation might occur when you build a project. When you select the Build Project button on the Polyspace Platform toolstrip, the generated test code and source files are compiled and linked into an executable. The error messages for compilation or linking errors that are detected during the build process are displayed in the Logs pane.

These error messages are like regular compiler error messages and refer to the error location by file name and line number. You can navigate to the relevant file and line, and investigate the error further. These errors can be caused by various issues, such as:

  • Issue in your source code — Some issues in your source code might not be detected during the initial code analysis. These issues are detected during the final build.

  • Issues in your test code — If the error message refers to the generated test code, open the test code file for further investigation. The test code files are located in the project artifacts folder specified using the configuration option Artifacts directory. Inside the project artifacts folder, there is a Tests subfolder that contains the following:

    • The code generated from your tests in a codegen subfolder.

    • All build artifacts in a build subfolder.

    Based on variable names and code comments, you can associate lines in the generated test code to input or assessment rows in your test data tables. You can then fix the issue in the input or assessment row thereby fixing the issue in the generated test code.

  • Issues with your project configuration — Polyspace Test constructs the build command for your compiler based on the project configuration you specify. If these configuration are inappropriate for your compiler and your code, the compilation might fail. For instance, you might be missing paths to static or dynamic libraries required for linking.

See Also

Topics