Off-Target Environment: Difference between revisions
No edit summary |
|||
Line 78: | Line 78: | ||
</li> | </li> | ||
<li>From a console window, invoke stride as follows, to verify connectivity with the target app: | <li>From a console window, invoke stride as follows, to verify connectivity with the target app: | ||
<pre>stride -- | <pre>stride --diagnostics --database ~/stride/SDK/Linux/out/TestApp.sidb --device TCP:localhost:8000</pre> | ||
As the tests run you will see output in both the TestApp (target) and stride (host) windows. | As the tests run you will see output in both the TestApp (target) and stride (host) windows. |
Revision as of 21:37, 4 June 2009
Overview
The STRIDE SDK is provided to be used primarily as an off-target evaluation or development sandbox. This allows you to use STRIDE in a small, controlled environment without needing to make changes to your target build. In addition, the SDK Makefile can serve as an example of the steps needed to add STRIDE instrumentation to your target build.
Each SDK package has identical functionality, but targets a specific operating system. The SDK contains the following items:
- STRIDE runtime source
- PAL source for interface with the Target OS
- Makefile to build STRIDE runtime library, test and sample applications
- Compiler setting file for target processor
Evaluation Steps
To simplify the evalution, we recommend using a single Windows or Linux computer for both the target and host systems. Host and target code will run in separate processes and communicate via TCP/IP, thus simulating an embedded target with host computer configuration. All code and techniques used in the sandbox evaluation are directly transferrable to a production environment.
The recommended evaluation steps are as follows:
- Build the STRIDE runtime library
- Build and test the target app with S2 diagnostic tests
- Build and test the target app with the TestIntro sample
- Explore other sample tests
Building the STRIDE Runtime Library
Note: all Makefiles must be run with gnu make. For SDKs targeting OS's where this is not the standard make utility, an executable is supplied in the SDK's bin directory.
Linux
The Makefile assumes a gnu toolchain. (Other toolchains can be used; see the comments in the Makefile.)
- cd to ~/stride/SDK/Linux/src
- Build the library
make library
- The file ~/stride/SDK/Linux/out/lib/libstride.a will be produced
Windows
The Makefile assumes a Visual Studio toolchain. (Other toolchains can be used; see the comments in the Makefile.)
- If using Microsoft Visual Studio, open a Visual Studio command prompt to ensure that the compiler and linker are on your PATH.[1]
- cd to stride\SDK\Windows\src
- build the library using the supplied gnu make. (You will get Makefile errors if you use the default make.)
..\bin\make library
- The file stride\SDK\Windows\out\lib\stride.lib will be produced
Building the TargetApp
This step builds the first version of an instrumented target application. This application links with the STRIDE runtime library and includes the S2 diagnostic tests.
This step requires an installation of the STRIDE build tools. If not installed, please see Package Installation for more information.
Linux
- cd to ~/stride/SDK/Linux/src
- Build the test app
make testapp
- The file ~/stride/SDK/Linux/out/bin/TestApp will be produced
- Note also that the STRIDE database file ~/stride/SDK/Linux/out/TestApp.sidb is also produced
Windows
- If using Microsoft Visual Studio, open a Visual Studio command prompt to ensure that the compiler and linker are on your PATH.
- cd to stride\SDK\Windows\src
- build the test app using the supplied gnu make. (You will get Makefile errors if you use the default make.)
..\bin\make testapp
- The file stride\SDK\Windows\out\bin\TestApp.exe will be produced
- Note that the STRIDE database file stride\SDK\Windows\out\TestApp.sidb is also produced
SDK Target Application Details
Running the S2 Diagnostic Tests
In this step, we will use the stride executable to run the S2 diagnostic tests.
This step requires an installation of the STRIDE host tools. If not installed, please see Package Installation for more information.
- Invoke the TestApp.
- Windows: TestApp.exe will open and run in a new console window
- Linux: In order to see TestApp's output, we recommend that you manually open a new console and invoke TestApp from there
- Note TestApp's output upon startup. Under Linux, the following is shown
[tim@s2centos01 bin]$ ./TestApp starting up... "_srThread" thread started. "stride" thread started. Listening on TCP port 8000
- From a console window, invoke stride as follows, to verify connectivity with the target app:
stride --diagnostics --database ~/stride/SDK/Linux/out/TestApp.sidb --device TCP:localhost:8000
As the tests run you will see output in both the TestApp (target) and stride (host) windows.
The host window output running under Linux is shown here:
Loading database... Connecting to device... runtime version: 4.1.01 Diagnosing target application... link payload fragmentation runtime configuration stub-proxy deadlock target characteristics Summary: 52 passed, 0 failed, 0 in progress, 12 not in use. Disconnecting from device... Saving result file...
- Note the Summary results shown in the host output; all in use tests should pass.
- To exit TestApp, give the target window focus and enter ctrl-c (or 'q' under Windows).
Viewing Detailed Test Results
If you now list the files in the directory from which you ran stride, you will see the files TestApp.xml and--if you were connected to the Internet when you ran the tests--TestApp.xsl.
By opening TestApp.xml in a web browser, the xsl is automatically applied to create html in the browser.
Building the TargetApp to Include Test Intro Sample
In this step, will will add a set of sample tests that provide an overview of STRIDE testing techniques. The Test Intro Sample tests are described in the linked article.
This step requires an installation of the STRIDE Samples packaqge. If not installed, please see Package Installation for more information.
The SDK Makefile is set up so that all .c .cpp and .h files found in the directory SDK/Linux/sample_src (or, alternatively 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 SCL Pragmas which declare Test Units in these .h files
- the inclusion of metadata into the sidb file to describe these Test Units
- the generation of test harnessing code to run the indicated Test Units and collect results
To begin, be sure that TestApp is not running, then copy the .c and .h files found in Samples/TestIntro to SDK/Linux/sample_src (or Windows equivalent).
Linux
- cd to ~/stride/SDK/Linux/src
- Build the test app
make testapp
- The file ~/stride/SDK/Linux/out/bin/TestApp will be produced
- Note also that the STRIDE database file ~/stride/SDK/Linux/out/TestApp.sidb is also produced
Windows
- If using Microsoft Visual Studio, use a Visual Studio command prompt to ensure that the compiler and linker are on your PATH.
- cd to stride\SDK\Windows\src
- Build the test app using the supplied gnu make. (You will get Makefile errors if you use the default make.)
..\bin\make testapp
- The file stride\SDK\Windows\out\bin\TestApp.exe will be produced
- Note that the STRIDE database file stride\SDK\Windows\out\TestApp.sidb is also produced
Listing Test Units in the Database File
In this step, we will use stride to list the Test Units in the TestApp.sidb database.
Run stride as follows (or Windows equivalent):
stride --list --database ~/stride/SDK/Linux/out/TestApp.sidb
You should see output like this:
[tim@s2centos01 src]$ stride --list --database ~/stride/SDK/Linux/out/TestApp.sidb Loading database... s2_testintro_cclass s2_testintro_flist s2_testintro_testdoubles s2_testintro_testpoints
Note that the S2 diagnostic tests (which are present in this TestApp) are not listed.
Running Test Intro Samples
Running All Tests
Here we will run all tests in the TestApp.sidb database.[2]
- Invoke TestApp in a target console as in earlier steps.
- Invoke stride as shown below and verify Summary results.
[tim@s2centos01 src]$ stride --database ~/stride/SDK/Linux/out/TestApp.sidb --device TCP:localhost:8000 Loading database... Connecting to device... runtime version: 4.1.01 Executing test units... s2_testintro_cclass > 1 passed, 1 failed, 0 in progress, 0 not in use. s2_testintro_flist > 2 passed, 1 failed, 0 in progress, 0 not in use. s2_testintro_testdoubles > 3 passed, 0 failed, 0 in progress, 0 not in use. s2_testintro_testpoints > 3 passed, 0 failed, 0 in progress, 0 not in use. Summary: 9 passed, 2 failed, 0 in progress, 0 not in use. Disconnecting from device... Saving result file...
Running a Subset of Tests
Here we will run only the Test Units named s2_testintro_cclass and s2_testintro_flist against TestApp.
[tim@s2centos01 src]$ stride -r "s2_testintro_cclass, s2_testintro_flist" --database ~/stride/SDK/Linux/out/TestApp.sidb --device TCP:localhost:8000 Loading database... Connecting to device... runtime version: 4.1.01 Executing test units... s2_testintro_cclass > 1 passed, 1 failed, 0 in progress, 0 not in use. s2_testintro_flist > 2 passed, 1 failed, 0 in progress, 0 not in use. Summary: 3 passed, 2 failed, 0 in progress, 0 not in use. Disconnecting from device... Saving result file...
Additional Samples
Makefile Reference
Macros
- TOOLCHAIN
- RTSINGLEPROC
- STANDALONE_TESTAPP
- LIBRARYTYPE
Targets
- all
- Builds the library target
- library
- Builds STRIDE runtime, producing stride.lib
- clean
- Deletes intermediate and target files
- testapp
- Builds an instrumented test application, TestApp.exe, using sources found in the sample_src directory
- database
- im
- daemon
Instrumenting Multiple Processes
Related Links
- Build Tools
- Test Units
- SCL Pragmas
Notes
- ↑ You can get a VS command prompt via the Start menu. Choose: Start -> All Programs -> Microsoft Visual Studio 200X -> Visual Studio Tools -> Visual Studio 200X Command Prompt
- ↑ Note that the S2 diagnostic tests are treated separately, and are not run unless the --diagnostic option is specified to stride.