TestFeaturesImpl.mesa
The Compute Server side of the Summoner.
Last Edited by: Bob Hagmann, May 3, 1985 9:08:55 am PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
DIRECTORY
Basics,
BasicTime,
Commander,
ComputeServerControl,
FS,
List,
IO,
ProcessProps,
Rope;
TestFeaturesImpl: CEDAR PROGRAM
IMPORTS ComputeServerControl, FS, List, IO, ProcessProps, Rope
= BEGIN
Variable Declarations
STREAM: TYPE = IO.STREAM;
ROPE: TYPE = Rope.ROPE;
Test Code
testFeatures1: Commander.CommandProc = {
in: STREAM = cmd.in;
out: STREAM = cmd.out;
err: STREAM = cmd.err;
commandLine: ROPE ← cmd.commandLine;
startWDIR, setToWDIR, tempRope: ROPE;
addWDir: List.AList;
fullFName, attachedTo: ROPE;
keep: CARDINAL;
bytes: INT;
created: BasicTime.GMT;
smallFileToCat: STREAM;
testExpandNameWithProcessProps: PROC [] = {
[fullFName: tempRope] ← FS.ExpandName[name: "foo.mesa"];
};
enumInfo: FS.InfoProc = {
out.PutL[LIST [
IO.rope["\n\t"],
IO.rope[fullFName],
IO.rope["\n\t\t"],
IO.rope[attachedTo],
IO.char[' ],
IO.card[keep],
IO.char[' ],
IO.int[bytes],
IO.char[' ],
IO.time[created]]];
RETURN[TRUE];
};
enumInfoONCE: FS.InfoProc = {
out.PutL[LIST [
IO.rope["\n\t"],
IO.rope[fullFName],
IO.rope["\n\t\t"],
IO.rope[attachedTo],
IO.char[' ],
IO.card[keep],
IO.char[' ],
IO.int[bytes],
IO.char[' ],
IO.time[created]]];
RETURN[FALSE];
};
enumInfoNEVER: FS.InfoProc = {
out.Put[IO.rope["
SHOULD NOT GET HERE"]];
RETURN[FALSE];
};
enumName: FS.NameProc = {
out.PutL[LIST [
IO.rope["\n\t"],
IO.rope[fullFName]]];
RETURN[TRUE];
};
enumNameONCE: FS.NameProc = {
out.PutL[LIST [
IO.rope["\n\t"],
IO.rope[fullFName]]];
RETURN[FALSE];
};
enumNameNEVER: FS.NameProc = {
out.Put[IO.rope["
SHOULD NOT GET HERE"]];
RETURN[FALSE];
};
echo the command line
out.Put[IO.rope[ "
command line: "]];
out.Put[IO.rope[commandLine]];
play with the default WDir
startWDIR ← FS.GetDefaultWDir[];
FS.SetDefaultWDir["users/hagmann.pa/Summoner/"];
setToWDIR ← FS.GetDefaultWDir[];
FS.SetDefaultWDir[startWDIR];
out.Put[IO.rope["
WDIR before and after SetDefaultWDir: "]];
out.Put[IO.rope[startWDIR]];
out.PutChar[' ];
out.Put[IO.rope[setToWDIR]];
IF Rope.Equal[startWDIR, "[]<>"] THEN FS.SetDefaultWDir["[]<>Summoner>"];
[fullFName: tempRope] ← FS.ExpandName[name: "///foo.mesa"];
out.Put[IO.rope["
ExpandName tests - ///foo.mesa: "], IO.rope[tempRope]];
[fullFName: tempRope] ← FS.ExpandName[name: "foo.mesa"];
out.Put[IO.rope["
ExpandName tests - foo.mesa, NIL: "], IO.rope[tempRope]];
addWDir ← List.PutAssoc[key: $WorkingDirectory , val: NARROW["///fi/", ROPE], aList: NIL];
ProcessProps.AddPropList[propList: addWDir, inner: testExpandNameWithProcessProps];
out.Put[IO.rope["
ExpandName tests - foo.mesa, NIL, ProcessProp = ///fi/: "], IO.rope[tempRope]];
[fullFName: tempRope] ← FS.ExpandName[name: "foo.mesa", wDir: "///fum/"];
out.Put[IO.rope["
ExpandName tests - foo.mesa, ///fum/: "], IO.rope[tempRope]];
tempRope ← FS.ConstructFName[ ["one", "two", "three", "four", "five", "six"], FALSE];
out.Put[IO.rope["
ConstructFName test - one through six: "], IO.rope[tempRope]];
out.Put[IO.rope["
WordsForPages for one page: "], IO.int[FS.WordsForPages[1]]];
[fullFName, attachedTo, keep, bytes, created] ← FS.FileInfo[name: "FS.bcd", wantedCreatedTime: BasicTime.nullGMT, remoteCheck: TRUE, wDir: "///Summoner/"] ;
out.PutL[LIST [
IO.rope["
FileInfo for FS.bcd, TRUE, ///Summoner/: "],
IO.rope[fullFName],
IO.rope["\n\t"],
IO.rope[attachedTo],
IO.char[' ],
IO.card[keep],
IO.char[' ],
IO.int[bytes],
IO.char[' ],
IO.time[created]]];
out.Put[IO.rope["
EnumerateForInfo for FSInterface*!h, ///Summoner/: "]];
FS.EnumerateForInfo[pattern: "FSInterface*!h", proc: enumInfo, wDir: "///Summoner/"];
out.Put[IO.rope["
EnumerateForInfo for FSInterface*!h, ///Summoner/ - ONCE-: "]];
FS.EnumerateForInfo[pattern: "FSInterface*!h", proc: enumInfoONCE, wDir: "///Summoner/"];
FS.EnumerateForInfo[pattern: "FSInterface.nosuchfile!h", proc: enumInfoNEVER, wDir: "///Summoner/"];
out.Put[IO.rope["
EnumerateForInfo for a non-existant file"]];
out.Put[IO.rope["
EnumerateForNames for FSInterface*!h, ///Summoner/: "]];
FS.EnumerateForNames[pattern: "FSInterface*!h", proc: enumName, wDir: "///Summoner/"];
out.Put[IO.rope["
EnumerateForNames for FSInterface*!h, ///Summoner/ - ONCE-: "]];
FS.EnumerateForNames[pattern: "FSInterface*!h", proc: enumNameONCE, wDir: "///Summoner/"];
FS.EnumerateForNames[pattern: "FSInterface.nosuchfile!h", proc: enumNameNEVER, wDir: "///Summoner/"];
out.Put[IO.rope["
EnumerateForNames for a non-existant file"]];
smallFileToCat ← FS.StreamOpen["smallFileToCat.txt"];
out.Put[IO.rope["
Type smallFileToCat on stdout
"]];
DO
out.PutChar[smallFileToCat.GetChar[! IO.EndOfStream => EXIT]];
ENDLOOP;
out.Put[IO.rope["

The first half of the tests are all done

"]];
};
ComputeServerControl.Register[key: "SummonerTestFeatures1", version: "1", proc: testFeatures1, doc: NIL, clientData: NIL];
END.
Bob Hagmann May 3, 1985 9:08:34 am PDT
changes to: ComputeServerControl