MATLAB and Simulink Training

Testing C Code with Polyspace Test

Contact us to schedule

Course Details

This two-day, hands-on course discusses the use of Polyspace Test™ to dynamically verify C software in host and target environments against behavioral expected behaviors and code coverage objectives. Topics include:
 
  • Authoring and executing simple and complex graphical tests
  • Measuring code coverage of a set of test cases and generating test cases for missing code coverage
  • Using stubs and mocks to substitute for function calls in code under test
  • Authoring, building, and running test suites and test cases using the C xUnit API
  • Registering a provided target support package and running test cases on an external target
  • Generating reports from Polyspace Test results

Day 1 of 2


Authoring Graphical Tests

Objective: Become familiar with the Polyspace Platform environment and author and execute simple graphical tests.

  • Creating a Polyspace project
  • Configuring the test environment
  • Authoring simple graphical tests
  • Understanding generated artifacts
  • Generating test reports
  • Generating test reports

Handling Complex Data

Objective: Author graphical tests for code that contains various data formats and scopes.

  • Assessing floating-point values
  • Initializing and assessing global variables
  • Initializing and assessing pointers
  • Initializing and assessing structures
  • Initializing and assessing arrays

Authoring Complex Tests

Objective: Author tests with multiple function calls and perform parameter sweep tests.

  • Authoring multi-step tests
  • Authoring parametrized tests
  • Authoring scripted tests

Profiling, Coverage, and Test Generation

Objective: Run tests with instrumentation for various levels of code coverage, execution time profiling, and stack profiling.

  • Measuring code coverage
  • Generating tests for missing code coverage
  • Profiling execution time
  • Profiling memory usage
  • Automating code coverage and profiling on the command line

Day 2 of 2


Using Stubs and Mocks

Objective: Add stub functions for callees without an implementation, and write mocks for callees that need to be replaced in testing.

  • Stubs and mocks overview
  • Stubbing undefined global variables
  • Stubbing undefined functions
  • Mocking defined functions
  • Using mock variables

Authoring Tests with xUnit C API

Objective: Become familiar with simple tests in the xUnit C API, and compile and run tests directly with an external toolchain.

  • xUnit C API overview
  • Building, running, and reviewing xUnit-based tests
  • Using assessment macros
  • Exporting test results
  • Importing xUnit tests into Polyspace projects

Authoring Complex Tests with xUnit C API

Objective: Author tests using the xUnit C API that are organized into suites, parameter sweep tests, and tests that assess data of custom types.

  • Configuring test suites
  • Authoring parametrized tests
  • Comparing custom data type objects
  • Measuring code coverage
  • Measuring execution time and memory usage

Running Tests on Target

Objective: Cross-compile and run existing test cases on an external target and profile for performance and code coverage.

  • On-target testing overview
  • Registering targets
  • Running tests on target
  • Profiling on target

Level: Advanced

Prerequisites:

Strong knowledge of C or C++

Duration: 2 day

Contact us to schedule