Studio:Hello Stride Sample: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Introduction==
==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 [http://en.wikipedia.org/wiki/Microsoft_Visual_Studio Visual Studio] workspace for building a [[Windows_Off-Target_Apps| Windows Off-Target App]], sample [[Test_Unit_Samples|test unit]] source code, and a STRIDE workspace for executing the test unit sample.
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 [http://en.wikipedia.org/wiki/Microsoft_Visual_Studio Visual Studio] workspace for building a [[Off-Target Test App | Off-Target App]], sample [[Test_Unit_Samples|test unit]] source code, and a STRIDE workspace for executing the test unit sample.


==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:
* STRIDE must be installed on the Windows PC to be used in the training, and any required licenses must be present.
* 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 [[Desktop Installation#Perl|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.
* Active State Perl must be installed, and [[Studio:Desktop Installation#Perl|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 [http://en.wikipedia.org/wiki/Visual_Studio_Express Visual Studio Express].
* 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 [http://en.wikipedia.org/wiki/Visual_Studio_Express Visual Studio Express].


Line 35: Line 35:
===Command Line Execution===
===Command Line Execution===


Command line execution for test classes is done using the [[Test_Runners#TestUnitRun.pl|TestUnitRun utility]].  Here are several examples of specific syntax to execute test classes.  All of these commands can be invoked from a standard command shell and the arguments shown assume that the commands are executed with the sample's directory as the starting directory. You must have your HelloStride.exe application running in order for the runner to be able to initiate a connection to the target simulator. In addition, you should verify that your %STRIDE_DIR%\bin\[[Transport_Configuration_File|transport.cfg]] file is using the TCP transport to connect to port 8000 (these are the default settings when the product is installed).
Command line execution refer to [[Stride Runner]].
 
====Test unit execution with TestUnitRun.pl====
 
The following command executes all of the test units found in the STRIDE database you have previously generated.  For the purpose of this sample, since there is only one database, the -d parameter is not strictly needed, but we show it here for completeness.
 
  TestUnitRun.pl -d HelloStride.sidb
 
When you run this command, you should see console output like:
 
Attempting connection using [Sockets (S2)] transport ...
Connected to device.
Initializing STRIDE database objects...
Done.
Running Test TestHelloStride...
Disconnected from device.
Test Results saved to C:\STRIDE\Samples\HelloStride\HelloStride.xml
Test Report saved to C:\STRIDE\Samples\HelloStride\HelloStride.html
***************************************************************************
Results Summary
***************************************************************************
  Passed:              1
  Failed:              1
  In Progress:          0
  Not Applicable:      0
  ...in 1 suites.
***************************************************************************


===Workspace-Based Execution===
===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). In addition, the '''setup''' folder contains a script (''VerifyEnv.pl'') that verifies that the required Perl packages have been installed correctly. 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 [[AutoScript#ascript.TestUnits|TestUnits]] collection. The script is essentially one line:
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 [[AutoScript#ascript.TestUnits|TestUnits]] collection. The script is essentially one line:


<source lang="perl">
   my $tu = $main::ascript->TestUnits->Item("TestHelloStride");
   my $tu = $main::ascript->TestUnits->Item("TestHelloStride");
   if (defined($tu))
   if (defined($tu))
Line 72: Line 47:
     $tu->Run();
     $tu->Run();
   }
   }
</source>


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.
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.
Line 94: Line 70:
Click on the Test Report hyperlink to display the html report in a web browser.
Click on the Test Report hyperlink to display the html report in a web browser.


[[Category: Samples]]
[[Category:Studio:Samples]]

Latest revision as of 22:51, 2 June 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 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 File: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.