XMesaCmplr8:
PROGRAM
IMPORTS Cmplr8Mntr1Defs, Cmplr8Mntr2Defs, RunRegressions, XMesaProcs =
BEGIN
filename: LONG STRING ← "XMesaCmplr8"L;
XMesaCall8: PROCEDURE = {
XMesaProcs.PrintCR;
XMesaProcs.PrintS[filename];
XMesaProcs.PrintCR;
XMesa8a[]; --FORK and JOIN
XMesa8b[]; --FORK and JOIN cont'd
XMesa8c[]; --MONITORS
<< This test is just plain broken - it's inherently timing dependent
XMesa8d[]; --CV's
>>
XMesaProcs.PrintS["Done"L];
XMesaProcs.PrintCR;
}; --end of XMesaCall8
XMesa8a:
PROCEDURE = {
--FORK and JOIN
str: LONG STRING ← "This is a test of the FORK and JOIN constructs";
numOfChar, numOfSpace, numofA, numOfE: CARDINAL ← 0;
p: PROCESS RETURNS [CARDINAL];
q: PROCESS RETURNS [CARDINAL, CARDINAL];
InspectString:
PROCEDURE [s:
LONG
STRING] =
BEGIN --Count how many letters the string contains
p ← FORK CountSpaces[str];
numOfSpace ← 100; --test by setting the value arbitrarily
numOfChar ← s.length;
numOfSpace ← JOIN p;
END;
CheckForSpecials:
PROCEDURE [s:
LONG
STRING] =
BEGIN
q ← FORK CountAandE[str];
numOfChar ← s.length;
[numofA, numOfE] ← JOIN q;
END;
CountSpaces:
PROCEDURE [s:
LONG
STRING]
RETURNS [
CARDINAL] =
BEGIN --Count how many blank spaces the string contains
c: CHARACTER;
si: CARDINAL ← 0;
num: CARDINAL ← 0;
UNTIL si = s.length
DO
c ← s[si]; si ← si + 1; IF c = ' THEN num ← num + 1; ENDLOOP;
RETURN[num];
END;
CountAandE:
PROCEDURE [s:
LONG
STRING]
RETURNS [
CARDINAL,
CARDINAL] =
BEGIN --Count how many blank spaces the string contains
c: CHARACTER;
si: CARDINAL ← 0;
num1: CARDINAL ← 0;
num2: CARDINAL ← 0;
UNTIL si = s.length
DO
c ← s[si];
si ← si + 1;
IF c = 'a THEN num1 ← num1 + 1;
IF c = 'e THEN num2 ← num2 + 1;
ENDLOOP;
RETURN[num1, num2];
END;
InspectString[str];
IF numOfChar # 46 THEN XMesaProcs.PutFailMessage[3810, filename];
IF numOfSpace # 9 THEN XMesaProcs.PutFailMessage[3830, filename];
numOfChar ← 0;
CheckForSpecials[str];
IF numofA # 2 THEN XMesaProcs.PutFailMessage[3850, filename];
IF numOfE # 2 THEN XMesaProcs.PutFailMessage[3870, filename];
};
XMesa8b:
PROCEDURE = {
--FORK and JOIN cont'd
flag1, flag2: BOOL ← FALSE;
p: PROCESS;
Proc1: PROCEDURE = {flag1 ← TRUE; };
p ← FORK Proc1;
flag2 ← TRUE;
JOIN p;
IF flag2 # TRUE THEN XMesaProcs.PutFailMessage[3865, filename];
IF flag1 # TRUE THEN XMesaProcs.PutFailMessage[3875, filename];
};
XMesa8c:
PROCEDURE = {
--MONITORS
p, q, r: PROCESS;
flag: BOOL ← FALSE;
proc1:
PROCEDURE =
BEGIN
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.Activate;
END;
proc2:
PROCEDURE =
BEGIN
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.DeActivate;
Cmplr8Mntr1Defs.Activate;
END;
proc3:
PROCEDURE =
BEGIN
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.DeActivate;
Cmplr8Mntr1Defs.DeActivate;
END;
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.DeActivate;
flag ← Cmplr8Mntr1Defs.Inspect[];
IF flag # TRUE THEN XMesaProcs.PutFailMessage[3890, filename];
p ← FORK proc1;
Cmplr8Mntr1Defs.DeActivate;
Cmplr8Mntr1Defs.DeActivate;
JOIN p;
flag ← FALSE;
flag ← Cmplr8Mntr1Defs.Inspect[];
IF flag # TRUE THEN XMesaProcs.PutFailMessage[3910, filename];
p ← FORK proc1;
q ← FORK proc2;
r ← FORK proc3;
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.Activate;
Cmplr8Mntr1Defs.DeActivate;
JOIN p;
JOIN q;
JOIN r;
flag ← FALSE;
flag ← Cmplr8Mntr1Defs.Inspect[];
IF flag # TRUE THEN XMesaProcs.PutFailMessage[3930, filename];
};
XMesa8d:
PROCEDURE = {
newTicket: CARDINAL ← 0;
p: PROCESS;
FOR begin: INTEGER IN [0..10] DO newTicket ← Cmplr8Mntr2Defs.AllocateTicket[]; ENDLOOP;
IF newTicket # 100 THEN XMesaProcs.PutFailMessage[3950, filename];
IF newTicket # Cmplr8Mntr2Defs.nullTicket
THEN
XMesaProcs.PutFailMessage[3980, filename];
IF Cmplr8Mntr2Defs.flag # TRUE THEN XMesaProcs.PutFailMessage[3990, filename];
Cmplr8Mntr2Defs.FreeTicket[];
p ← FORK Cmplr8Mntr2Defs.FreeTicket[];
newTicket ← Cmplr8Mntr2Defs.AllocateTicket[];
IF newTicket # Cmplr8Mntr2Defs.nullTicket
THEN
XMesaProcs.PutFailMessage[3995, filename];
JOIN p;
IF newTicket # 9 THEN XMesaProcs.PutFailMessage[4000, filename];
IF Cmplr8Mntr2Defs.flag #
FALSE
THEN
XMesaProcs.PutFailMessage[4010, filename];
};
mainline
RunRegressions.RegisterTest[XMesaCall8, "test8"];
END...