Slide 1

Unique Call Control

Automatically intercept or simulate
function calls for complete control

Leverage C/C++ Dynamic Testing with Cantata Call Control

 

Testing what happens when function calls from the Software Under Test (SUT) are made, is integral to all levels of dynamic testing. Cantata call interface control automatically generates the necessary test framework for these interfaces, making it easy to:

  • Simulate call interfaces between the SUT and called objects outside the build
  • Intercept call interfaces between the SUT and objects in the build
  • Set and validate data when function calls occur
  • Check return values and inject errors
  • Verify call order and control each call instance

Cantata’s Unique Wrappers Intercept and Simulate Calls
Automatic Wrapping provides unmatched call control for both C/C++ unit and integration testing. Wrappers allow you to:

  • Intercept calls with BEFORE and AFTER sections
  • Simulate calls by replacing them
  • Set and check data on each call

This level of call control automation helps testers maximize dynamic testing and validate software behaviour.

What is Cantata Call Control?

Cantata call interface controls are automatically generated for all function calls made by the Software Under Test (SUT), e.g., to other functions in the same or other files, 3rd party object code, operating system / compiler library, or target firmware / hardware. Users have complete control over the appropriate style of Cantata call control generated for each call made from each function:

  • Stubs simulate calls to objects not included in the build.
  • Isolates simulate specific calls to objects included in the build.
  • Wrappers simulate or intercept specific calls to objects included in the build.
  • Dependency Resolver automatically removes undefined link references.

Each type of Cantata call control is written in C/C++ as needed, providing a test control point in the execution flow to set and check data available to the SUT (e.g., global data or hardware registers) and parameters/returns. Since each control type can also have multiple instances, different behavior and call order can be set or verified each time a call is made in each test case scenario.

Isolation of C++ for testing from the remainder of the code base can result in a lengthy daisy-chain effect of undefined references at link time when building test executables. Cantata Dependency Resolver determines the missing references and automatically adds the required code to resolve all the undefined references (methods or variables).

The various Cantata call controls provide testers flexibility to choose simulation or interception as needed to drive and verify the code.

Optimize C/C++ Testing with Cantata Call Controls

Discover how Cantata can help you achieve more robust automated testing.

Cantata Wrapping:

The Power of Wrapper Functions for Automated Testing

Wrapper functions are a game-changer for automated testing. These unique functions automatically intercept or simulate other function calls. They go beyond traditional test doubles like stubs or mocks by providing more flexibility when integrating and testing components.

Automatically generated wrappers can intercept calls before, after, or entirely replace the original call with a simulation. When used with a Cantata test script, the wrappers generate code for before, after, and replace sections. Wrappers enable call interface control even outside of Cantata with other test drivers.

“Very useful, especially for checking the messages sent from one process to another, and also for simulating responses from external processes to the process under test.”

Dave Parker, Software Engineer, Marconi Communications

“Without this [Cantata wrapping], difficult external conditions not directly influenced by our code, such as memory allocation errors, may have been difficult to simulate.”

Simon Prior, Primary Reactor Protection System project, OSyS.

“Very useful, especially for checking the messages sent from one process to another, and also for simulating responses from external processes to the process under test.”

Simon Prior, Primary Reactor Protection System project, OSyS.

Automate Unit Testing with Wrapper Functions

Wrappers help automated unit testing in two key ways:

  • Intercept calls – Set or validate inputs/outputs before and after calls to functions inside or outside the test boundary.
  • Simulate calls – Replace any function call with a simulation to isolate the code under test.

Wrappers give more control over specific calls than traditional test doubles. You can intercept calls to functions inside the test boundary like those between classes in the same code file. Wrappers also allow flexibility in defining isolation levels for unit testing.

INTERCEPT & SIMULATE CALLS AT INTEGRATION & SYSTEM TEST

Integration & systems testing verifies the actual interaction between multiple units, so the more units are integrated, the less useful replacing those units with simulations becomes. Cantata Wrapping at integration & system testing retains all the benefits of Wrapping at unit testing, but it becomes even more useful to simulate or intercept specific calls when testing the actual interactions.

Cantata Wrapping interceptions are available for any C/C++ function call made from anywhere within the software under test to:

  • Other software components in the build
  • External software (including 3rd party or object code)
  • Operating system or standard library functions
  • Firmware or hardware

Cantata Wrapping interceptions allow the tester to check actual interface behavior, rather than use test scenarios based on assumptions in a simulation. Interception of calls provides unparalleled capability inject errors and verify actual behavior of actual interactions (e.g. failures with operating systems, 3rd party code, firmware and hardware) which are otherwise impossible or too expensive to test.

How does Wrapping work?

Cantata Wrapping uses accessibility instrumentation (via the GUI or CLI) on a copy of the source code to intercept function calls from the Software Under Test (SUT).

Anything called by a C/C++ function call can be Wrapped (e.g. another function, a 3rd party object, a database etc). A Wrapper has an identical function prototype to the called object being replaced, but testability instrumentation allows the called object to be included in the test build without causing linker errors.

The BEFORE, REPLACE and AFTER Wrapper sections insert programmable additional C/C++ functions, which then call: another Wrapper section, the called object or pass back to the SUT. Each Wrapper section contains Cantata directives to record call order, modify or check parameters / exceptions and all data accessible to the SUT or called object, and returns.

EDITING CANTATA CONTROLLED CALLS

Cantata automatically generates each Wrapper (containing BEFORE, AFTER and REPLACE sections) into the test script with a default BEFORE-AFTER pairing instance. This means that called objects can be Wrapped without forcing the tester to specify the return value.

Additional Wrapper instances (in either Before-After or Before-Replace pairings) may be added to check all parameter values passed to and from the called object. When additional instances are added, Cantata automatically offers checks of actual against expected values for all the parameters passed over the interface.

A function call to an object, can have all calls Wrapped or just selected calling functions.

Wrappers are implemented as C/C++ into a Cantata test script, and can be edited in the Cantata GUI, or directly using any C/C++ editor.

CONTROLLING CALLS IN TEST CASES

Cantata call interface controls can use multiple instances stubs, Wrappers or isolates to provide different behaviors on different occasions the call is made. These controlled calls and instances are used in a Cantata test script to set the expected order of calls and controlled behavior for each test case.

Expected Call Sequences are very flexible (linear, fixed size loops, parallel etc.), and can be set for specific orders or any time matches for each controlled call. The order of expected calls in each test case can be edited in the Cantata GUI (test script manager) or directly in any C/C++ editor.

More information about Wrapping

For further information about Wrapping please see our Wrapping feature brief: