background image
<< Client/Server Testing - Specifying the target | Client/Server Testing - Synchronizing threads with semaphores >>
Client/Server Testing - Alternative machine handle operator
<< Client/Server Testing - Specifying the target | Client/Server Testing - Synchronizing threads with semaphores >>
User's Guide
369
21 I
MPLEMENTING
C
LIENT
/S
ERVER
T
ESTING
Using 4Test's parallel processing features
// Valid machine handle operator use
for each sMachine in lsMachine
sMachine-> TextEditor.Search.Find.Pick
// Invalid machine handle operator use with method
if (sMachine->ProjX.DuplicateAlert.Exists())
Print ("Duplicate warning on {sMachine} recipient.")
If you need to use this kind of statement, use the alternative form of the
machine handle operator described below.
Alternative machine
handle operator
An alternative syntax for the machine handle operator is the bracket form:
[hMachine] Any4TestFunctionCall ()
where [hMachine] is a machine handle (or use [sMachine.]) For example, to
execute the SYS_SetDir function on the target machine specified by the
string sMachineA, you do this:
[sMachineA] SYS_SetDir (sDir)
The correct form of the invalid syntax shown above is:
// Invalid machine handle operator use
if ([sMachine]ProjX.DuplicateAlert.Exists())
Print ("Duplicate warning on {sMachine} recipient.")
To execute the SYS_SetDir function on the host machine, you can do the
following:
[hHost] SYS_SetDir (sDir)
You can also use this form of the machine handle operator with a function
that is not being used to return a value or with a method, as in the following
examples.
for each sMachine in lsMachine
[sMachine] FormatTest7 ()
for each sMachine in lsMachine
[sMachine] TextEditor.Search.Find.Pick
Protecting access to
global variables
When a new thread is spawned, 4Test creates a new copy of all local variables
and function arguments for it to use. However, all threads have equal access
to global variables. To avoid a situation in which multiple threads modify a
variable "simultaneously," you need to declare the variable as "shareable." A
shareable variable is available to only one thread at a time.
Note Instances where threads modify variables simultaneously will
generate unpredictable results. Errors of this kind are very hard to
detect. Make variables shareable wherever the potential for conflict
exists.