Running and Publishing the Expectations Sample: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
Line 52: Line 52:
Here we will run the test module that is provided in this example .
Here we will run the test module that is provided in this example .


# Run TestApp in a console window as in [[Building Test App | earlier steps]].
# Run TestApp in a console window as in [[Off-Target Test App | earlier steps]].
# Invoke <tt>stride</tt> in a separate console window (different from the running TestApp) -- as shown below and verify Summary results.
# Invoke <tt>stride</tt> in a separate console window (different from the running TestApp) -- as shown below and verify Summary results.



Revision as of 00:05, 15 May 2010

Building Instrumented Source Under Test

In this step, will will add pre-instrumented example source that provide an overview of STRIDE instrumentation techniques. The Expectations Sample sources are described in the linked article.

This step requires an installation of the STRIDE Framework package. If not installed, please see Desktop Installation for more information.

How the SDK Makefile Includes Tests

The SDK Makefile is set up so that all .c .cpp and .h files found in the directory SDK/Windows/sample_src are included in the compile and link of the testapp target.

Further--as a pre-compilation step--any .h files found in sample_src are submitted to the S2 compiler and subsequent Build Tools. This will result in

  • the detection of test pragmas used to declare Test Units in these .h files
  • the detection of function pragmas used to declare remoting of functions also found in .h files
  • the inclusion of metadata into the sidb file created
  • the generation of an intercept module required for executing tests

Build Steps

To begin, be sure that TestApp is not running, then copy the .c and .h files found in Samples/test_in_scrips/Expectations to SDK/Windows/sample_src. As described above, the presence of these files in the sample_src will result in the submission of the .h files to the STRIDE Build Tools.

Once the files have been copied to sample_src, simply build TestApp using the SDK makefile.

Linux

  1. Build the test app
    cd $STRIDE_DIR/SDK/Linux/src
    make testapp
    
  2. The file $STRIDE_DIR/SDK/Linux/out/bin/TestApp will be produced
  3. Note also that the STRIDE database file <tt$STRIDE_DIR/SDK/Linux/out/TestApp.sidb is also produced

Windows

  1. If using Microsoft Visual Studio, open a Visual Studio command prompt[1] to ensure that the compiler and linker are on your PATH.
  2. Build the test app using the supplied GNU make. (You will get Makefile errors if you use the default make.)
    cd %STRIDE_DIR%\SDK\Windows\src
    ..\bin\make testapp
    
  3. The file %STRIDE_DIR%\SDK\Windows\out\bin\TestApp.exe will be produced
  4. Note that the STRIDE database file %STRIDE_DIR%\SDK\Windows\out\TestApp.sidb is also produced

Running Expectation Sample

Here we will run the test module that is provided in this example .

  1. Run TestApp in a console window as in earlier steps.
  2. Invoke stride in a separate console window (different from the running TestApp) -- as shown below and verify Summary results.

Here are the command line parameters that we will submit to stride

--run=%STRIDE_DIR%\Samples\test_in_script\Expectations\s2_expectations_testmodule.pm
--database ./out/TestApp.sidb 
--device TCP:localhost:8000

The command line arguments are very long, so we'll want to create a text file named RunSample.txt in the SDK\Windows directory as an option file to submit to stride.

If you haven't done so already, start TestApp running in a separate console window.

Now run stride as follows (starting from the SDK\Windows directory):

stride -O RunSample.txt

The output should look like this:


Loading database...
Connecting to device...
Executing...
  test module "C:\stride\Samples\test_in_script\Expectations\s2_expectations_testmodule.pm"...
    > 3 passed, 1 failed, 0 in progress, 0 not in use.
  ---------------------------------------------------------------------
  Summary: 3 passed, 1 failed, 0 in progress, 0 not in use.

Disconnecting from device...
Saving result file...

Publishing Results to Test Space

To automatically publish test results add the following options to RunSample.txt:

--upload
--testspace https://USER:PASS@mycompany.stridetestspace.com
--project Sandbox
--space Samples


Now run stride as follows:

stride -O RunSample.txt

The output should look like this:


Loading database...
Connecting to device...
Executing...
  test module "C:\stride\Samples\test_in_script\Expectations\s2_expectations_testmodule.pm"...
    > 3 passed, 1 failed, 0 in progress, 0 not in use.
  ---------------------------------------------------------------------
  Summary: 3 passed, 1 failed, 0 in progress, 0 not in use.

Disconnecting from device...
Saving result file...
Uploading to test space...


A few things to note:

  • the run parameter specifies the test module to execute
  • You will have to replace USER:PASS with your S2-assigned TestSpace user name and password
  • You will have to replace mycompany with your S2-assigned subdomain name
  • The project "Sandbox" and TestSpace "Expectations" have been pre-created within your company STRIDE TestSpace


Viewing Results in Test Space

First navigate to the S2-provided TestSpace with your browser. The URL has the form: https://companyname.stridetestspace.com. On the page that is presented, enter your login credentials.

At the top of the next page, click on the All Projects link to view the status of existing projects. Here you should see the Sandbox project listed, with its contained TestSpace Expectations shown.

Clicking the Expectations link will present you with the Expectations TestSpace page. From the top-line results at the bottom of the page you can drill down into the Sequence_1 results to see the test details.

Analyzing the Results

At this point, we recommend that you take some time to review the techniques used in the Expectations sample tests and correlate the results shown in Test Space with the various STRIDE constructs in the sample source. The article Expectations Sample describes the tests in detail.


  1. To open a Visual Studio Command prompt: Click the Start button, point to All Programs, Microsoft Visual Studio 200X, Visual Studio Tools, and then click Visual Studio 200X Command Prompt.