Difference between revisions of "Studio:Integrating the Intercept Module (IM)"

From STRIDE Wiki
Jump to: navigation, search
Line 8: Line 8:
 
* Stack size
 
* Stack size
 
* Threads
 
* Threads
 +
 +
== Configuring and generating an Intercept Module ==
 +
You can either generate the IM via STRIDE Studio’s Intercept Module Wizard, or you can utilize scripts to automatically configure and generate the IM files. These files will contain Studio-based configuration definitions. In addition, the script used for configuration will denote in which context the IM runtime functions are to be executed.
 +
 +
The script can execute automatically so that the Intercept Module is built as part of the test automation framework, as shown in the following example. The IM generation script should open a Studio workspace, optionally compile the workspace and save the database (if needed), then configure and create the IM as shown in the following Perl example:
 +
 
 +
  # Compile and save the workspace database
 +
  $main::studio->Workspace->CompileAll();
 +
  $main::studio->Workspace->Save();
 +
 
 +
  # Intercept Module (IM) name and path constants
 +
  my $IM_FILE_NAME = "stride";
 +
  my $IM_LOCATION_PATH = $main::studio->Workspace->Path;
 +
 
 +
  # Create a reference to the workspace IM object
 +
  my $IM = $main::studio->Workspace->Intercept;
 +
 
 +
  # Local variables
 +
  my ($i, $fx);
 +
 
 +
  # Reset all of the IM configuration settings to off and
 +
  # reset the delegate group Id's to their default name.
 +
  $IM->Reset();
 +
 
 +
  # Setup the IM name and path
 +
  $IM->{Name} = $IM_FILE_NAME;
 +
  $IM->{Path} = $IM_LOCATION_PATH;
 +
 
 +
  # For each interface in the IM collection
 +
  for ($i=0; $i < $IM->Count(); $i++)
 +
  {
 +
      # reference the ith interface;
 +
      $fx = $IM->Item($i);
 +
 
 +
      $fx->{Stub} = 1;              # configure as stub
 +
                                    # and delegate
 +
      $fx->Delegate->{Owner} = 1;    # mangle from owner's perspective
 +
      $fx->Delegate->{Explicit} = 1; # implicit name mangling
 +
      $fx->Delegate->{Dynamic} = 1;  # enable dynamic interception
 +
  }                               
 +
 
 +
  # Create IM files.
 +
  $IM->Create();
 +
 +
The resulting Intercept Module file is then compiled and built with the rest of your target code.
 +
 
== Starting the IMStubRead thread ==
 
== Starting the IMStubRead thread ==
  
 
[[Category:Deploying STRIDE]]
 
[[Category:Deploying STRIDE]]

Revision as of 19:37, 20 June 2007

IM Files and how they are used

Naming conventions

The Intercept Module source file (IM.c / IM.cpp)

The IM.h file

The IMEntry.h file

Adding the IM files to the build

IM Resource Requirements

  • Stack size
  • Threads

Configuring and generating an Intercept Module

You can either generate the IM via STRIDE Studio’s Intercept Module Wizard, or you can utilize scripts to automatically configure and generate the IM files. These files will contain Studio-based configuration definitions. In addition, the script used for configuration will denote in which context the IM runtime functions are to be executed.

The script can execute automatically so that the Intercept Module is built as part of the test automation framework, as shown in the following example. The IM generation script should open a Studio workspace, optionally compile the workspace and save the database (if needed), then configure and create the IM as shown in the following Perl example:

 # Compile and save the workspace database
 $main::studio->Workspace->CompileAll();
 $main::studio->Workspace->Save();
 
 # Intercept Module (IM) name and path constants
 my $IM_FILE_NAME = "stride";
 my $IM_LOCATION_PATH = $main::studio->Workspace->Path;
 
 # Create a reference to the workspace IM object
 my $IM = $main::studio->Workspace->Intercept;
 
 # Local variables
 my ($i, $fx);
 
 # Reset all of the IM configuration settings to off and
 # reset the delegate group Id's to their default name.
 $IM->Reset();
  
 # Setup the IM name and path
 $IM->{Name} = $IM_FILE_NAME;
 $IM->{Path} = $IM_LOCATION_PATH;
  
 # For each interface in the IM collection
 for ($i=0; $i < $IM->Count(); $i++)
 {
     # reference the ith interface;
     $fx = $IM->Item($i);
  
     $fx->{Stub} = 1;               # configure as stub
                                    # and delegate
     $fx->Delegate->{Owner} = 1;    # mangle from owner's perspective
     $fx->Delegate->{Explicit} = 1; # implicit name mangling
     $fx->Delegate->{Dynamic} = 1;  # enable dynamic interception
 }                                 
  
 # Create IM files.
 $IM->Create();

The resulting Intercept Module file is then compiled and built with the rest of your target code.

Starting the IMStubRead thread