Skip to content

Statements

import

Purpose

Load an OSC2 file into Foretify.

Category

Statement

Syntax

import "<path-name>"

Syntax parameters

<path-name>
(Required) The relative or full (global) path, including the file name, of the file to import. It must be enclosed in quotes. It may contain environment variables, preceded by '$'. The default file extension is .osc. Wildcards are not allowed. Files with the same name but different paths can be loaded.

Description

If you have built a scenario hierarchically, with a higher level scenario calling a lower-level one, and the coverage definitions in a separate file, you can use import statements to import all these files into a test file.

Imports must come before any other statements in an OSC2 file. The order of imports is important, as a type must be defined before it is referenced.

If a specified file has already been loaded, the statement is ignored. For files not already loaded, the search sequence is:

  1. If a full path is specified (for example, "/x/y/my_file"), then use that full path. The file name as specified is looked up first, and if not found, the name with the extension .osc is searched.

  2. Else look in the directory where the importing file resides.

  3. Else look in the current directory.

  4. Else look in directories specified by the OSC_PATH environment variable.

  5. Else this is an error.

Example

This example shows the import statements from a typical test. The first import line is the simulator configuration file, and the second loads cut_in_and_slow_top.osc, the top-level OSC2 source file for the test.

OSC2 code: import examples
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
import "$FTX_PACKAGES//base_scenarios/scenarios/vehicle_cut_in/vehicle_cut_in_and_slow/vehicle_cut_in_and_slow_top.osc"

See complete example.

The cut_in_and_slow_top.osc file in turn has the following import statements:

OSC2 code: import examples
import "$FTX_PACKAGES/base_scenarios/scenarios/vehicle_cut_in/vehicle_cut_in_and_slow/vehicle_cut_in_and_slow_h.osc"
import "$FTX_PACKAGES/base_scenarios/scenarios/vehicle_cut_in/vehicle_cut_in_and_slow/vehicle_cut_in_and_slow_imp.osc"
import "$FTX_PACKAGES/base_scenarios/scenarios/vehicle_cut_in/vehicle_cut_in_and_slow/vehicle_cut_in_and_slow_cover.osc"

See complete example.