Samples Overview

From STRIDE Wiki
Revision as of 23:13, 6 June 2011 by Marku (talk | contribs)
Jump to navigation Jump to search

Introduction

The samples are provided with with the Desktop installation package. They are self-documented (using doxygen or perldoc) and this content will be attached to the test report whenever a sample is executed. They are also readily executable using our off-target (desktop) environment.

The samples were created to be as simple as possible while sufficiently demonstrating the topic at hand. In particular, the samples are very light on core application logic (that is, the source under test) -- they focus instead on the code that leverages STRIDE to define and execute tests. As you review the sample code, if you find yourself confused about which code is the test logic and which is the source under test, try reading the source file comments to discern this.

What you need to do

In order to get the full benefit from these training articles, we recommend you do the following:

  • follow the wiki links we provide in the training articles. These links provide rich technical information on the topics covered by the training. These are also articles you will likely refer to in the future when you are implementing your own tests.
  • read/review all sample source code prior to running. The samples consist almost entirely of source code, so it makes sense to use a source code editor (one you are familiar with) for this purpose.
  • build and execute the samples using the off-target framework. If you completed your installation as instructed above, it should be fully functional when you do the training.
  • review the reports that are produced when you run the samples. The reports give you a feel for how data is reported in the STRIDE Framework. The extracted documentation is also provided in the report.
  • For most samples, we provide some observations that help summarize aspects of the results that might be of interest to you. These observations are not necessarily comprehensive - in fact, we hope you'll discover other interesting features in the samples that we haven't mentioned.

Organization

The samples are a collection of native and script source code that demonstrate the techniques for creating and executing tests using the STRIDE Framework. The samples are grouped into two top-level directories:

test_in_c_cpp
These are samples that implement the test logic using native code that executes on target. This functionality is focused at developers interested in writing tests in c/c++.
test_in_script
These are the introductory samples for the STRIDE Framework that illustrate how to do expectation testing of instrumented source under test using script test modules on the host.

Once you have established a Off-Target Environment on your desktop, you can easily build and run any combination of these samples. In every case, you can include a sample simply by copying its source files to the SDK's sample_src directory and rebuilding the testapp.

Tests in C/C++

How you package your tests refers to how functions or methods implementing test cases are included into test units. It's possible for different packaging options to coexist, but for consistency and simplicity, we recommend that you decide early on in your test creation cycle what kind of test unit package you will use for your test units and then stick with that for all of your test units.

Test Intro Sample

This sample is an introduction to some of the testing features and techniques from a C only perspective. For C++ environments we recommend the Test Intro Cpp Sample.


Test Class Sample (packaging)

If your compiler supports standard C++, the Test Class packaging is preferred as it allows the greatest functionality and flexibility with no added complexity for the simplest use cases.[1] (Note that the Test Class packaging can be used even if the software under test is written in C.) Demonstrates features available when test units are created as C++ classes.

Test C Class Sample (packaging)

Demonstrates how to create and use test units that are C structures

Test Function List Sample (packaging)

Demonstrates how to create and use test units that are free C functions

Test Macros Sample

Pass/Fail Macros simplify the task of setting a test case's status to pass or fail. They comprise a set of ASSERTs and EXPECTs that test a condition (e.g. equailty, less than, strings equal, etc.) and set the currently running test to the appropriate pass or fail status. ASSERTs cause the currently executing function to immediately return if fail status is set; EXPECTs do not return. This sample demonstrates the use of the Test Code Macros. This sample is implemented using Test Classes (c++ only), but these macros also work in C compilation units.

Test Point Sample

Test points are a unique STRIDE feature that greatly simplifies testing of multi-threaded software as well as single-threaded software that employs callbacks. This Sample demonstrates techniques and syntax for implementing Test Points. With this technique, STRIDE makes it possible to observe and verify activity occurring another thread (e.g. a state machine).

Test Double Sample

Test doubles provide a means to intercept function calls so that alternate implementations can be substituted at runtime under the control of your test code. This enables sophisticated mocking, faking, and stubbing. This Sample demonstrates techniques and syntax for implementing Test Doubles. STRIDE's unique implementation makes it possible to dynamically switch in function mocks, stubs, and fakes at runtime. This sample is implemented using Test Classes (c++ only), but the techniques demonstrated work equally well in C compilation units.

File Services Sample

The STRIDE File Services APIs provide a means to perform basic filesystem operations on the host filesystem from test code running on a device. This Sample demonstrates techniques and syntax for performing basic tasks using the File Transfer Services API.

Tests in Script

The following samples are available to illustrate the use of host scripting with the STRIDE Framework.

Expectations Sample

This sample provides some pre-instrumented source code that include STRIDE Test Points and Test Logs. A single perl test module is included that implements a few examples of expectation testing based on the software under test.

FileTransfer Sample

This sample shows an example of how you might use helper functions on the target to invoke STRIDE File Transfer services. The example is driven by host script logic that invokes remote target functions to actuate a file transfer to the target.

FunctionRemoting Sample

This sample shows some examples of invoking remote functions for the purpose of fixturing your behavior tests written in script on the host.


Notes