test-guide.mss 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. @Make(article)
  2. @device(LPT)
  3. @style(Spacing 1)
  4. @use(Bibliography "<griss.docs>mtlisp.bib")
  5. @modify(enumerate,numbered=<@a. @,@i. >, spread 1)
  6. @modify(itemize,spread 1)
  7. @modify(description,leftmargin +2.0 inch,indent -2.0 inch)
  8. @LibraryFile(PSLMacrosNames)
  9. @comment{ The logos and other fancy macros }
  10. @pageheading(Left "Utah Symbolic Computation Group",
  11. Right "July 1982",
  12. Line "Operating Note No. 71"
  13. )
  14. @set(page=1)
  15. @newpage()
  16. @Begin(TitlePage)
  17. @begin(TitleBox)
  18. @center[
  19. @b(The PSL Bootstrap Test Files)
  20. M. L. Griss, S. Lowder, E. Gibson, E. Benson,
  21. R. R. Kessler, and G. Q. Maguire Jr.
  22. Utah Symbolic Computation Group
  23. Computer Science Department
  24. University of Utah
  25. Salt Lake City, Utah 84112
  26. (801)-581-5017
  27. @value(date)]
  28. @end(TitleBox)
  29. @begin(abstract)
  30. This note describes how use a suite of tests designed to exhaustively
  31. exercise all facets of the PSL bootstrap sequence. Each test is a step
  32. towards boostrapping a complete mini-LISP and then complete PSL.
  33. @end(abstract)
  34. @begin(ResearchCredit)
  35. Work supported in part by the National Science Foundation
  36. under Grant No. MCS-8204247, and by Lawrence Livermore Laboratories under
  37. Subcontract No. 7752601.
  38. @end(ResearchCredit)
  39. @end(TitlePage)
  40. @pageheading(Left "PSL Testing",
  41. Right "Page @Value(Page)"
  42. )
  43. @set(Page=1)
  44. @newpage()
  45. @section(Introduction)
  46. In order to accomplish the PSL bootstrap with a minimum of fuss, a carefully
  47. graded set of tests is being developed, to help pinpoint each error as
  48. rapidly as possible. This preliminary note describes the current status
  49. of the test files. The first phase requires the coding of an initial
  50. machine dependent I/O package and its testing using a familar system language.
  51. Then the code-generator macros can be succesively tested, making calls on this
  52. I/O package as needed. Following this is a series of graded SYSLISP files,
  53. each relying on the correct working of a large set of SYSLISP constructs.
  54. At the end of this sequence, a fairly complete "mini-LISP" is obtained.
  55. At last the complete PSL interpreter is bootstrapped, and a variety of
  56. PSL functional and timing tests are run.
  57. @section(Basic I/O Support)
  58. The test suite requires a package of I/O routines to read and print
  59. characters, and print integers. These support routines are usually written
  60. in a "foreign" language (call it "F"), such as PASCAL, C or FORTRAN; they
  61. could also be coded in LAP, using CMACROs to call operating system
  62. commands, if simple enough. (E.g., JSYS's on DEC-20, Traps on 68000, etc.).
  63. These routines typically are limited to using the user's terminal/console
  64. for input and output. Later steps in the bootstraping sequence introduce a
  65. more complete stream based I/O module, with file-IO.
  66. On some systems, it is appropriate to have a main routine written in "F"
  67. which initializes various things, and then calls the "LISP" entry point; on
  68. others, it is better to have "LISP" as the main routine, and have it call
  69. the initialization routines itself. In any event, it is best to first write
  70. a MAIN routine in "F", have it call a subroutine (called, say TEST), which
  71. then calls the basic I/O routines to test them. The documentation for the
  72. operating system should be consulted to determine the subroutine calling
  73. conventions. Often, the "F" compiler has an "ASSEMBLY Listing switch",
  74. which can be turned on to see how the standard "F" to "F" calling sequence
  75. is constructed, and to give some useful guidance to writing correct
  76. assembly code. This can also be misleading, if the assembler switch only
  77. shows part of the assembly code, thus the user is cautioned to examine
  78. both the code and the documentation.
  79. On directory PT: (which stands for /psl/tests or <PSL.TESTS>), or its
  80. subdirectories, we have a number of sample I/O packages, written in various
  81. languages: PASCAL, FORTRAN, C and DEC20 assembly code. Each has been used
  82. successfully with some PSL bootstrap. The primitives provided in these
  83. files are often named XXX-yyyy, where XXX is the machine name, and yyyy is
  84. the primitive, provided that these are legal symbols. Of course, the name
  85. XXX-yyyy may have to be changed to conform to "F" and the associated linker
  86. symbol conventions. Each name XXX-yyyy will be flagged as a
  87. "ForeignFunction", and called by a non-LISP convention.
  88. The following is a brief description of each primitive, and its use. For
  89. uniformity we assume each "foreign" primitive gets a single integer
  90. argument, which it may use, ignore, or change (VAR c:integer in PASCAL).
  91. @Comment{Is this assumed to be a WORD size quantity, i.e. on the 68000 a 32
  92. bit quantity or can it be a small integer???}
  93. The following routines ("yyyy") in LISP, will be associated with the
  94. corresponding "foreign" routine "XXX-yyyy" in an appropriate way:
  95. @begin(description)
  96. init(C)@\Called once to set up I/O channels, open devices, print welcome
  97. message, initialize timer. Ignores the argument C.
  98. Quit()@\Called to terminate execution; may close all open files. C is
  99. ignored.
  100. PutC(C)@\C is the ASCII equivalent of a character, and is printed out
  101. without line termination (I/O buffering may be needed). C=EOL=10 (ASCII LF)
  102. @Comment{does this mean that the character should appear right away, or can
  103. it wait till the EOL is sent???}
  104. will be used to signal end-of-line, C=EOF=26 (ASCII SUB) will be used to
  105. signal end of file.
  106. GetC()@\Returns the ASCII equivalent of the next input character;
  107. C=EOL=10 for end of line, and C=EOF=26 for end of file. Note it is
  108. assumed that GetC does not echo the character.
  109. TimC()@\Returns the runtime since the start of this program, in
  110. milli-seconds, unless micro-seconds is more appropriate. For testing
  111. purposes this routine could also print out the time since last called.
  112. PutI(C)@\Print C as an integer, until a SYSLISP based Integer printer that
  113. calls XXX-PutC works. This function is used to print integers in the
  114. initial tests before the full I/O implementation is ready.
  115. Err(C)@\Called in test code if an error occurs, and prints C as an
  116. error number. It should then call Quit() .
  117. @end(description)
  118. As a simple test of these routines implement in "F" the following. Based on
  119. the "MainEntryPointName!*" set in XXX-ASM.RED, and the decision as to
  120. whether the Main toutine is in "F" or in "LISP", XXX-MAIN() is the main
  121. routine or first subroutine called:
  122. @begin(verbatim)
  123. % MAIN-ROUTINE:
  124. CALL XXX-INIT(0);
  125. CALL XXX-MAIN(0);
  126. CALL XXX-QUIT(0);
  127. % XXX-MAIN(DUMMY):
  128. INTEGER DUMMY,C;
  129. CALL XXX-PUTI(1); % Print a 1 for first test
  130. CALL XXX-PUTC(10); % EOL to flush line
  131. CALL XXX-PUTI(2); % Second test
  132. CALL XXX-PUTC(65); % A capital "A"
  133. CALL XXX-PUTC(66); % A capital "B"
  134. CALL XXX-PUTC(97); % A lowercase "a"
  135. CALL XXX-PUTC(98); % A lowercase "b"
  136. CALL XXX-PUTC(10); % EOL to flush line
  137. CALL XXX-PUTI(3); % Third test, type in "AB<cr>"
  138. CALL XXX-GETC(C);
  139. CALL XXX-PUTC(C); % Should print A65
  140. CALL XXX-PUTI(C);
  141. CALL XXX-GETC(C);
  142. CALL XXX-PUTC(C); % Should print B66
  143. CALL XXX-PUTI(C);
  144. CALL XXX-GETC(C);
  145. CALL XXX-PUTI(C); % should print 10 and EOL
  146. CALL XXX-PUTC(C);
  147. CALL XXX-PUTI(4); % Last Test
  148. CALL XXX-ERR(100);
  149. CALL XXX-PUTC(26); % EOF to flush buffer
  150. CALL XXX-QUIT(0);
  151. % END
  152. @end(verbatim)
  153. For examples, see PT20:20IO.MAC for DEC-20 version, PHP:HP.TEXT for HP9836
  154. PASCAL version, PCR:shell for CRAY fortran version.
  155. @section(LAP and CMACRO Tests)
  156. After the basic XXX-ASM.RED file has been written and the XXX-CROSS.EXE has
  157. been built, and seems to be working, an exhastive set of CMACRO tests
  158. should be run. The emitted code should be carefully examined, and the
  159. XXX-CMAC.SL adjusted as seems necessary. Part of the CMACRO tests are to
  160. ensure that !*MOVEs in and out of the registers, and the ForeignFunction
  161. calling mechanism work.
  162. @section(SysLisp Tests)
  163. This set of tests involve the compilation to target assmbly code, the
  164. linking and execution of a series of increasingly more complex tests. The
  165. tests are organized as a set of modules, called by a main driver. Two of
  166. these files are machine dependent, associating convenient LISP names and
  167. calling conventions with the "Foreign" XXX-yyyy function, define
  168. basic data-spaces, define external definitions of them for inclusion, and
  169. also provide the appropriate MAIN routine, if needed. These files
  170. should probably be put on a separte subdirectory of PT: (e.g., PT20:,
  171. PT68:, etc.)
  172. The machine dependent files are:
  173. @begin(description)
  174. XXX-HEADER.RED@\Is a machine dependent "main" include file, read into each
  175. MAINn.RED file, to define the data-spaces needed, and perhaps define a main
  176. routine in LAP, and have the appropriate XXX-MAIN call the "FirstCall"
  177. function, used to start the body of the test. Also included are the
  178. interface routines to the "F" coded I/O package. providing a set of LISP
  179. entry-points to the XXX-yyy functions. This should be copied and edited
  180. for the new target machine as needed. Notice that in most cases, it simply
  181. defines "procedure yyyy(x); XXX-yyyy(x);", relying on "ForeignFunction"
  182. declaration of XXX-yyyy. Notice that "UndefinedFunction" is defined in
  183. LAP, to call Err, as appropriate. This will trap some erroneous calls,
  184. since a call to it is planted in all "unused" SYMFNC cells. Some effort to
  185. make it pick up the ID number of the offending undefined function (by
  186. carefully choosing the instructions to be planted in the function cell),
  187. will be a great help. Once coded and tested by running MAIN1, it need not
  188. be changed for the subsequent MAINn/SUBn combinations to work.
  189. XXX-TEST-GLOBAL-DATA.RED@\This contains a series of external declarations
  190. to correspond to the Global Data definitions in the above header file
  191. file. It is automatically included in all but the MAINn module via the
  192. "GlobalDataFileName!*" option of XXX-ASM.RED.
  193. @end(description)
  194. The machine independent test files and drivers are:
  195. @begin(description)
  196. MAIN1.RED@\Is a very simple driver, that calls Getc and Putc, does a few
  197. tests. It does an 'IN "XXX-HEADER.RED";'. The "FirstCall" procedure
  198. then calls "init", uses "putc" to print AB on one
  199. line. It should then print factorial 10, and some timings for 1000 calls
  200. on Factorial 9 and Tak(18,12,6). Build by iteself, and run with IO.
  201. @Comment{This seems to hide the assumption that 10! can be done in the
  202. integer size of the test implementation.??? }
  203. SUB2.RED@\Defines a simple print function, to print ID's, Integer's,
  204. Strings and Dotted pairs in terms of repeated calls on PutC. Defines
  205. TERPRI, PRIN1, PRIN2, PRINT, PRIN2T and a few other auxilliary print functions
  206. used in other tests. Tries to print "nice" list notation.
  207. MAIN2.RED@\Uses Prin2String to print a welcome message, solicit a sequence of
  208. characters to be input, terminated by "#". Watch how end-of-line is handled.
  209. Then Print is called, to check that TAG's are correctly recognized,
  210. by printing a LISP integer, an ID and 2 dotted pairs. Requires SUB2 and IO modules.
  211. SUB3.RED@\Defines a mini-allocator, with the functions CONS, XCONS and NCONS,
  212. GTHEAP, GTSTR. Requires primitives in SUB2 module.
  213. MAIN3.RED@\First Executes a Casetest, trying a variety of Branches and
  214. Defaults in the case staement. There a number of calls on Ctest with an
  215. integer from -1 to 12; Ctest tries to classify its argument using a case
  216. statement. ConsTest simply calls the mini-allocator version of CONS to build
  217. up a list and then prints it. Requires SUB2, SUB3 and IO modules.
  218. SUB4.RED@\Defines a mini-reader, with RATOM and READ. This mini-READ
  219. does not read vectors, and does not know about the escape character, ! .
  220. Requires SUB3, SUB2, and IO modules.
  221. MAIN4.RED@\The test loop calls
  222. RATOM, printing the internal representation of each token.
  223. Type in a series of id's, integer's, string'ss etc. Watch that same ID goes
  224. to same place. After typing a Q, goes into a READ-PRINT loop, until Q is
  225. again input. Requires SUB3, SUB2 and IO modules.
  226. SUB5.RED@\Defines a mini-EVAL. Does not permit user define functions.
  227. Can eval ID's, numbers, and simple forms. No LAMBDA expressions.
  228. FEXPR Functions known are: QUOTE, SETQ and LIST.
  229. Can call any compiled EXPR, with upto 4 arguments. Rather inefficient, but
  230. could be used for quick bootstrap.
  231. Requires SUB4, SUB3, SUB2 and I/O.
  232. MAIN5.RED@\Tests the IDAPPLY constructs, and FUNBOUNDP. Then starts a
  233. mini-READ-EVAL-PRINT loop. Requires SUB5, SUB4, SUB3, SUB2 and IO modules.
  234. Note that input ID's are not case raised, so input should be in UPPERCASE
  235. for builtin functions. Terminates on Q input.
  236. SUB6.RED@\Defines a more extensive set of primitives to support the
  237. mini-EVAL, including LAMBDA expressions, and user defined EXPR and FEXPR
  238. functions. Can call any compiled EXPR, with up to 4 arguments. COND,
  239. WHILE, etc. are defined. Requires SUB5, SUB4, SUB3, SUB2 and I/O.
  240. MAIN6.RED@\Tests the full PSL BINDING module (PI:BINDING.RED).
  241. Also includes the standard PSL-TIMER.RED (describd below), which must be
  242. driven by hand, since file I/O is not yet present.
  243. Requires SUB6,SUB5, SUB4, SUB3, SUB2 and IO modules.
  244. Note that input ID's are not case raised, so input should be in UPPERCASE
  245. for builtin functions. Terminates on Q input.
  246. SUB7.RED@\A set of routines to define a minimal file-io package, loading
  247. the machine independent files: PT:SYSTEM-IO.RED and PT:IO-DATA.RED, and a
  248. machine dependent file XXX-SYSTEM-IO.RED. The latter file defines
  249. primitives to OPEN and CLOSE files, and read and write RECORDS of some
  250. size. The following definitions are used in the routines:
  251. @begin(verbatim)
  252. FileDescriptor: A machine dependent word to
  253. references an open file.
  254. FileName: A Lisp string
  255. @end(verbatim)
  256. @begin(description)
  257. SYSCLEARIO()@\Called by Cleario to do any machine specific initialization
  258. needed, such as clearing buffers, initialization tables, setting interrupt
  259. characters, etc.
  260. SysOpenRead(Channel,FileName)@\Open FileName for input and return a file
  261. descriptor used in later references to the file. Channel may be used to
  262. index a table of "unit" numbers in FORTRAN-like systems.
  263. SysOpenWrite(Channel,FileName)@\Open FileName for Output and return a file
  264. descriptor used in later references to the file. Channel may be used to
  265. index a table of "unit" numbers in FORTRAN-like systems.
  266. SysReadRec(FileDescriptor,StringBuffer)@\Read from the FileDescriptor, a
  267. record into the StringBuffer. Return the length of the string read.
  268. SysWriteRec (FileDescriptor, StringToWrite, StringLength)@\ StringLength
  269. characters from StringToWrite from the first position.
  270. SysClose (FileDescriptor)@\Close FileDescriptor, allowing
  271. it to be reused.
  272. SysMaxBuffer(FileDesc)@\Return a number to allocate the file-buffer
  273. as a string; this should be maximum for this descriptor.
  274. @end(description)
  275. MAIN7.RED@\Is an interface to the Mini-Eval in SUB5.RED and SUB6.RED
  276. and defines an (IOTEST) function that should be called. Other functions to
  277. try are (OPEN "foo" 'OUTPUT), (WRS n), (RDS n) etc. Note also that
  278. XXX-HEADER will have to be changed at this point to have GETC and PUTC
  279. use the IndependentReadChar and IndependentWriteChar.
  280. FIELD.RED@\A a set of extensive tests of the Field and Shift functions.
  281. Needs a WCONST BitsPerWord defined in XXX-HEADER.RED. Build by itself,
  282. and execute with the IO support.
  283. @end(description)
  284. Test set "n" is run by using a set of command files to set up
  285. a multi-module program. These files are stored on the
  286. approriate subdirectory (PT20: for the DEC20). Note that each module
  287. usually produces 2-3 files ("code", "data" and "init")
  288. @begin(Enumerate)
  289. First Connect to the Test subdirectory for XXX:
  290. @verbatim[
  291. @@CONN PTxxx:]
  292. Then initialize a fresh symbol table for program MAINn, MAINn.SYM:
  293. @verbatim[
  294. @@MIC FRESH MAINn]
  295. Now successively compile each module, SUB2..SUBn
  296. @verbatim[
  297. @@MIC MODULE SUB2,MAINn
  298. @@MIC MODULE SUB3,MAINn
  299. @@MIC MODULE SUBn,MAINn]
  300. Now compile the MAIN program itself
  301. @verbatim[
  302. @@MIC MAIN MAINn]
  303. As appropriate, compile or assemble the output "F" language modules
  304. (after shipping to the remote machine, removing tabs, etc..). Then
  305. "link" the modules, with the XXX-IO support, and execute. On the
  306. DEC-20, the
  307. @verbatim[
  308. @@EX @@MAINn.CMD
  309. command files are provided as a guide]
  310. See the Appendix (file PT20:20-TEST.OUTPUT) for an example of the
  311. output on the DEC-20.
  312. @end(enumerate)
  313. @section(Mini PSL Tests)
  314. The next step is to start incorporating portions of the PSL kernel into the
  315. test series (the "full" Printer, the "full" reader, the "full" Allocator,
  316. the "full" Eval, etc.), driving each with more comprehensive tests. Most of
  317. these should just "immediately" run. There some peices of Machine specific
  318. code that have to be written (in LAP or SYSLISP), to do channel I/O,
  319. replacing the simple XXX-IO; to do fast APPLY; Fluid Binding and
  320. Arithmetic. This set of tests will help check these peices out before
  321. getting involved with large files.
  322. @section(Full PSL Tests)
  323. Now that PSL seems to be running, a spectrum of functional tests and timing
  324. tests should be run to catch any oversights, missing modules or bugs, and as a
  325. guide to optimization. The following tests exist:
  326. @Description[
  327. PSLTEST.SL@\A fairly comprehensive test of the Standard LISP subset of PSL.
  328. Do (DSKIN "pt:psltest.sl"). There are a few tests of the error mechanism that
  329. have to be "pushed" through for a full test.
  330. MATHLIB.TST@\A series of tests of MATHLIB. First LAOD MATHLIB; into RLISP,
  331. then do IN "MATHLIB.TST"; .
  332. PSL-TIMER.SL, TIME-PSL.SL@\A standard timimg test covering PSL basics.
  333. Compile PSL-TIMER.SL into kernel, or with resident compiler, then
  334. (LAPIN "PT:TIME-PSL.TEST").
  335. ]
  336. @section(References)
  337. @bibliography
  338. @NewPage()
  339. @appendix(Sample DEC-20 Output)
  340. @begin(verbatim)
  341. @include(PT20:20-TEST.OUTPUT)
  342. @end(verbatim)