background image
<< Client/Server Testing - The parallel statement | Client/Server Testing - Alternative machine handle operator >>
Client/Server Testing - Specifying the target
<< Client/Server Testing - The parallel statement | Client/Server Testing - Alternative machine handle operator >>
368
User's Guide
21 I
MPLEMENTING
C
LIENT
/S
ERVER
T
ESTING
Using 4Test's parallel processing features
Specifying the target
While the typical purpose for a thread is to direct test operations to a
particular test machine, you have total flexibility as to which machine is
being driven by a particular thread at any point in time. For example, in the
code below, the spawn statement starts a thread for each machine in a
predefined list of test machines. The SetMachine command directs the code
in that thread to the Agent on the specified machine. But the ["server"]
machine handle operator directs the code in the doThis function to the
machine named "server." The code following the doThis invocation
continues to be sent to the sMachine specified in the SetMachine command.
for each smachine in lsMachine
spawn // start thread for each sMachine
SetMachine (sMachine)
// ... code executed on sMachine
["server"]doThis() // code executed on "server"
// ...continue with code for sMachine
rendezvous
Note that while the machine handle operator takes only a machine handle,
4Test implicitly casts the string form of the Agent machine's name as a
machine handle and so the machine name is effectively the same as a
machine handle.
More about machine
handle operator
You can use the SetMachine function to change target machines for an entire
block of code. To specify the target machine for a single command, use the
machine handle operator on the command. There are two forms of this
operator: the arrow form (sMachine->) and the bracket form ([sMachine]).
For example, to execute the SYS_SetDir function on the target machine
specified by the sMachine1 variable, you do this:
sMachine1->SYS_SetDir (sDir)
Note To allow you to conveniently perform system related functions
(SYS_) on the host, you can preface the function call with the
machine handle operator, specifying the globally defined constant
hHost as the argument to the operator. For example, to set the
working directory on the host machine to c:\mydir, you do this:
hHost->SYS_SetDir ("c:\mydir")
You can use this syntax with a method call, for example:
sMachine-> TextEditor.Search.Find.Pick
But when invoking a method, this form of the machine handle must be the
first token in the statement. The following examples show valid and invalid
syntax: