Software Testing Automation Framework (STAF) V2 Developer's Guide
January 30, 2006
V 2.6.9
This document explains how to build STAF. It assumes that you are familiar with the operating system(s) in question and the process of building software in general. It will walk you through the process of:
STAF developers are the intended audience for this document.
Obtaining the STAF Source Code
Externally open sourced STAF code is available on SourceForge via two methods:
Each tar file contains a snapshot of the source code for a released version of STAF.
gunzip STAF252-src.tar.gz
tar -xvf STAF252-src.tarNote: The STAF230-src.tar.gz file was tarred up wrong in that it didn't include the src/staf directory structure. So, if you use this file, create a src/staf directory structure and untar the file into it.
The current STAF code is contained in CVS, including code that has not been released yet.
cd /cygdrive/dWhere d is the drive where you want to put STAF code.
md buildWhere build is the name of the directory to where you are checking out STAF code.
cd build
cd / mkdir buildWhere build is the name of the directory to where you want to check out STAF code.
cd build
export CVS_RSH=sshThis must be done once for each window.
ssh developername@staf.sourceforge.netEnter your SourceForge password when prompted. Exit.
ssh developername@cvs.staf.sourceforge.netEnter your SourceForge password when prompted. You cannot execute anything here so it will exit for you.
cvs -d :ext:developername@cvs.sourceforge.net:/cvsroot/staf co srcEnter your SourceForge password when prompted.
cd src/staf
cvs updateEnter your SourceForge password when prompted.
Requirements for Building STAF
To build STAF, you need to install the following software based on the operating system where you are building:
To build the Java interface component of STAF and to build any STAF services written in Java, you need to install Java. Currently, we are mostly using Java 1.4.2 (IBM or Sun), but also support other versions of Java.
To build the REXX interface component of STAF, you need to install REXX.
Explaining the STAF Source Tree and Build Environment
All STAF source code is contained in the /src/staf directory. This is the directory from which you run 'make' to build various STAF projects.
The STAF uses the "whole-project makefile" approach described in Peter Miller's Recursive Make Considered Harmful article.
The /src/staf/stafif directory contains STAF daemon and internal STAF Services source code.
The /src/staf/stafproc directory contains STAF C interface library source code.
The /src/staf/services directory contains source code for external STAF services like Log, Monitor, and
Resource Pool.
Any operating system specific code is contained in a subdirectory (e.g. win32, unix) under the STAF component.
There are subdirectories for each language in which STAF services can be implemented in the /src/staf/lang directory.
The STAF source tree looks like the following:
/src/staf/ - Contains all STAF source code /src/staf/makefile - The master STAF makefile /src/staf/build/ - Contains auxilliary makefiles used in building STAF /src/staf/codepage/ - Contains additional code pages /src/staf/docs/ - Contains STAF documentation, including makefile to build STAF docs /src/staf/History - A file containing a history of changes made to STAF by version /src/staf/install/ - Contains STAF installation source code /src/staf/install/unix/ - Contains the STAFInst program used to install from a STAF tar file /src/staf/install/ismp/ - Contains InstallShield Multi-Platform source code for installing STAF /src/staf/lang/ - Contains source code for supporting the different languages in which STAF services can be implemented /src/staf/lang/java/ - Contains source code for supporting STAF services implemented in Java /src/staf/lang/jython/ - Contains source code for supporting STAF services that package Jython /src/staf/lang/perl/ - Contains source code for supporting STAF services implemented in Perl /src/staf/lang/rexx/ - Contains source code for supporting STAF services implemented in REXX /src/staf/lang/tcl/ - Contains source code for supporting STAF services implemented in Tcl /src/staf/lang/python - Contains source code for supporting STAF services implemented in Python /src/staf/package/ - Contains makefiles used for packaging STAF /src/staf/samples/ - Contains sample source code showing how to interact with STAF from different languages such as C, C++, and REXX /src/staf/samples/demo/ - Contains the STAF Demo source code /src/staf/services/ - Contains source code for external STAF services like Log, Monitor, and Resource Pool, STAX /src/staf/stafclnt/ - Contains STAF command line utility source code /src/staf/stafif/ - Contains STAF C interface library source code /src/staf/stafinfo/ - Contains the STAF information utility source code /src/staf/stafproc/ - Contains STAF daemon and internal STAF Services source code /src/staf/stafreg/ - Contains source code for the STAF Registration program /src/staf/test/ - Contains source code used to test STAF /src/staf/utils/ - Contains source code for STAF utilities like fmtlog (Format Log Utility) and GenWl (Generic Workload Processor) /src/staf/webpages/sf - Contains source code for the STAF SourceForge web pages
This section describes how to build STAF from a valid source tree.
STAF's master Makefile is located in the /src/staf directory. See it for additional
information about the environment variables used.
cd /build/src/stafAssuming /build is the directory where you checked out STAF source code.
export MSVCDIR=c:/MVStudio
export VSCOMMONDIR=d:/MVStudio/Common
Note: The VSCOMMONDIR environment variable is not needed if you selected the default install location for the common Microsoft Visual C++ components.
export MSSDKDIR=d:/MicrosoftSDK
Note: MSSDKDIR only needs to be set if you are building IA-64 code for Windows. Typically, only MSSDKDIR or MSVCDIR (and, possibly, VSCOMMONDIR) need to be set. You don't normally need to set both.
make
You may want to put these commands in a shell script that you run instead, e.g. ". ./setstaf.sh". Examples of some common shell scripts that you make want to use are:
export PROJECTS=staf export OS_NAME=win32 export BUILD_TYPE=retail export MSVCDIR=d:/MVStudio (Only needed if on Windows) export VSCOMMONDIR=d:/MVStudio/Common (Only needed if on Windows) export MSSDKDIR=d:/MicrosoftSDK (Only needed if on Windows and building IA-64 code) make
export PROJECTS=java export JAVA_DRIVE=d export JAVA_LIBS=jvm export JAVA_VERSION=1.4 export JAVA_BUILD_V11=0 export JAVA_BUILD_V12=1 export JAVA_V12_ROOT=/cygdrive/d/ibmjdk1.4.2 export JAVA_V12_LIBDIRS=/cygdrive/d/ibmjdk1.4.2/lib export JAVA_V12_BIN_DIR=/usr/java_dev2/sh (this is only required on AIX, when using Java 1.2+ to build) make
export PROJECTS=docs export OS_NAME=win32 export BUILD_TYPE=retail export B2H_ROOT=d:/tools/b2h export JAVA_V12_ROOT=d:/tools/sunjdk1.4 export SAXON_ROOT=d:/tools/saxon export DOCBOOK_ROOT=d:/tools/docbook export MSVCDIR=d:/MVStudio (Only needed if on Windows) export VSCOMMONDIR=d:/MVStudio/Common (Only needed if on Windows) export MSSDKDIR=d:/MicrosoftSDK (Only needed if on Windows and building IA-64 code) make
Notes:
export PROJECTS=rexx export OS_NAME=win32 export REXX_ROOT=/cygdrive/d/ObjREXX export REXX_LIBDIRS=d:/ObjREXX/API export RXPP_ROOT=d:/tools/rxpp make
Note that you need to have RXPP installed in order to build the STAF Documentation. On Windows, you should download the rxpp.tar file (available on staf1b.austin.ibm.com in the /tools directory) to d:/tools/rxpp, and untar the file in this directory.
export PROJECTS=perl PERL_V58_ROOT ?= c:/perl583 PERL_V58_INCLUDEDIRS ?= $(PERL_V58_ROOT)/lib/CORE PERL_V58_LIBDIRS ?= $(PERL_V58_ROOT)/lib/CORE PERL_V58_LIBS ?= perl58 PERL_BUILD_V58 ?= 1 PERL_V56_ROOT ?= c:/perl PERL_V56_INCLUDEDIRS ?= $(PERL_V56_ROOT)/lib/CORE PERL_V56_LIBDIRS ?= $(PERL_V56_ROOT)/lib/CORE PERL_V56_LIBS ?= perl56 PERL_BUILD_V56 ?= 1 make
Note that you need to have (on Windows or Linux) ActivePerl 5.6 and 5.8 installed. It can be downloaded from http://aspn.activestate.com/ASPN/Downloads/ActivePerl/.
To build STAF Perl 5.6 support, you need both Perl 5.6 and 5.8 installed and you must set the environment variables documented above for both Perl 5.6 and for Perl 5.8. This is because building STAF Perl support requires xsubpp (the external subroutine preprocessor) which only exists in Perl 5.8. STAF's Perl support code uses XS which is C-like glue code that gets massaged by Perl's xsubpp into legitimate C code.
After installing ActivePerl, note that if you are using cygwin, when you are running STAF perl testcases, you must fully-qualify where the perl binary exists (i.e., /cygdrive/d/perl/bin/perl teststaf.pl).
To run perl testcases, you must set the environment variable PERLLIB=c:/staf/bin.
To build STAF support for Perl 5.0 on Linux, you need to build project "perl50". The "perl" project will only build STAF support for Perl 5.6 and Perl 5.8.
export PROJECTS=python export OS_NAME=win32 export PYTHON_ROOT=d:/python export PYTHON_INCLUDEDIRS=d:/python/include export PYTHON_LIBDIRS=d:/python/Libs export PYTHON_ROOT=d:/python export PYTHON_LIBS=python22 make
Note that you need to have (on Windows) Python 2.2 installed. It can be downloaded from http://www.python.org/2.2.1/ Note that that you must run a RETAIL build for Python (a DEBUG build will fail).
To run python testcases, you must set the environment variable PYTHONPATH=c:/staf/bin (or else copy the .pl file to c:/staf/bin and run it from that directory).
export PROJECTS=tcl export OS_NAME=win32 export TCL_INCLUDEDIRS=d:/tcl/include export TCL_LIBS=d:/tcl/lib/tcl83 make
Note that you need to have (on Windows) TCL 8.3 installed. It can be downloaded from http://tcl.sourceforge.net.
To run tcl testcases, you must set the environment variable TCLLIBPATH=c:/staf/bin. To start a tcl testcase, an example command is "tclsh83 TestTcl.tcl"
export PROJECTS=demo export OS_NAME=win32 export BUILD_TYPE=retail export MSVCDIR=d:/MVStudio (Only needed if on Windows) export VSCOMMONDIR=d:/MVStudio/Common (Only needed if on Windows) export MSSDKDIR=d:/MicrosoftSDK (Only needed if on Windows and building IA-64 code) make
export PROJECTS=jython export JYTHON_ROOT=d:/jython-2.1 export JAVA_DRIVE=d export JAVA_LIBS=jvm export JAVA_VERSION=1.4 export JAVA_BUILD_V11=0 export JAVA_BUILD_V12=1 export JAVA_V12_ROOT=/cygdrive/d/ibmjdk1.4.2 export JAVA_V12_LIBDIRS=/cygdrive/d/ibmjdk1.4.2/lib export JAVA_V12_BIN_DIR=/usr/java_dev2/sh (this is only required on AIX, when using Java 1.2+ to build) makeNotes:
export PROJECTS=stax export JAVA_DRIVE=d export JAVA_LIBS=jvm export JAVA_VERSION=1.4 export JAVA_BUILD_V11=0 export JAVA_BUILD_V12=1 export JAVA_V12_ROOT=/cygdrive/d/ibmjdk1.4.2 export JAVA_V12_LIBDIRS=/cygdrive/d/ibmjdk1.4.2/lib export JAVA_V12_BIN_DIR=/usr/java_dev2/sh (this is only required on AIX, when using Java 1.2+ to build) export XERCES_ROOT=c:/tools/xerces-2_6_2 make
Notes:
export PROJECTS=event export JAVA_DRIVE=d export JAVA_LIBS=jvm export JAVA_VERSION=1.4 export JAVA_BUILD_V11=0 export JAVA_BUILD_V12=1 export JAVA_V12_ROOT=/cygdrive/d/ibmjdk1.4.2 export JAVA_V12_LIBDIRS=/cygdrive/d/ibmjdk1.4.2/lib export JAVA_V12_BIN_DIR=/usr/java_dev2/sh (this is only required on AIX, when using Java 1.2+ to build) make
export PROJECTS=cron export JAVA_DRIVE=d export JAVA_LIBS=jvm export JAVA_VERSION=1.4 export JAVA_BUILD_V11=0 export JAVA_BUILD_V12=1 export JAVA_V12_ROOT=/cygdrive/d/ibmjdk1.4.2 export JAVA_V12_LIBDIRS=/cygdrive/d/ibmjdk1.4.2/lib export JAVA_V12_BIN_DIR=/usr/java_dev2/sh (this is only required on AIX, when using Java 1.2+ to build) make
export PROJECTS=eventmanager export JAVA_DRIVE=d export JAVA_LIBS=jvm export JAVA_VERSION=1.4 export JAVA_BUILD_V11=0 export JAVA_BUILD_V12=1 export JAVA_V12_ROOT=/cygdrive/d/ibmjdk1.4.2 export JAVA_V12_LIBDIRS=/cygdrive/d/ibmjdk1.4.2/lib export JAVA_V12_BIN_DIR=/usr/java_dev2/sh (this is only required on AIX, when using Java 1.2+ to build) make
export PROJECTS=http export JAVA_DRIVE=d export JAVA_LIBS=jvm export JAVA_VERSION=1.4 export JAVA_BUILD_V11=0 export JAVA_BUILD_V12=1 export JAVA_V12_ROOT=/cygdrive/d/sunjdk1.4.2 export JAVA_V12_LIBDIRS=/cygdrive/d/sunjdk1.4.2/lib export JAVA_V12_BIN_DIR=/usr/java_dev2/sh (this is only required on AIX, when using Java 1.2+ to build) export APACHE_XERCES_ROOT=c:/tools/xerces-2_6_2 export COMMONS_LOGGING_ROOT=c:/tools/commons-logging-1.0.4 export COMMONS_CODEC_ROOT=c:/tools/commons-codec-1.3 export COMMONS_HTTPCLIENT_ROOT=c:/tools/commons-httpclient-3.0 export NEKOHTML_ROOT=c:/tools/nekohtml-0.9.5 make
Notes:
On Linux, Solaris, and AIX, there is an additional file that is not built with STAF but must be included in the lib directory. The file should already reside on your build system, so simply copy this file to the lib directory before packaging the build for distribution. The files are:
Note that on Solaris, even if you build a retail version of STAF, the binary and library files will still contain symbolic information. After the build completes, you must run the "strip" command on every binary and library file before packaging the build for distribution.
Note that on AIX, you may receive the following error message when building STAF:
xlC_r: 1501-230 Internal Compiler error; Please contact your Service RepresentativeIf you receive this error message, ignore it (it is a compiler bug on AIX) and re-start the build (by typing "make" again). The second make should be successful.
To run using the version of STAF you just built, refer to the "Running STAF from the Built Executables" section.
Running STAF from the Built Executables
To run STAF from the executables you built, perform the following based on the operating system you are using:
STAF local SHUTDOWN SHUTDOWN
cd /build/rel/linux/staf/retail (or /build/rel/linux/staf/debug) export STAFHome=$PWD export LD_LIBRARY_PATH=$STAFHome/lib:$STAFHome/lib/java12:$LD_LIBRARY_PATH export PATH=$STAFHome/bin:$PATH export STAFCONVDIR=$STAFHome/codepage
cp /usr/local/staf/bin/STAF.cfg bin
which STAFProcShould show something like: /build/rel/linux/staf/retail/bin/STAFProc
STAFProc&If you get error "mprotect reset:Bad address", then check the version (uname -a), and if 2.4, type the following and then restart STAF:
export LD_ASSUME_KERNEL=2.2.25
You can run STAF from the executables you built from a Cygwin window or from a Windows command prompt.
STAF local SHUTDOWN SHUTDOWN
D: cd \build\rel\win32\staf\retail (or \build\rel\win32\staf\debug) set STAFHome=D:\build\rel\win32\staf\retail set PATH=%STAFHome%\bin;%STAFHome%\lib;%STAFHome%\lib\java12;%PATH% set STAFCONVDIR=%STAFHome%\codepage
cp C:\STAF\bin\STAF.cfg D:\build\rel\win32\staf\retail\bin
which STAFProcNote: The "which" utility for Windows does not come with Windows. Should show something like: d:\build\rel\win32\staf\retail\bin/STAFProc.exe
STAFProc
STAF local SHUTDOWN SHUTDOWN
cd /cygdrive/d/build/rel/win32/staf/retail (or /cygdrive/d/build/rel/win32/staf/debug) export STAFHome=$PWD export PATH=$STAFHome/bin:$STAFHome/lib:$STAFHome/lib/java12:$PATH export STAFCONVDIR=d:/build/rel/win32/staf/retail/codepage
cp /cygdrive/c/STAF/bin/STAF.cfg /cygdrive/d/build/rel/win32/staf/retail/bin/STAF.cfg
type STAFProcShould show something like:
STAFProc is /cygdrive/d/build/rel/win32/staf/retail/bin/STAFProc
STAFProc
Explaining How STAF is Packaged for Installation
STAF is packaged for installation using InstallShield MultiPlatform for
most operating systems and/or as GNU zipped tar files for some of the
Unix operating systems.
We use InstallShield MultiPlatform (ISMP) to provide a GUI interface to install STAF. In order to package STAF using ISMP, you need a license for InstallShield MultiPlatform. We provide both a ISMP jar file and an ISMP executable for each operating system supported by STAF, except for Irix and AIX 4.3.2 or earlier which are not supported by InstallShield MultiPlatform.
For example, for STAF 2.5.2 for Windows, files STAF252-setup-win32.jar and STAF252-setup-win32.exe are available for download from the STAF SourceForge website. If you already have Java 1.2 or later installed, you would probably download the ISMP jar file because it is smaller. If you do not already have Java installed, you would need to download the ISMP executable file (which includes a bundled JVM).
For Unix systems whose platforms are not supported by InstallShield MultiPlatform, such as Irix and AIX 4.3.2 or earlier, a GNU zipped tar file is provided. We also provide GNU zipped tar files for some of the other operating systems as well. Once the tar file is untarred, the STAFInst executable is used to install STAF.
For example, for STAF 2.3.0 for Irix, file STAF230-irix.tar.gz is available for download from the STAF SourceForge website.
Here are the steps to create a Tar File (these steps will use Linux as an example):
STAF provides consistent and easily readable source code by adhering to the following conventions:
tryNot:
{
connection->writeUInt(0);
}
try{ connection->writeUInt(0); }
void rollBuffer(char * buffer, int bufferLen, int rollLen)
int endIndx = bufferLen - rollLen;
if ((i == offset) || (last == -1))
/***********************************************************************/ /* STAFStringNumOfWords - Returns the number of words in a STAFString */ /* */ /* Accepts: (In) A STAFString_t */ /* (Out) The number of words */ /* (Out) A pointer to an OS return code (may be NULL) */ /* */ /* Returns: kSTAFOk on success */ /* other on error */ /***********************************************************************/
/* This clause establishes the new eol marker. It causes the use of binary transfer if the eol on both sides are the same and no codepage conversion is to be done. This allows for a faster transfer. */
// offset = buffer length - null char - ending // index of eol offset = len - 1 - endBuffer;
class STAFHandleManager
unsigned int maxConvertedLength;
void rollBuffer(char * buffer, int bufferLen, int rollLen)
enum IndexRep { kChar = 0, kByte = 1 };
Reporting/Browsing/Fixing Bugs and Features
All bug reports and feature requests for STAF are kept on SourceForge.
When you begin work on a bug or feature, set the "Assigned to" field to your userid. Make the changes and test them. Update the history file to describe the new feature or bug fix you made, making sure you reference the request ID. Commit your changes into CVS, specifying the request ID in the commit message. Then update the bug/feature, adding comments on the changes you made, specify the Resolution and Status, and submit your changes.
On Linux systems, you can use gdb to debug STAF, usually with more success using a debug version of STAF. Using gdb can be useful when a SIGSEGV problem is occurring.
Use gdb to debug STAF locally as follows:
gdb STAFProc
run
Use gdb to debug STAF remotely as follows:
gdb STAFProc run
Various commands that you might need while using gdb are:
Here are some commonly used links for STAF:
Appendix B: Common CVS Commands
Here are some of the common CVS commands that you will use. Use the 'man cvs' command to get more information about these CVS commands and others.
cvs updateCompares your directory tree with the tree in the CVS repository, by file, based on the directory that you are currently in. Execute this command from within your private source directory when you wish to update your copies of source files from changes that other developers have made to the source in the CVS repository. A -d option can be used to add any new directories. Each file that has changed will have one of the following codes which indicate how it was changed:
cvs add file...Add a new file or directory to the CVS repository, pending a 'cvs commit' on the same file. Can only be done from within sources created by a previous 'cvs checkout' invocation. (Does not directory affect repository; changes working directory.)
Note that if you are checking in a binary file (such as a gif or pdf file), you must add the -kb option to the add command. This indicates that the file is a binary file. This is important so that when updates are made to the file, cvs will not attempt to "merge" the 2 versions of the binary file, which may cause bad things to happen.
cvs checkoutMake a working directory of source files for editing. (Creates or changes working directory.) This is a necessary preliminary for most cvs work: creates your private copy of the source. You can also use a path relative to the source respository here. You can work with this copy without interfering with others' work. At least one subdirectory level is always created.
cvs diffShow differences between files in working directory and source repository, or between two revisions in source repository. (Does not change either repository or working directory.) Used to show the code changes. < in front of lines of code indicate that these lines have been removed and > in front of lines of code indicate that these lines have been added.
cvs commit -m "Enter a message here that describes the change including the bug/feature ID (#0123456)"Apply to the source repository changes, additions, and deletions from your working directory. (Changes repository.) Use this command when you wish to 'publish' your changes to other developers, by incorporating them in the source repository.
cvs logDisplay log information. (Does not change repository or working directory.)
cvs remove file...Use this command (after erasing any files listed)
cvs helpTo get help for a specific CVS command, for example update, type:
cvs --help update
Appendix C: New Developer Activities
When a new developer joins the STAF team, he/she must perform the following activities.
Join the Open Source STAF Development Project
Subscribe to Mailing Lists and Monitor Newsgroups
External and internal STAF customers can send questions to the STAF SourceForge mailing lists and forums, and internal IBM STAF customers can post questions on the AWE Newsgroup. Part of the job responsibilities of a STAF Developer is to monitor the newsgroups, the SourceForge Mailing Lists, and the SourceForge Forums and respond to any questions or support requests. STAF developers get notes sent to them when anyone sends a note to one of the mailing lists or posts a message on a forum. However, STAF developers must monitor the Newsgroups to check for any new postings.
Appendix D: Shutting Down STAF on Unix
Currently, there is a bug that occurs sometimes where STAF cannot be restarted after shutting it down via "STAF LOCAL SHUTDOWN SHUTDOWN". If this happens, perform the following:
killall -9 STAFProc
ps -ea | grep STAF
kill -9Replace
ps -ea | grep STAF
This is the end of the document.