Studio:Interfacing Sample
Note: for content related to versions of STRIDE 3.0.0101a and earlier, please refer to Autoscript Sample v3.0.0101a
Introduction
The following content relates to the sample files and workspaces installed in %STRIDE_DIR%\Samples\TestScripts\Interfacing. This sample consists of a Visual Studio workspace for building an off-target simulator, sample source code and test scripts, and a STRIDE workspace for sample code execution.
Getting Started
Prerequisites
Before starting, some prerequisites must be satisfied. For details and instructions, see Host Installation.
Specifically:
- STRIDE must be installed on the Windows PC to be used in the training, and any required licenses must be present.
- Active State Perl must be installed, and additional perl packages must be downloaded and installed.
- Microsoft Visual Studio 2005 or a later version must be installed. If you do not currently have any version of Visual Studio, we recommend that you install the current free version of Visual Studio Express.
Basic Execution
To begin, open the Visual Studio Solution file in the sample directory. This solution (and corresponding project) were created for Visual Studio 2005. If you have a later version of Visual Studio installed, you should be able to open this solution and it will be automatically upgraded if necessary.
Once you have successfully opened the solution, rebuild it. The build process has custom STRIDE build rules integrated and will produce a STRIDE database, intercept module source files, and an off-target simulator application that incorporates the sample source code.
Once the build is complete, perform the following steps to run the sample scripts in the workspace:
- launch the off-target simulator, Interfacing.exe. This will run in a standard console window.
- open a command prompt window and change to this sample's directory.
- at the command prompt, run the command WorkspaceRun.pl -x setup -x teardown. This will execute all of the sample test scripts in the workspace and displays the results. You may open a browser and display the report written to the Ascript_Samples.html file in the sample's directory .
- quit the Ascript_Samples.exe application by typing 'q' in its console window.
Sample Description
Now that you have built the off-target simulator and executed the scripting samples, you can take time to peruse the sample scripts. This section provides a brief description for each category of example scripts. You can execute any of the scripts manually as long as you have the off-target simulator (Interfacing.exe) running.
The main focus of this sample is the use of your SCL qualified interfaces in script code. The STRIDE object that enables this is AutoScript - declared as ascript when injected into Studio's script execution environment. We provide functionally equivalent examples in two languages: jscript and perl. We recommend that you try to follow the provided examples in whichever language you are most comfortable reading.
Calling Functions
Owning Functions
Running Test Units
Run
This demonstrates the use of the TestUnits collection and items to invoke test units. The examples shows script examples of executing a single test units, all test units, and a single test unit with constructor arguments.
Sending Messages
Receiving Messages
Using Constants
The AutoScript object model exposes preprocessor macros present in the compilation units given to the STRIDE compiler. There are a number of rules that determine exactly how the macros are interpreted by the compiler (refer to SCL Language Reference for details). The AutoScript Constants Object exposes the preprocessor macros as a collection of items with name an value properties.
Macros
This shows how to use the Value field to refer to the interpreted value of the declared macro. In many cases, this is just the string representation of the macro as declared in the source code. In some cases, when the expression can be readily interpreted as an arithmetic or logical expression, the result of the expression is returned in the Value field instead. Refer to the corresponding Constants.h source file when reviewing this example.