Difference between revisions of "Studio:Hello Stride Sample"

From STRIDE Wiki
Jump to: navigation, search
(Prerequisites)
Line 4: Line 4:
  
 
==Prerequisites==
 
==Prerequisites==
Before starting, some prerequisites must be satisfied. For details and instructions, see [[Desktop Installation]].
+
Before starting, some prerequisites must be satisfied. For details and instructions, see [[Studio:Desktop Installation]].
  
 
Specifically:
 
Specifically:

Revision as of 22:57, 6 May 2010

Introduction

The purpose of this sample is to verify that STRIDE is installed and functioning correctly and the required prerequisites for STRIDE operation are met. The following content relates to the sample files and workspaces installed in %STRIDE_DIR%\Samples\HelloStride. This sample consists of a Visual Studio workspace for building a Windows Off-Target App, sample test unit source code, and a STRIDE workspace for executing the test unit sample.

Prerequisites

Before starting, some prerequisites must be satisfied. For details and instructions, see Studio:Desktop 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. Note: when the sample workspace is executed, a script runs that verifies that the required Perl packages have been installed correctly.
  • 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.

Getting Started

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 a Windows Off-Target App that incorporates the test unit source.

Once the build is complete, perform the following steps to run the test unit in the workspace:

  1. launch the Windows Off-Target App, HelloStride.exe. This will run in a standard console window.
  2. open a command prompt window and change to this sample's directory.
  3. at the command prompt, run the command TestUnitRun.pl -v. This will execute all of the test units in the workspace and open a browser to display the results.
  4. quit the HelloStride.exe application by typing 'q' in its console window.

HelloStride Test Unit

Now that you have built the Windows Off-Target App and executed the test unit it contains, you can take time to peruse the source and the corresponding results that was produced. The HelloStride sample defines a test unit, TestHelloStride, as a test function list that combines two simple target functions, tf_HelloStride_Pass and tf_HelloStride_Fail, both of which use STRIDE runtime APIs to set descriptions and add comments for their respective test cases. One of the test functions returns a value indicating a PASS status, and the other returns a FAIL status.

Test Unit Execution

This sample demonstrates two different techniques for executing the sample test unit.

Command Line Execution

Command line execution refer to Stride Runner.

Workspace-Based Execution

We also provide a sample STRIDE workspace that demonstrates the use of script execution within STRIDE Studio. This workspace was created using WorkspaceSetup.pl. The setup and teardown folders provide basic infrastructure scripts that start and stop the Windows Off-Target App (HelloStride.exe). The script that drives the testing is in the workspace test folder. This folder contains a single script, RunTest.pl, that executes the sample test unit through the STRIDE AutoScript object's TestUnits collection. The script is essentially one line:

  my $tu = $main::ascript->TestUnits->Item("TestHelloStride");
  if (defined($tu))
  {
    $tu->Run();
  }

Note that the test folder has the OnRunConnect property checked (to see this, select the folder and look for the property in the Properties panel in Studio.) When this property is true, the connection is established with the target simulator before the contents of the folder are executed. The order of the folders in the workspace here is important - the setup folder executes before the test folder, so the Windows Off-Target App is started before the connection is established when the test folder runs.

Running the Test

  • Run the workspace by clicking on the Run All toolbar button RunAll.png
    • At the completion of the run, you will see text similar to the following written to the STRIDE Messages window:
Tests Complete
***************************************************************************
Results Summary
***************************************************************************
  Passed:               1
  Failed:               1
  In Progress:          0
  Not Applicable:       0
  ...in 2 suites.
***************************************************************************

Test Report created file://C:\STRIDE\Samples\HelloStride\HelloStride.html

Click on the Test Report hyperlink to display the html report in a web browser.