Test Script Services |
You can use the advanced functions to perform timing calculations, logging operations, and internal variable initialization functions. TestManager performs these operations on behalf of scripts in a safe and efficient manner. Consequently, the functions need not and usually should not be performed by individual test scripts.
The following table lists the advanced functions.
TSSInternalVarSet
() Sets the value of an internal variable.
TSSLogCommand
() Logs a command event.
TSSThinkTime
() Calculates a think-time average.
Sets the value of an internal variable.
s32TSSInternalVarSet
(IVKeyinternVar
, IVValueivVal
)
internVar
The internal variable to operate on. Internal variables and their values are listed in the table startingon page283. See page59 for the IVKey and page60 for the IVValue definitions.
ivVal
The new value for
internVar
.
The function exits with one of the following results:
TSS_OK.
Success.
TSS_NOSERVER
. No previous successful call to TSSConnect()
.
TSS_INVALID
. The timer label is invalid, or there is no unlabeled timer to stop.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
The values of some internal variables affect think-time calculations and the contents of log events. Setting a value incorrectly could cause serious misbehavior in a script.
This example sets IV_cmdcnt
to 0.
s32 retVal = TSSInternalVarSet
(IV_cmdcnt,0);
s32TSSLogCommand
(char *name
, char *label
, s16result
, char *description
, s32starttime
, s32endtime
, char *logdata
, s32propertyCount
, NamedValue *property
)
This function exits with one of the following results:
TSS_OK.
Success.
TSS_NOSERVER
. No previous successful call to TSSConnect()
.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
The value of IV_cmdcnt
is logged with the event.
The command name and label entered with TSS
CommandStart() are logged, and the run state is restored to the value that existed prior to the TSS
CommandStart() call.
An event and any data associated with it are logged only if the specified result
preference matches associated settings in the EVAR_LogData_control
or EVAR_LogEvent_control
environment variables. Alternatively, the logging preference may be set with the EVAR_Log_level
and EVAR_Record_level
environment variables. The TSS_LOG_RESULT_STOPPED, TSS_LOG_RESULT_COMPLETED, and TSS_LOG_RESULT_UNEVALUATED preferences are intended for internal use.
NamedValue is defined as follows:
typedef struct { char *Name; char *Value; } NamedValue;
This example logs a message for a login script.
s32 retVal = TSSLogCommand
("Login", "initTimer",
TSS_LOG_RESULT_PASS,"Command timer failed", 0, 0,"Login command
completed", NULL);
TSS
CommandStart(), TSS
CommandEnd()
Calculates a think-time average.
s32TSSThinkTime
(s32thinkAverage
)
thinkAverage
If specified as 0, the number of milliseconds stored in the
ThinkAvg
environment variable is entered. Otherwise, the value specified overrides ThinkAvg
.
On success, this function returns a calculated think-time average. A negative exit value indicates an error. Call TSSErrorDetail() for more information.
This call calculates and returns a think time using the same algorithm as TSSThink(). But unlike TSSThink(), this call inserts no pause into a script.
This function could be useful in a situation where a test script calls another program that, as a matter of policy, does not allow a calling program to set a delay in execution. In this case, the called program would use TSSThinkTime() to recalculate the delay requested by TSSThink()
before deciding whether to honor the request.
This example calculates a pause based on a think-time average of 5000 milliseconds.
ctime = `tsscmd GetTime`IVValue iv;
iv.ivInt = TSSGetTime;
TSSInternalVarSet (IV_fcs_ts, iv);
TSSInternalVarSet (IV_lcs_ts, iv);
TSSInternalVarSet (IV_fcr_ts, iv);
TSSInternalVarSet (IV_lcr_ts, iv);
s32 pause = TSSThinkTime
(5000);
Rational TestManager Extensibility Reference | Rational Software Corporation |
Copyright (c) 2003, Rational Software Corporation | http://www.rational.com support@rational.com info@rational.com |