2 * This program tests the external queue interface of Regina
3 * It runs num_clients instances of itself, each instance will create a
4 * named queued. For even numbered instances, lines will be queued
5 * FIFO; odd numbered instances will be queued LIFO.
6 * Once each instance queues its lines, it will read lines off
7 * another stack; created by its opposite instance.
8 * Opposite instances are eg. instance 1 and num_clients, 2 and 48, etc
11 parse source sys env prog
12 num_clients
= 50 /* 50 */
13 num_lines
= 10 /* 100 */
17 if stream( "./rexx", "C", "FSTAT" ) \
= "" then
19 if stream( "../rexx", "C", "FSTAT" ) \
= "" then
21 Do i
= 1 To num_clients
22 Address System cmd prog i
'&'
28 * Set up the list of opposites...
30 Do i
= 1 To num_clients
31 opposite
.i
= 1+(num_clients
-i
)
35 If instance
// 2 = 0 Then order
= 'fifo'
37 call RxQueue 'Set', Rxqueue('Create', 'QUEUE'instance
'@')
38 /* Say '***Creating queue' Rxqueue('Create', 'QUEUE'instance'@' ) */
40 * push or queue num_lines lines onto our queue
43 line = 'line'i
'from instance' instance
44 /* Say '***Going to put <'line'> on queue:' order */
45 If order
= 'fifo' Then Queue line
49 * Sleep for 10 seconds, then find our opposite, and
50 * set our default queue to its queue, and read off
51 * the the lines, checking they are in the correct
52 * order and the correct contents
56 Say '***Setting queue. Previous was:' rxqueue('Set', 'QUEUE'opposite.instance'@' )
57 Say '***Getting queue. Now:' rxqueue('Get')
59 Call rxqueue 'Set', 'QUEUE'opposite
.instance
'@'
61 * The order of the lines is the opposite to
62 * the order in which we put our lines on our queue
64 If order
= 'lifo' Then
67 * PULL the lines off the stack, and check them
68 * they should be in FIFO order,
72 exp
= 'line'i
'from instance' opposite
.instance
73 If line \
= exp
Then Call Abort
line, exp
79 * PULL the lines off the stack, and check them
80 * they should be in LIFO order,
82 Do i
= num_lines
To 1 By -1
84 exp
= 'line'i
'from instance' opposite
.instance
85 If line \
= exp
Then Call Abort
line, exp
89 * Cleanup up our opposite's queue
91 Call Rxqueue 'Delete', 'QUEUE'opposite
.instance
'@'
92 Say 'Instance' instance
'finished.'
96 Abort: Procedure Expose instance
98 say '--------------------------------------------------------------------'
99 Say 'Error validating instance' instance
'. Got <'line'> Expecting <'exp
'>'
100 Call Rxqueue 'Delete', 'QUEUE'opposite
.instance
'@'
101 say '--------------------------------------------------------------------'