Main Content

sltest.CodeImporter.SandboxSettings Class

Namespace: sltest.CodeImporter

Sandbox settings for C code testing

Since R2021a

Description

Use an object of the sltest.CodeImporter.SandboxSettings class to configure a sandbox for C code unit testing. Creating an sltest.CodeImporter object also creates a SandboxSettings object with default values. SandboxSettings objects do not apply when the TestType setting of the sltest.CodeImporter object is IntegrationTest.

Properties

expand all

Sandbox generation mode, specified as one of these values:

  • "GenerateAggregatedHeader" — For a single C code source file, generates a sandbox that includes a minimal, aggregated header file and stubs for undefined symbols. The header file contains the symbols required for compilation.

  • "GeneratePreprocessedSource" — Generates a sandbox containing the preprocessed version of the C code source files and creates stubs for undefined symbols.

  • "UseOriginalCode" — Generates a sandbox using the original C code without any modifications. However, if the code has undefined symbols, the CodeImporter creates stub files.

Attributes:

GetAccess
public
SetAccess
public

Whether to copy specified source files into the sandbox, specified as a numeric or logical 1 (true) or 0 (false). When CopySourceFiles is 1 or true,

  • If Mode is GenerateAggregatedHeader, the CodeImporter copies the specified source file to the sandbox src folder.

  • If Mode is UseOriginalCode, the CodeImporter copies the required header and source files to the sandbox include and src folders, respectively.

  • If Mode is GeneratePreprocessedSource, the CopySourceFiles setting is ignored.

Attributes:

GetAccess
public
SetAccess
public

Whether to remove pragmas from code files, specified as a numeric or logical 1 (true) or 0 (false). When RemoveAllPragma is true or 1,

  • If Mode is GenerateAggregatedHeader, the CodeImporter removes all #pragma instances from the aggregated header file.

  • If Mode is GeneratePreprocessedSource, the CodeImporter removes all #pragma instances from the preprocessed source.

  • If Mode is UseOriginalCode, RemoveAllPragma is ignored.

Attributes:

GetAccess
public
SetAccess
public

Whether to remove all global variable definitions in the generated header file and replace them with extern declarations, specified as a numeric or logical 1 (true) or 0 (false). RemoveVariableDefinitionInHeader applies only to GenerateAggregatedHeader mode. When RemoveVariableDefinitionInHeader is true or 1,

  • If Mode is GenerateAggregatedHeader, the global variable definitions are replaced in the aggregated header file.

  • If Mode is GeneratePreprocessedSource or UseOriginalCode, RemoveVariableDefinitionInHeader is ignored.

Note

If a source or header file that contains a global variable definition is included multiple times in the source file you are importing, set RemoveVariableDefinitionHeader to true or 1. The corresponding setting in the wizard is Remove variable definition in header file.

Attributes:

GetAccess
public
SetAccess
public

Examples

collapse all

Change the sandbox mode and variable definition header settings.

codeimport_obj = sltest.CodeImporter('myCodeTest');
codeimport_obj.CustomCode.SourceFiles = {'myCode1.c','myCode2.c'};

codeimport_obj.SandboxSettings.Mode = "GeneratePreprocessedSource";
codeimport_obj.SandboxSettings.RemoveVariableDefinitionInHeader = true;

Version History

Introduced in R2021a