Test Script Services |
This section documents functions that may be required by applications. They are not typically used by test scripts.
A suite can contain multiple test scripts of different types. When TestManager executes a suite, a separate session is started for each type of script in the suite. Each session lasts until all scripts of the type have finished executing. Thus, if a suite contains three Visual Basic test scripts and six VU test scripts, two sessions are started and each remains active until all scripts of the respective types finish.
In a given suite run, a session can be run directly (inside the TestManager process space) or by a separate TSS server process (proxy). The latter happens only if the following two conditions are met:
rttssremote.lib
.
Applications can use the session functions listed in the following table to manage proxy TSS servers and sessions on behalf of test scripts. These functions are not needed for sessions that are directly executed by TestManager.
TSSConnect()
Connects to a TSS proxy server.
TSSContext()
Passes context information to a TSS server.
TSSDisconnect()
Disconnects from a TSS proxy server.
TSSServerStart()
Starts a TSS proxy server.
TSSServerStop()
Stops a TSS proxy server.
TSSShutdown()
Stops logging and initializes TSS.
Connects to a TSS proxy server.
s32TSSConnect
(char *host
, u16port
, s32id
)
This function exits with one of the following results:
TSS_NOOP
. A connection and ID had already been established for this execution thread.
port
.
TSS_SYSERROR
. A system error occurred. Call TSSErrorDetail() for information.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
For scripts that are executed by a proxy process rather than directly by the TSEE, this function must be called before any other TSS functions. This function is also required when a script (or TSEA) starts a new thread of execution.
The proxy TSS DLL uses host
and port
(the host and port parameters passed to SessionOpen()
in the TSEA) to establish a connection with the correct TSEE.
The direct TSS DLL ignores host
and port
, and associates the id
with the current execution thread. If the thread already had an ID, id
is ignored. (You cannot change id
.)
This example connects to a TSS server running on host 192.36.25.107. The port
is defined in the example for TSSServerStart().
s32 retVal = TSSConnect
("192.36.25.107",port,0);
Passes context information to a TSS server.
s32TSSContext
(ContextKeyctx
, void *value
)
ctx
The type of context information to pass: Can be one of the following:
value
The information of type
ctx
to pass.
This functionexits with one of the following results:
TSS_OK
. Success.
TSS_NOSERVER
. No previous successful call to TSSConnect()
.
TSS_INVALID
. The specified ctx
is invalid.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
This call is useful for test scripts that are executed by a stand-alone process -- outside the TestManager framework -- and that also make TSS calls. The call passes information, such as the log file name, that would be passed through shared memory if the script were executed by TestManager.
Test scripts that are executed by a proxy TSS server process should make this call immediately after TSSConnect(), before accessing any other TSS services. Otherwise, inconsistent results can occur.
ContextKey is defined as follows:
enum ContextKey { CTXT_workingDir, CTXT_datapoolDir, CTXT_timeZero, CTXT_todZero, CTXT_logDir CTXT_logFile CTXT_logData CTXT_testScript CTXT_style CTXT_sourceUID CTXT_END }; typedef enum ContextKey ContextKey;
This example passes a working directory to the current proxy TSS server.
s32 retVal = TSSContext
(CTXT_workingDir,"C:\temp");
Disconnects from a TSS proxy server.
void TSSDisconnect
(void)
This call closes the connection established by TSSCconnect()
and performs any required cleanup operations.
This example disconnects from the TSS server.
TSSDisconnect
();
s32TSSServerStart
(u16 *port
)
port
The listening port for the TSS server. If specified as
0
(recommended), the system chooses the port and returns its number to port
.
This function exits with one of the following results:
TSS_OK
. Success.
TSS_NOOP
. A TSS server was already listening on port
.
TSS_SYSERROR
. A system error occurred. Call TSSErrorDetail() for information.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
No TSS server is started if one is already running. A test script that is to be executed by a proxy server and that might be the first to execute should make this call.
This example starts a proxy TSS server on a system-designated port, whose number is returned to port
.
u16 port = 0;
s32 retVal = TSSServerStart
(&port);
s32TSSServerStop
(u16port
)
port
The port number that the TSS server to be stopped is listening on.
This functionexits with one of the following results:
TSS_OK
. Success.
TSS_NOOP
. No TSS server was listening on port
.
TSS_SYSERROR
. A system error occurred. Call TSSErrorDetail() for information.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
In a test suite with multiple scripts, only the last executed script should make this call.
This example stops a proxy TSS server that was started by the example for TSSServerStart().
s32 retval = TSSServerStop
(port);
Stops logging and initializes TSS.
s32 TSSShutdown
(void)
This function exits with one of the following results:
TSS_OK.
Success.
TSS_NOSERVER
. No previous successful call to TSSConnect()
.
TSS_INVALID
. The specified ctx
is invalid.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
This call stops logging functions, pauses a playback session, and initializes TSS to resume logging and executing the next task.
This example shuts down logging during session execution so that logging can be restarted for the next task.
s32 retval = TSSShutdown
();
Rational TestManager Extensibility Reference | Rational Software Corporation |
Copyright (c) 2003, Rational Software Corporation | http://www.rational.com support@rational.com info@rational.com |