;; Function To Be Tested: . (MASTERSCOPE) (Programmer's Assistant Command) ;; ;; Source: Xerox Common Lisp Implementation Notes (Lyric Beta Release) ;; Section 20.2 (The Evaluator), Page 28 ;; Section: The Evaluator ;; ;; Created By: John Park ;; ;; Creation Date: Feb 25, 1987 ;; ;; Last Update: ;; ;; Filed As: {ERIS}test>exec>masterscope.u ;; ;; ;; Syntax: . &rest LINE ;; ;; Function Description: Make a MASTERSCOPE query. Masterscope is an interactive ;; program for analyzing and cross referencing user programs. It contains ;; facilities for analyzing user functions to determine what other functions are ;; called, how and where variables are bound, set, or referenced, as well as ;; which functions use particular record declarations. Masterscope is able to ;; analyze definitions directly from a file as well as in-core definitions. ;; ;; Argument(s): Masterscope commands (SEE IRM, Vol 3, Section 19) ;; ;; Returns: (SEE IRM, Vol 3, Section 19) ;; ;; Constraints/Limitations: Due to the nature of Programmer's Assistant commands, ;; testing them will not be totally automatic. Comments are incorporated within ;; each command file, which will be run by using the function bksysbuf. ;; Each test setup is titled "COMMAND-TEST-SETUP", which executes the command ;; string. The do-test form within the command file will return T or "test ;; failed" This test file requires TEDIT and MASTERSCOPE package ;; The tree structure of the functions being analyzed are as follows: ;; ;; Top-Function ;; | ;; Func-A------------------------Fun-B ;; | | ;; --------------------- -------------------- ;; | | | | | | ;; Func-A1 Func-A2 Func-A3 Func-B1 Func-B2 Func-B3 ;; | ;; -------------- ;; | | ;; Func-C1 Func-A1 ;; ;; Messages will be printed before each command in the command files is executed ;; for user monitoring. Test result is logged on ;; {eris}test>exec>test.report. (DO-TEST "MASTERSCOPE-TEST-SETUP" (PROGN (SETQ MESS1 "Now do-test will determine if correct results have been returned for the analysis of user functions...") (SETQ TEST-RESULT "{ERIS}TEST>EXEC>TEST.REPORT") (DEFUN R-FORMAT (STATUS) (FORMAT *OUTPUT* "~2%COMMAND:MASTERSCOPE~%STATUS: ~A DATE: ~A TESTER: ~A~%" STATUS (IL:DATE) IL:USERNAME)) (DEFUN TOP-FUNCTION NIL (AND (FUNC-A) (FUNC-B))) (DEFUN FUNC-A NIL (OR (FUNC-A1) (FUNC-A2) (FUNC-A3))) (DEFUN FUNC-B NIL (OR (FUNC-B1) (FUNC-B2) (FUNC-B3))) (DEFUN FUNC-A1 NIL T) (DEFUN FUNC-A2 NIL NIL) (DEFUN FUNC-A3 NIL T) (DEFUN FUNC-B1 NIL (AND (FUNC-C1)(FUNC-A1))) (DEFUN FUNC-B2 NIL NIL) (DEFUN FUNC-B3 NIL T) (DEFUN FUNC-C1 NIL NIL) (SETQ {CORE}WHO-CALLS "{CORE}WHO-CALLS") (SETQ {CORE}PATHS "{CORE}PATHS") (SETQ MASTERSCOPE-COMMAND-STRING "; Start analyzing functions in top-function . ANALYZE TOP-FUNCTION . ANALYZE FUNC-A . ANALYZE FUNC-B . ANALYZE FUNC-B1 . WHO CALLS FUNC-A1 (IF (EQUAL * '(FUNC-A FUNC-B1)) (SETQ FUNC-A1-CALL T) (SETQ FUNC-A1-CALL NIL)) . WHO CALLS TOP-FUNCTION (IF (EQUAL * NIL) (SETQ TOP-FUNC-CALL T) (SETQ TOP-FUNC-CALL NIL)) . WHO CALLS FUNC-A (IF (EQUAL * '(TOP-FUNCTION)) (SETQ FUNC-A-CALL T) (SETQ FUNC-A-CALL NIL)) . WHO CALLS FUNC-B2 (IF (EQUAL * '(FUNC-B)) (SETQ FUNC-B-CALL T) (SETQ FUNC-B-CALL NIL)) (DRIBBLE '{CORE}WHO-CALLS) . WHO CALLS WHO (DRIBBLE) (DRIBBLE '{CORE}PATHS) . SHOW PATHS TO FUNC-A1 FROM TOP-FUNCTION (DRIBBLE) ; analyzing the file that contains the previous masterscope interactions ; (who calls?) (SETQ CALL-LIST '(|func-b -- (func-b1 func-b2 func-b3)| |func-b1 -- (func-c1 func-a1)| |func-a -- (func-a1 func-a2 func-a3)| |top-function -- (func-a func-b)|)) (SETQ WHO-CALLS-FLG NIL) (SETQ WHO-CALLS (OPEN {CORE}WHO-CALLS)) (READ-LINE WHO-CALLS) (READ-LINE WHO-CALLS) (DOLIST (Y CALL-LIST) (IF (STRING-EQUAL Y (READ-LINE WHO-CALLS)) (PUSH T WHO-CALLS-FLG) (PUSH NIL WHO-CALLS-FLG))) (CLOSE WHO-CALLS) ; analyzing the file that contains the masterscope interaction (show paths) (SETQ PATHS (OPEN {CORE}PATHS)) (DO (( i 0 (1+ i))) ((= i 5) t) (READ-LINE PATHS)) (IF (AND (STRING-EQUAL (READ-LINE PATHS) '|1.func-a1 func-a top-function|) (STRING-EQUAL (READ-LINE PATHS) '|2. func-b1 func-b top-function|)) (SETQ PATHS-FLG T)(SETQ PATHS-FLG NIL)) (CLOSE PATHS) (DELETE-FILE '{CORE}PATHS) (DELETE-FILE '{CORE}WHO-CALLS) (FORMAT NIL MESS1) (DO-TEST 'MASTERSCOPE-TEST-RESULT (PROG2 (SETQ *OUTPUT* (OPEN TEST-RESULT :DIRECTION :OUTPUT :IF-EXISTS :APPEND)) (IF (AND (EQ FUNC-A1-CALL T) (EQ TOP-FUNC-CALL T) (EQ FUNC-A-CALL T) (EQ FUNC-B-CALL T) (EQ PATHS-FLG T) (NOTANY #'NULL WHO-CALLS-FLG)) (PROGN (R-FORMAT 'SUCCESS) T) (PROGN (R-FORMAT 'FAIL) NIL)) (CLOSE *OUTPUT*) ) ) ") (IL:BKSYSBUF MASTERSCOPE-COMMAND-STRING) ) ) STOP