0000: 0a 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30 .;; Copyright 20
0010: 30 36 2d 32 30 31 31 2c 20 4d 61 74 74 68 65 77 06-2011, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b Welland..;; .;;
0030: 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 This program i
0040: 73 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65 s made available
0050: 20 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47 under the GNU G
0060: 50 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f PL version 2.0 o
0070: 72 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53 r.;; greater. S
0080: 65 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79 ee the accompany
0090: 69 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47 ing file COPYING
00a0: 20 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b for details..;;
00b0: 20 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72 .;; This progr
00c0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65 am is distribute
00d0: 64 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41 d WITHOUT ANY WA
00e0: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20 RRANTY; without
00f0: 65 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70 even the.;; imp
0100: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 lied warranty of
0110: 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 MERCHANTABILITY
0120: 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 or FITNESS FOR
0130: 41 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20 A PARTICULAR.;;
0140: 20 50 55 52 50 4f 53 45 2e 0a 0a 3b 3b 20 20 73 PURPOSE...;; s
0150: 74 72 66 74 69 6d 65 28 27 25 6d 2f 25 64 2f 25 trftime('%m/%d/%
0160: 59 20 25 48 3a 25 4d 3a 25 53 27 2c 27 6e 6f 77 Y %H:%M:%S','now
0170: 27 2c 27 6c 6f 63 61 6c 74 69 6d 65 27 29 0a 0a ','localtime')..
0180: 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20 74 65 ;; register a te
0190: 73 74 20 72 75 6e 20 77 69 74 68 20 74 68 65 20 st run with the
01a0: 64 62 0a 28 64 65 66 69 6e 65 20 28 72 65 67 69 db.(define (regi
01b0: 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 ster-run db keys
01c0: 29 20 3b 3b 20 74 65 73 74 2d 6e 61 6d 65 29 0a ) ;; test-name).
01d0: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 74 72 (let* ((keystr
01e0: 20 20 20 20 28 6b 65 79 73 2d 3e 6b 65 79 73 74 (keys->keyst
01f0: 72 20 6b 65 79 73 29 29 0a 09 20 28 63 6f 6d 6d r keys)).. (comm
0200: 61 20 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 a (if (> (le
0210: 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20 22 2c ngth keys) 0) ",
0220: 22 20 22 22 29 29 0a 09 20 28 61 6e 64 73 74 72 " "")).. (andstr
0230: 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e 67 (if (> (leng
0240: 74 68 20 6b 65 79 73 29 20 30 29 20 22 20 41 4e th keys) 0) " AN
0250: 44 20 22 20 22 22 29 29 0a 09 20 28 76 61 6c 73 D " "")).. (vals
0260: 6c 6f 74 73 20 20 28 6b 65 79 73 2d 3e 76 61 6c lots (keys->val
0270: 73 6c 6f 74 73 20 6b 65 79 73 29 29 20 3b 3b 20 slots keys)) ;;
0280: 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20 28 6b 65 79 ?,?,? ..... (key
0290: 76 61 6c 6c 73 74 20 28 6b 65 79 73 2d 3e 76 61 vallst (keys->va
02a0: 6c 6c 69 73 74 20 6b 65 79 73 29 29 20 3b 3b 20 llist keys)) ;;
02b0: 65 78 74 72 61 63 74 73 20 74 68 65 20 76 61 6c extracts the val
02c0: 75 65 73 20 66 72 6f 6d 20 72 65 6d 61 69 6e 64 ues from remaind
02d0: 65 72 20 6f 66 20 28 61 72 67 76 29 0a 09 20 28 er of (argv).. (
02e0: 72 75 6e 6e 61 6d 65 20 20 20 28 67 65 74 2d 77 runname (get-w
02f0: 69 74 68 2d 64 65 66 61 75 6c 74 20 22 3a 72 75 ith-default ":ru
0300: 6e 6e 61 6d 65 22 20 23 66 29 29 0a 09 20 28 73 nname" #f)).. (s
0310: 74 61 74 65 20 20 20 20 20 28 67 65 74 2d 77 69 tate (get-wi
0320: 74 68 2d 64 65 66 61 75 6c 74 20 22 3a 73 74 61 th-default ":sta
0330: 74 65 22 20 22 6e 6f 22 29 29 0a 09 20 28 73 74 te" "no")).. (st
0340: 61 74 75 73 20 20 20 20 28 67 65 74 2d 77 69 74 atus (get-wit
0350: 68 2d 64 65 66 61 75 6c 74 20 22 3a 73 74 61 74 h-default ":stat
0360: 75 73 22 20 22 6e 2f 61 22 29 29 0a 09 20 28 61 us" "n/a")).. (a
0370: 6c 6c 76 61 6c 73 20 20 20 28 61 70 70 65 6e 64 llvals (append
0380: 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65 20 73 (list runname s
0390: 74 61 74 65 20 73 74 61 74 75 73 20 75 73 65 72 tate status user
03a0: 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20 ) keyvallst))..
03b0: 28 71 72 79 76 61 6c 73 20 20 20 28 61 70 70 65 (qryvals (appe
03c0: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65 nd (list runname
03d0: 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20 ) keyvallst))..
03e0: 28 6b 65 79 3d 3f 73 74 72 20 20 28 73 74 72 69 (key=?str (stri
03f0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 ng-intersperse (
0400: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 28 map (lambda (k)(
0410: 63 6f 6e 63 20 28 6b 65 79 3a 67 65 74 2d 66 69 conc (key:get-fi
0420: 65 6c 64 6e 61 6d 65 20 6b 29 20 22 3d 3f 22 29 eldname k) "=?")
0430: 29 20 6b 65 79 73 29 20 22 20 41 4e 44 20 22 29 ) keys) " AND ")
0440: 29 29 0a 20 20 20 20 3b 3b 20 28 70 72 69 6e 74 )). ;; (print
0450: 20 22 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22 "keys: " keys "
0460: 20 61 6c 6c 76 61 6c 73 3a 20 22 20 61 6c 6c 76 allvals: " allv
0470: 61 6c 73 20 22 20 6b 65 79 76 61 6c 6c 73 74 3a als " keyvallst:
0480: 20 22 20 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20 " keyvallst).
0490: 20 20 28 70 72 69 6e 74 20 22 4e 4f 54 45 3a 20 (print "NOTE:
04a0: 75 73 69 6e 67 20 6b 65 79 20 22 20 28 73 74 72 using key " (str
04b0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 ing-intersperse
04c0: 6b 65 79 76 61 6c 6c 73 74 20 22 2f 22 29 20 22 keyvallst "/") "
04d0: 20 66 6f 72 20 74 68 69 73 20 72 75 6e 22 29 0a for this run").
04e0: 20 20 20 20 28 69 66 20 28 61 6e 64 20 72 75 6e (if (and run
04f0: 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c name (null? (fil
0500: 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29 28 ter (lambda (x)(
0510: 6e 6f 74 20 78 29 29 20 6b 65 79 76 61 6c 6c 73 not x)) keyvalls
0520: 74 29 29 29 20 3b 3b 20 74 68 65 72 65 20 6d 75 t))) ;; there mu
0530: 73 74 20 62 65 20 61 20 62 65 74 74 65 72 20 77 st be a better w
0540: 61 79 20 74 6f 20 22 61 70 70 6c 79 20 61 6e 64 ay to "apply and
0550: 22 0a 09 28 6c 65 74 20 28 28 72 65 73 20 23 66 "..(let ((res #f
0560: 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c )).. (apply sql
0570: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 ite3:execute db
0580: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 (conc "INSERT OR
0590: 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e IGNORE INTO run
05a0: 73 20 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65 s (runname,state
05b0: 2c 73 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76 ,status,owner,ev
05c0: 65 6e 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20 ent_time" comma
05d0: 6b 65 79 73 74 72 20 22 29 20 56 41 4c 55 45 53 keystr ") VALUES
05e0: 20 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 (?,?,?,?,strfti
05f0: 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 22 20 me('%s','now')"
0600: 63 6f 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22 comma valslots "
0610: 29 3b 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29 );")... allvals)
0620: 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74 .. (apply sqlit
0630: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 e3:for-each-row
0640: 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64 .. (lambda (id
0650: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 65 ).. (set! re
0660: 73 20 69 64 29 29 0a 09 20 20 20 64 62 0a 09 20 s id)).. db..
0670: 20 20 28 6c 65 74 20 28 28 71 72 79 20 28 63 6f (let ((qry (co
0680: 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46 52 nc "SELECT id FR
0690: 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 28 72 OM runs WHERE (r
06a0: 75 6e 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74 unname=? " andst
06b0: 72 20 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22 29 r key=?str ");")
06c0: 29 29 0a 09 20 20 20 20 20 3b 3b 20 28 70 72 69 )).. ;; (pri
06d0: 6e 74 20 22 71 72 79 3a 20 22 20 71 72 79 29 20 nt "qry: " qry)
06e0: 0a 09 20 20 20 20 20 71 72 79 29 0a 09 20 20 20 .. qry)..
06f0: 71 72 79 76 61 6c 73 29 0a 09 20 20 28 73 71 6c qryvals).. (sql
0700: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 ite3:execute db
0710: 22 55 50 44 41 54 45 20 72 75 6e 73 20 53 45 54 "UPDATE runs SET
0720: 20 73 74 61 74 65 3d 3f 2c 73 74 61 74 75 73 3d state=?,status=
0730: 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 20 73 ? WHERE id=?;" s
0740: 74 61 74 65 20 73 74 61 74 75 73 20 72 65 73 29 tate status res)
0750: 0a 09 20 20 72 65 73 29 20 0a 09 28 62 65 67 69 .. res) ..(begi
0760: 6e 0a 09 20 20 28 70 72 69 6e 74 20 22 45 52 52 n.. (print "ERR
0770: 4f 52 3a 20 43 61 6c 6c 65 64 20 77 69 74 68 6f OR: Called witho
0780: 75 74 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 ut all necessary
0790: 20 6b 65 79 73 22 29 0a 09 20 20 23 66 29 29 29 keys").. #f)))
07a0: 29 0a 0a 3b 3b 20 72 75 6e 73 3a 67 65 74 2d 72 )..;; runs:get-r
07b0: 75 6e 73 2d 62 79 2d 70 61 74 74 0a 3b 3b 20 67 uns-by-patt.;; g
07c0: 65 74 20 72 75 6e 73 20 62 79 20 6c 69 73 74 20 et runs by list
07d0: 6f 66 20 63 72 69 74 65 72 69 61 0a 3b 3b 20 72 of criteria.;; r
07e0: 65 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72 egister a test r
07f0: 75 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 3b un with the db.;
0800: 3b 0a 3b 3b 20 55 73 65 3a 20 28 64 62 2d 67 65 ;.;; Use: (db-ge
0810: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 t-value-by-heade
0820: 72 20 28 64 62 3a 67 65 74 2d 68 65 61 64 65 72 r (db:get-header
0830: 20 72 75 6e 69 6e 66 6f 29 28 64 62 3a 67 65 74 runinfo)(db:get
0840: 2d 72 6f 77 20 72 75 6e 69 6e 66 6f 29 29 0a 3b -row runinfo)).;
0850: 3b 20 20 74 6f 20 65 78 74 72 61 63 74 20 69 6e ; to extract in
0860: 66 6f 20 66 72 6f 6d 20 74 68 65 20 73 74 72 75 fo from the stru
0870: 63 74 75 72 65 20 72 65 74 75 72 6e 65 64 0a 3b cture returned.;
0880: 3b 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a ;.(define (runs:
0890: 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 get-runs-by-patt
08a0: 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 db keys runname
08b0: 70 61 74 74 20 2e 20 70 61 72 61 6d 73 29 20 3b patt . params) ;
08c0: 3b 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 ; test-name). (
08d0: 6c 65 74 2a 20 28 28 6b 65 79 76 61 6c 6c 73 74 let* ((keyvallst
08e0: 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 (keys->vallist
08f0: 6b 65 79 73 29 29 0a 09 20 28 74 6d 70 20 20 20 keys)).. (tmp
0900: 20 20 20 28 72 75 6e 73 3a 67 65 74 2d 73 74 64 (runs:get-std
0910: 2d 72 75 6e 2d 66 69 65 6c 64 73 20 6b 65 79 73 -run-fields keys
0920: 20 27 28 22 69 64 22 20 22 72 75 6e 6e 61 6d 65 '("id" "runname
0930: 22 20 22 73 74 61 74 65 22 20 22 73 74 61 74 75 " "state" "statu
0940: 73 22 20 22 6f 77 6e 65 72 22 20 22 65 76 65 6e s" "owner" "even
0950: 74 5f 74 69 6d 65 22 29 29 29 0a 09 20 28 6b 65 t_time"))).. (ke
0960: 79 73 74 72 20 20 20 28 63 61 72 20 74 6d 70 29 ystr (car tmp)
0970: 29 0a 09 20 28 68 65 61 64 65 72 20 20 20 28 63 ).. (header (c
0980: 61 64 72 20 74 6d 70 29 29 0a 09 20 28 72 65 73 adr tmp)).. (res
0990: 20 20 20 20 20 27 28 29 29 0a 09 20 28 6b 65 79 '()).. (key
09a0: 2d 70 61 74 74 20 22 22 29 29 0a 20 20 20 20 28 -patt "")). (
09b0: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 for-each (lambda
09c0: 20 28 6b 65 79 76 61 6c 29 0a 09 09 28 6c 65 74 (keyval)...(let
09d0: 2a 20 28 28 6b 65 79 20 20 20 20 28 76 65 63 74 * ((key (vect
09e0: 6f 72 2d 72 65 66 20 6b 65 79 76 61 6c 20 30 29 or-ref keyval 0)
09f0: 29 0a 09 09 20 20 20 20 20 20 20 28 66 75 6c 6b )... (fulk
0a00: 65 79 20 28 63 6f 6e 63 20 22 3a 22 20 6b 65 79 ey (conc ":" key
0a10: 29 29 0a 09 09 20 20 20 20 20 20 20 28 70 61 74 ))... (pat
0a20: 74 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 t (args:get-ar
0a30: 67 20 66 75 6c 6b 65 79 29 29 29 0a 09 09 20 20 g fulkey)))...
0a40: 28 69 66 20 70 61 74 74 0a 09 09 20 20 20 20 20 (if patt...
0a50: 20 28 73 65 74 21 20 6b 65 79 2d 70 61 74 74 20 (set! key-patt
0a60: 28 63 6f 6e 63 20 6b 65 79 2d 70 61 74 74 20 22 (conc key-patt "
0a70: 20 41 4e 44 20 22 20 6b 65 79 20 22 20 6c 69 6b AND " key " lik
0a80: 65 20 27 22 20 70 61 74 74 20 22 27 22 29 29 0a e '" patt "'")).
0a90: 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 .. (begin..
0aa0: 09 09 28 70 72 69 6e 74 20 22 45 52 52 4f 52 3a ..(print "ERROR:
0ab0: 20 73 65 61 72 63 68 69 6e 67 20 66 6f 72 20 72 searching for r
0ac0: 75 6e 73 20 77 69 74 68 20 6e 6f 20 70 61 74 74 uns with no patt
0ad0: 65 72 6e 20 73 65 74 20 66 6f 72 20 22 20 66 75 ern set for " fu
0ae0: 6c 6b 65 79 29 0a 09 09 09 28 65 78 69 74 20 36 lkey)....(exit 6
0af0: 29 29 29 29 29 0a 09 20 20 20 20 20 20 6b 65 79 ))))).. key
0b00: 73 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a s). (sqlite3:
0b10: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 20 20 for-each-row .
0b20: 20 20 20 28 6c 61 6d 62 64 61 20 28 61 20 2e 20 (lambda (a .
0b30: 72 29 0a 20 20 20 20 20 20 20 28 73 65 74 21 20 r). (set!
0b40: 72 65 73 20 28 63 6f 6e 73 20 28 6c 69 73 74 2d res (cons (list-
0b50: 3e 76 65 63 74 6f 72 20 28 63 6f 6e 73 20 61 20 >vector (cons a
0b60: 72 29 29 20 72 65 73 29 29 29 0a 20 20 20 20 20 r)) res))).
0b70: 64 62 20 0a 20 20 20 20 20 28 63 6f 6e 63 20 22 db . (conc "
0b80: 53 45 4c 45 43 54 20 22 20 6b 65 79 73 74 72 20 SELECT " keystr
0b90: 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 " FROM runs WHER
0ba0: 45 20 72 75 6e 6e 61 6d 65 20 6c 69 6b 65 20 3f E runname like ?
0bb0: 20 22 20 6b 65 79 2d 70 61 74 74 20 22 3b 22 29 " key-patt ";")
0bc0: 0a 20 20 20 20 20 72 75 6e 6e 61 6d 65 70 61 74 . runnamepat
0bd0: 74 29 0a 20 20 20 20 28 76 65 63 74 6f 72 20 68 t). (vector h
0be0: 65 61 64 65 72 20 72 65 73 29 29 29 0a 0a 28 64 eader res)))..(d
0bf0: 65 66 69 6e 65 20 28 72 65 67 69 73 74 65 72 2d efine (register-
0c00: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 test db run-id t
0c10: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 est-name item-pa
0c20: 74 68 29 0a 20 20 28 6c 65 74 20 28 28 69 74 65 th). (let ((ite
0c30: 6d 2d 70 61 74 68 73 20 28 69 66 20 28 65 71 75 m-paths (if (equ
0c40: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 al? item-path ""
0c50: 29 0a 09 09 09 28 6c 69 73 74 20 69 74 65 6d 2d )....(list item-
0c60: 70 61 74 68 29 0a 09 09 09 28 6c 69 73 74 20 69 path)....(list i
0c70: 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 29 0a tem-path "")))).
0c80: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 (for-each .
0c90: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 70 74 68 (lambda (pth
0ca0: 29 0a 20 20 20 20 20 20 20 28 73 71 6c 69 74 65 ). (sqlite
0cb0: 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 49 4e 3:execute db "IN
0cc0: 53 45 52 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 SERT OR IGNORE I
0cd0: 4e 54 4f 20 74 65 73 74 73 20 28 72 75 6e 5f 69 NTO tests (run_i
0ce0: 64 2c 74 65 73 74 6e 61 6d 65 2c 65 76 65 6e 74 d,testname,event
0cf0: 5f 74 69 6d 65 2c 69 74 65 6d 5f 70 61 74 68 29 _time,item_path)
0d00: 20 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 73 74 72 VALUES (?,?,str
0d10: 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 ftime('%s','now'
0d20: 29 2c 3f 29 3b 22 20 72 75 6e 2d 69 64 20 74 65 ),?);" run-id te
0d30: 73 74 2d 6e 61 6d 65 20 70 74 68 29 29 0a 20 20 st-name pth)).
0d40: 20 20 20 69 74 65 6d 2d 70 61 74 68 73 29 29 29 item-paths)))
0d50: 0a 0a 3b 3b 20 20 28 64 65 66 69 6e 65 20 64 62 ..;; (define db
0d60: 20 28 6f 70 65 6e 2d 64 62 29 29 0a 3b 3b 20 20 (open-db)).;;
0d70: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 (test-set-status
0d80: 21 20 64 62 20 32 20 22 72 75 6e 66 69 72 73 74 ! db 2 "runfirst
0d90: 22 20 22 43 4f 4d 50 4c 45 54 45 44 22 20 22 50 " "COMPLETED" "P
0da0: 41 53 53 22 20 22 73 75 6d 6d 65 72 22 29 0a 0a ASS" "summer")..
0db0: 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65 (define (test-se
0dc0: 74 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e t-status! db run
0dd0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 73 74 -id test-name st
0de0: 61 74 65 20 73 74 61 74 75 73 20 69 74 65 6d 64 ate status itemd
0df0: 61 74 2d 6f 72 2d 70 61 74 68 20 2e 20 63 6f 6d at-or-path . com
0e00: 6d 65 6e 74 29 0a 20 20 28 6c 65 74 20 28 28 69 ment). (let ((i
0e10: 74 65 6d 2d 70 61 74 68 20 28 69 66 20 28 73 74 tem-path (if (st
0e20: 72 69 6e 67 3f 20 69 74 65 6d 64 61 74 2d 6f 72 ring? itemdat-or
0e30: 2d 70 61 74 68 29 20 69 74 65 6d 64 61 74 2d 6f -path) itemdat-o
0e40: 72 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 r-path (item-lis
0e50: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 2d t->path itemdat-
0e60: 6f 72 2d 70 61 74 68 29 29 29 29 0a 20 20 20 20 or-path)))).
0e70: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 (sqlite3:execute
0e80: 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 db "UPDATE test
0e90: 73 20 53 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 s SET state=?,st
0ea0: 61 74 75 73 3d 3f 2c 65 76 65 6e 74 5f 74 69 6d atus=?,event_tim
0eb0: 65 3d 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c e=strftime('%s',
0ec0: 27 6e 6f 77 27 29 20 57 48 45 52 45 20 72 75 6e 'now') WHERE run
0ed0: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 _id=? AND testna
0ee0: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 me=? AND item_pa
0ef0: 74 68 3d 3f 3b 22 20 0a 09 09 20 20 20 20 20 73 th=?;" ... s
0f00: 74 61 74 65 20 73 74 61 74 75 73 20 72 75 6e 2d tate status run-
0f10: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 id test-name ite
0f20: 6d 2d 70 61 74 68 29 0a 20 20 20 20 28 69 66 20 m-path). (if
0f30: 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75 61 6c (and (not (equal
0f40: 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 ? item-path ""))
0f50: 20 3b 3b 20 6e 65 65 64 20 74 6f 20 75 70 64 61 ;; need to upda
0f60: 74 65 20 74 68 65 20 74 6f 70 20 74 65 73 74 20 te the top test
0f70: 72 65 63 6f 72 64 20 69 66 20 50 41 53 53 20 6f record if PASS o
0f80: 72 20 46 41 49 4c 20 61 6e 64 20 74 68 69 73 20 r FAIL and this
0f90: 69 73 20 61 20 73 75 62 74 65 73 74 0a 09 20 20 is a subtest..
0fa0: 20 20 20 28 6f 72 20 28 65 71 75 61 6c 3f 20 73 (or (equal? s
0fb0: 74 61 74 75 73 20 22 50 41 53 53 22 29 0a 09 09 tatus "PASS")...
0fc0: 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 (equal? status
0fd0: 22 57 41 52 4e 22 29 0a 09 09 20 28 65 71 75 61 "WARN")... (equa
0fe0: 6c 3f 20 73 74 61 74 75 73 20 22 46 41 49 4c 22 l? status "FAIL"
0ff0: 29 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 )))..(begin.. (
1000: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 sqlite3:execute
1010: 0a 09 20 20 20 64 62 0a 09 20 20 20 22 55 50 44 .. db.. "UPD
1020: 41 54 45 20 74 65 73 74 73 20 0a 20 20 20 20 20 ATE tests .
1030: 20 20 20 20 20 20 20 20 53 45 54 20 66 61 69 6c SET fail
1040: 5f 63 6f 75 6e 74 3d 28 53 45 4c 45 43 54 20 63 _count=(SELECT c
1050: 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 65 ount(id) FROM te
1060: 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 sts WHERE run_id
1070: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d =? AND testname=
1080: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 ? AND item_path
1090: 21 3d 20 27 27 20 41 4e 44 20 73 74 61 74 75 73 != '' AND status
10a0: 3d 27 46 41 49 4c 27 29 2c 0a 20 20 20 20 20 20 ='FAIL'),.
10b0: 20 20 20 20 20 20 20 20 20 20 20 70 61 73 73 5f pass_
10c0: 63 6f 75 6e 74 3d 28 53 45 4c 45 43 54 20 63 6f count=(SELECT co
10d0: 75 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 65 73 unt(id) FROM tes
10e0: 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d ts WHERE run_id=
10f0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f ? AND testname=?
1100: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 21 AND item_path !
1110: 3d 20 27 27 20 41 4e 44 20 28 73 74 61 74 75 73 = '' AND (status
1120: 3d 27 50 41 53 53 27 20 4f 52 20 73 74 61 74 75 ='PASS' OR statu
1130: 73 3d 27 57 41 52 4e 27 29 29 0a 20 20 20 20 20 s='WARN')).
1140: 20 20 20 20 20 20 20 20 57 48 45 52 45 20 72 75 WHERE ru
1150: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e n_id=? AND testn
1160: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 ame=? AND item_p
1170: 61 74 68 3d 27 27 3b 22 0a 09 20 20 20 72 75 6e ath='';".. run
1180: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 72 75 -id test-name ru
1190: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 72 n-id test-name r
11a0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 un-id test-name)
11b0: 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 .. (sqlite3:exe
11c0: 63 75 74 65 0a 09 20 20 20 64 62 0a 09 20 20 20 cute.. db..
11d0: 22 55 50 44 41 54 45 20 74 65 73 74 73 0a 20 20 "UPDATE tests.
11e0: 20 20 20 20 20 20 20 20 20 20 20 53 45 54 20 73 SET s
11f0: 74 61 74 65 3d 27 43 4f 4d 50 4c 45 54 45 44 27 tate='COMPLETED'
1200: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
1210: 20 20 73 74 61 74 75 73 3d 43 41 53 45 20 57 48 status=CASE WH
1220: 45 4e 20 66 61 69 6c 5f 63 6f 75 6e 74 20 3e 20 EN fail_count >
1230: 30 20 54 48 45 4e 20 27 46 41 49 4c 27 20 57 48 0 THEN 'FAIL' WH
1240: 45 4e 20 70 61 73 73 5f 63 6f 75 6e 74 20 3e 20 EN pass_count >
1250: 30 20 41 4e 44 20 66 61 69 6c 5f 63 6f 75 6e 74 0 AND fail_count
1260: 3d 30 20 54 48 45 4e 20 27 50 41 53 53 27 20 45 =0 THEN 'PASS' E
1270: 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e 27 20 45 4e LSE 'UNKNOWN' EN
1280: 44 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 57 D. W
1290: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e HERE run_id=? AN
12a0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 D testname=? AND
12b0: 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a item_path='';".
12c0: 09 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d . run-id test-
12d0: 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 69 66 20 name))). (if
12e0: 28 61 6e 64 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f (and (not (null?
12f0: 20 63 6f 6d 6d 65 6e 74 29 29 0a 09 20 20 20 20 comment))..
1300: 20 28 63 61 72 20 63 6f 6d 6d 65 6e 74 29 29 0a (car comment)).
1310: 09 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 .(sqlite3:execut
1320: 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 e db "UPDATE tes
1330: 74 73 20 53 45 54 20 63 6f 6d 6d 65 6e 74 3d 3f ts SET comment=?
1340: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 WHERE run_id=?
1350: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 AND testname=? A
1360: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 ND item_path=?;"
1370: 0a 09 09 09 20 28 63 61 72 20 63 6f 6d 6d 65 6e .... (car commen
1380: 74 29 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e t) run-id test-n
1390: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 ame item-path)))
13a0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 )..(define (test
13b0: 2d 73 65 74 2d 6c 6f 67 21 20 64 62 20 72 75 6e -set-log! db run
13c0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 -id test-name it
13d0: 65 6d 64 61 74 20 6c 6f 67 66 29 20 0a 20 20 28 emdat logf) . (
13e0: 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 let ((item-path
13f0: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 (item-list->path
1400: 20 69 74 65 6d 64 61 74 29 29 29 0a 20 20 20 20 itemdat))).
1410: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 (sqlite3:execute
1420: 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 db "UPDATE test
1430: 73 20 53 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 66 s SET final_logf
1440: 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d =? WHERE run_id=
1450: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f ? AND testname=?
1460: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f AND item_path=?
1470: 3b 22 20 0a 09 09 20 20 20 20 20 6c 6f 67 66 20 ;" ... logf
1480: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 run-id test-name
1490: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28 item-path)))..(
14a0: 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65 74 define (test-set
14b0: 2d 74 6f 70 6c 6f 67 21 20 64 62 20 72 75 6e 2d -toplog! db run-
14c0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6c 6f 67 id test-name log
14d0: 66 29 20 0a 20 20 28 73 71 6c 69 74 65 33 3a 65 f) . (sqlite3:e
14e0: 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54 xecute db "UPDAT
14f0: 45 20 74 65 73 74 73 20 53 45 54 20 66 69 6e 61 E tests SET fina
1500: 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20 72 l_logf=? WHERE r
1510: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 un_id=? AND test
1520: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f name=? AND item_
1530: 70 61 74 68 3d 27 27 3b 22 20 0a 09 09 20 20 20 path='';" ...
1540: 6c 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 73 74 logf run-id test
1550: 2d 6e 61 6d 65 29 29 0a 0a 3b 3b 20 3b 3b 20 54 -name))..;; ;; T
1560: 4f 44 4f 3a 20 43 6f 6e 76 65 72 67 65 20 74 68 ODO: Converge th
1570: 69 73 20 77 69 74 68 20 64 62 3a 67 65 74 2d 74 is with db:get-t
1580: 65 73 74 2d 69 6e 66 6f 0a 3b 3b 20 28 64 65 66 est-info.;; (def
1590: 69 6e 65 20 28 72 75 6e 73 3a 67 65 74 2d 74 65 ine (runs:get-te
15a0: 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 st-info db run-i
15b0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d d test-name item
15c0: 2d 70 61 74 68 29 0a 3b 3b 20 20 20 28 6c 65 74 -path).;; (let
15d0: 20 28 28 72 65 73 20 23 66 29 29 20 3b 3b 20 28 ((res #f)) ;; (
15e0: 76 65 63 74 6f 72 20 23 66 20 23 66 20 23 66 20 vector #f #f #f
15f0: 23 66 20 23 66 20 23 66 29 29 29 0a 3b 3b 20 20 #f #f #f))).;;
1600: 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d (sqlite3:for-
1610: 65 61 63 68 2d 72 6f 77 20 0a 3b 3b 20 20 20 20 each-row .;;
1620: 20 20 28 6c 61 6d 62 64 61 20 28 69 64 20 72 75 (lambda (id ru
1630: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 73 n-id test-name s
1640: 74 61 74 65 20 73 74 61 74 75 73 29 0a 3b 3b 20 tate status).;;
1650: 20 20 20 20 20 20 20 28 73 65 74 21 20 72 65 73 (set! res
1660: 20 28 76 65 63 74 6f 72 20 69 64 20 72 75 6e 2d (vector id run-
1670: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 73 74 61 id test-name sta
1680: 74 65 20 73 74 61 74 75 73 20 69 74 65 6d 2d 70 te status item-p
1690: 61 74 68 29 29 29 0a 3b 3b 20 20 20 20 20 20 64 ath))).;; d
16a0: 62 20 22 53 45 4c 45 43 54 20 69 64 2c 72 75 6e b "SELECT id,run
16b0: 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73 74 61 _id,testname,sta
16c0: 74 65 2c 73 74 61 74 75 73 20 46 52 4f 4d 20 74 te,status FROM t
16d0: 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 ests WHERE run_i
16e0: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 d=? AND testname
16f0: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 =? AND item_path
1700: 3d 3f 3b 22 0a 3b 3b 20 20 20 20 20 20 72 75 6e =?;".;; run
1710: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 -id test-name it
1720: 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20 20 20 em-path).;;
1730: 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65 2d 69 res))..(define-i
1740: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d nline (test:get-
1750: 69 64 20 76 65 63 29 20 20 20 20 20 20 20 28 76 id vec) (v
1760: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 30 29 ector-ref vec 0)
1770: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 ).(define-inline
1780: 20 28 74 65 73 74 3a 67 65 74 2d 72 75 6e 5f 69 (test:get-run_i
1790: 64 20 76 65 63 29 20 20 20 28 76 65 63 74 6f 72 d vec) (vector
17a0: 2d 72 65 66 20 76 65 63 20 31 29 29 0a 28 64 65 -ref vec 1)).(de
17b0: 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 fine-inline (tes
17c0: 74 3a 67 65 74 2d 74 65 73 74 2d 6e 61 6d 65 20 t:get-test-name
17d0: 76 65 63 29 28 76 65 63 74 6f 72 2d 72 65 66 20 vec)(vector-ref
17e0: 76 65 63 20 32 29 29 0a 28 64 65 66 69 6e 65 2d vec 2)).(define-
17f0: 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 inline (test:get
1800: 2d 73 74 61 74 65 20 76 65 63 29 20 20 20 20 28 -state vec) (
1810: 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 33 vector-ref vec 3
1820: 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e )).(define-inlin
1830: 65 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 e (test:get-stat
1840: 75 73 20 76 65 63 29 20 20 20 28 76 65 63 74 6f us vec) (vecto
1850: 72 2d 72 65 66 20 76 65 63 20 34 29 29 0a 28 64 r-ref vec 4)).(d
1860: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 efine-inline (te
1870: 73 74 3a 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 st:get-item-path
1880: 20 76 65 63 29 28 76 65 63 74 6f 72 2d 72 65 66 vec)(vector-ref
1890: 20 76 65 63 20 35 29 29 0a 0a 28 64 65 66 69 6e vec 5))..(defin
18a0: 65 20 28 72 75 6e 73 3a 74 65 73 74 2d 67 65 74 e (runs:test-get
18b0: 2d 66 75 6c 6c 2d 70 61 74 68 20 74 65 73 74 29 -full-path test)
18c0: 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e . (let* ((testn
18d0: 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65 74 ame (db:test-get
18e0: 2d 74 65 73 74 6e 61 6d 65 20 20 20 74 65 73 74 -testname test
18f0: 29 29 0a 09 20 28 69 74 65 6d 70 61 74 68 20 28 )).. (itempath (
1900: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d db:test-get-item
1910: 2d 70 61 74 68 20 74 65 73 74 29 29 29 0a 20 20 -path test))).
1920: 20 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 (conc testname
1930: 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65 (if (equal? ite
1940: 6d 70 61 74 68 20 22 22 29 20 22 22 20 28 63 6f mpath "") "" (co
1950: 6e 63 20 22 28 22 20 69 74 65 6d 70 61 74 68 20 nc "(" itempath
1960: 22 29 22 29 29 29 29 29 0a 0a 28 64 65 66 69 6e ")")))))..(defin
1970: 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 74 e-inline (test:t
1980: 65 73 74 2d 67 65 74 2d 66 75 6c 6c 6e 61 6d 65 est-get-fullname
1990: 20 74 65 73 74 29 0a 20 20 20 28 63 6f 6e 63 20 test). (conc
19a0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 (db:test-get-tes
19b0: 74 6e 61 6d 65 20 74 65 73 74 29 0a 09 20 28 69 tname test).. (i
19c0: 66 20 28 65 71 75 61 6c 3f 20 28 64 62 3a 74 65 f (equal? (db:te
19d0: 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 st-get-item-path
19e0: 20 74 65 73 74 29 20 22 22 29 0a 09 20 20 20 20 test) "")..
19f0: 20 22 22 0a 09 20 20 20 20 20 28 63 6f 6e 63 20 "".. (conc
1a00: 22 28 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 "(" (db:test-get
1a10: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 -item-path test)
1a20: 20 22 29 22 29 29 29 29 0a 0a 28 64 65 66 69 6e ")"))))..(defin
1a30: 65 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 e (check-valid-i
1a40: 74 65 6d 73 20 63 6c 61 73 73 20 69 74 65 6d 29 tems class item)
1a50: 0a 20 20 28 6c 65 74 20 28 28 76 61 6c 69 64 2d . (let ((valid-
1a60: 76 61 6c 75 65 73 20 28 6c 65 74 20 28 28 73 20 values (let ((s
1a70: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a (config-lookup *
1a80: 63 6f 6e 66 69 67 64 61 74 2a 20 22 76 61 6c 69 configdat* "vali
1a90: 64 76 61 6c 75 65 73 22 20 63 6c 61 73 73 29 29 dvalues" class))
1aa0: 29 0a 09 09 09 28 69 66 20 73 20 28 73 74 72 69 )....(if s (stri
1ab0: 6e 67 2d 73 70 6c 69 74 20 73 29 20 23 66 29 29 ng-split s) #f))
1ac0: 29 29 0a 20 20 20 20 28 69 66 20 76 61 6c 69 64 )). (if valid
1ad0: 2d 76 61 6c 75 65 73 0a 09 28 69 66 20 28 6d 65 -values..(if (me
1ae0: 6d 62 65 72 20 69 74 65 6d 20 76 61 6c 69 64 2d mber item valid-
1af0: 76 61 6c 75 65 73 29 0a 09 20 20 20 20 69 74 65 values).. ite
1b00: 6d 20 23 66 29 0a 09 69 74 65 6d 29 29 29 0a 0a m #f)..item)))..
1b10: 28 64 65 66 69 6e 65 20 28 74 65 73 74 73 74 65 (define (testste
1b20: 70 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62 p-set-status! db
1b30: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d run-id test-nam
1b40: 65 20 74 65 73 74 73 74 65 70 2d 6e 61 6d 65 20 e teststep-name
1b50: 73 74 61 74 65 2d 69 6e 20 73 74 61 74 75 73 2d state-in status-
1b60: 69 6e 20 69 74 65 6d 64 61 74 20 63 6f 6d 6d 65 in itemdat comme
1b70: 6e 74 29 0a 20 20 3b 3b 20 28 70 72 69 6e 74 20 nt). ;; (print
1b80: 22 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 "run-id: " run-i
1b90: 64 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 d " test-name: "
1ba0: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c test-name). (l
1bb0: 65 74 2a 20 28 28 73 74 61 74 65 20 20 20 20 20 et* ((state
1bc0: 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 (check-valid-ite
1bd0: 6d 73 20 22 73 74 61 74 65 22 20 73 74 61 74 65 ms "state" state
1be0: 2d 69 6e 29 29 0a 09 20 28 73 74 61 74 75 73 20 -in)).. (status
1bf0: 20 20 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d (check-valid-
1c00: 69 74 65 6d 73 20 22 73 74 61 74 75 73 22 20 73 items "status" s
1c10: 74 61 74 75 73 2d 69 6e 29 29 0a 09 20 28 69 74 tatus-in)).. (it
1c20: 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 em-path (item-li
1c30: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 st->path itemdat
1c40: 29 29 0a 09 20 28 74 65 73 74 64 61 74 20 20 20 )).. (testdat
1c50: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 (db:get-test-inf
1c60: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 o db run-id test
1c70: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 -name item-path)
1c80: 29 29 0a 20 20 20 20 3b 3b 20 28 70 72 69 6e 74 )). ;; (print
1c90: 20 22 74 65 73 74 64 61 74 3a 20 22 20 74 65 73 "testdat: " tes
1ca0: 74 64 61 74 29 0a 20 20 20 20 28 69 66 20 28 61 tdat). (if (a
1cb0: 6e 64 20 74 65 73 74 64 61 74 20 3b 3b 20 69 66 nd testdat ;; if
1cc0: 20 74 68 65 20 73 65 63 74 69 6f 6e 20 65 78 69 the section exi
1cd0: 73 74 73 20 74 68 65 6e 20 66 6f 72 63 65 20 73 sts then force s
1ce0: 70 65 63 69 66 69 63 61 74 69 6f 6e 20 42 55 47 pecification BUG
1cf0: 2c 20 49 20 64 6f 6e 27 74 20 6c 69 6b 65 20 68 , I don't like h
1d00: 6f 77 20 74 68 69 73 20 77 6f 72 6b 73 2e 0a 09 ow this works...
1d10: 20 20 20 20 20 28 6f 72 20 28 6e 6f 74 20 73 74 (or (not st
1d20: 61 74 65 29 28 6e 6f 74 20 73 74 61 74 75 73 29 ate)(not status)
1d30: 29 29 0a 09 28 70 72 69 6e 74 20 22 57 41 52 4e ))..(print "WARN
1d40: 49 4e 47 3a 20 49 6e 76 61 6c 69 64 20 22 20 28 ING: Invalid " (
1d50: 69 66 20 73 74 61 74 75 73 20 22 73 74 61 74 75 if status "statu
1d60: 73 22 20 22 73 74 61 74 65 22 29 0a 09 20 20 20 s" "state")..
1d70: 20 20 20 20 22 20 76 61 6c 75 65 20 5c 22 22 20 " value \""
1d80: 28 69 66 20 73 74 61 74 75 73 20 73 74 61 74 75 (if status statu
1d90: 73 2d 69 6e 20 73 74 61 74 65 2d 69 6e 29 20 22 s-in state-in) "
1da0: 5c 22 2c 20 75 70 64 61 74 65 20 79 6f 75 72 20 \", update your
1db0: 76 61 6c 69 64 73 74 61 74 65 73 20 73 65 63 74 validstates sect
1dc0: 69 6f 6e 20 69 6e 20 6d 65 67 61 74 65 73 74 2e ion in megatest.
1dd0: 63 6f 6e 66 69 67 22 29 29 0a 20 20 20 20 28 69 config")). (i
1de0: 66 20 74 65 73 74 64 61 74 0a 09 28 6c 65 74 20 f testdat..(let
1df0: 28 28 74 65 73 74 2d 69 64 20 28 74 65 73 74 3a ((test-id (test:
1e00: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 get-id testdat))
1e10: 29 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 ).. (sqlite3:ex
1e20: 65 63 75 74 65 20 64 62 20 0a 09 09 09 22 49 4e ecute db ...."IN
1e30: 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20 SERT OR REPLACE
1e40: 69 6e 74 6f 20 74 65 73 74 5f 73 74 65 70 73 20 into test_steps
1e50: 28 74 65 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d (test_id,stepnam
1e60: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65 e,state,status,e
1e70: 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e vent_time,commen
1e80: 74 29 20 56 41 4c 55 45 53 28 3f 2c 3f 2c 3f 2c t) VALUES(?,?,?,
1e90: 3f 2c 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c ?,strftime('%s',
1ea0: 27 6e 6f 77 27 29 2c 3f 29 3b 22 0a 09 09 09 74 'now'),?);"....t
1eb0: 65 73 74 2d 69 64 20 74 65 73 74 73 74 65 70 2d est-id teststep-
1ec0: 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 name state statu
1ed0: 73 20 28 69 66 20 63 6f 6d 6d 65 6e 74 20 63 6f s (if comment co
1ee0: 6d 6d 65 6e 74 20 22 22 29 29 29 0a 09 28 70 72 mment "")))..(pr
1ef0: 69 6e 74 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 int "ERROR: Can'
1f00: 74 20 75 70 64 61 74 65 20 22 20 74 65 73 74 2d t update " test-
1f10: 6e 61 6d 65 20 22 20 66 6f 72 20 72 75 6e 20 22 name " for run "
1f20: 20 72 75 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 run-id " -> no
1f30: 73 75 63 68 20 74 65 73 74 20 69 6e 20 64 62 22 such test in db"
1f40: 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 ))))..(define (t
1f50: 65 73 74 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 est-get-kill-req
1f60: 75 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 uest db run-id t
1f70: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 est-name itemdat
1f80: 29 0a 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d ). (let* ((item
1f90: 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 -path (item-list
1fa0: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 ->path itemdat))
1fb0: 0a 09 20 28 74 65 73 74 64 61 74 20 20 20 28 64 .. (testdat (d
1fc0: 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 b:get-test-info
1fd0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e db run-id test-n
1fe0: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 ame item-path)))
1ff0: 0a 20 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 . (equal? (te
2000: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 st:get-state tes
2010: 74 64 61 74 29 20 22 4b 49 4c 4c 52 45 51 22 29 tdat) "KILLREQ")
2020: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 ))..(define (tes
2030: 74 2d 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 t-set-meta-info
2040: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 db run-id testna
2050: 6d 65 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c me itemdat). (l
2060: 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 et ((item-path (
2070: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 item-list->path
2080: 69 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c itemdat))..(cpul
2090: 6f 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f oad (get-cpu-lo
20a0: 61 64 29 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20 ad))..(hostname
20b0: 28 67 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 (get-host-name))
20c0: 0a 09 28 64 69 73 6b 66 72 65 65 20 28 67 65 74 ..(diskfree (get
20d0: 2d 64 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72 -df (current-dir
20e0: 65 63 74 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d ectory)))..(unam
20f0: 65 20 20 20 20 28 67 65 74 2d 75 6e 61 6d 65 20 e (get-uname
2100: 22 2d 73 72 76 70 69 6f 22 29 29 0a 09 28 72 75 "-srvpio"))..(ru
2110: 6e 70 61 74 68 20 20 28 63 75 72 72 65 6e 74 2d npath (current-
2120: 64 69 72 65 63 74 6f 72 79 29 29 29 0a 20 20 20 directory))).
2130: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 (sqlite3:execut
2140: 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 e db "UPDATE tes
2150: 74 73 20 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70 ts SET host=?,cp
2160: 75 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 uload=?,diskfree
2170: 3d 3f 2c 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 =?,uname=?,rundi
2180: 72 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 r=? WHERE run_id
2190: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d =? AND testname=
21a0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d ? AND item_path=
21b0: 3f 3b 22 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65 ?;"... hostname
21c0: 0a 09 09 20 20 63 70 75 6c 6f 61 64 0a 09 09 20 ... cpuload...
21d0: 20 64 69 73 6b 66 72 65 65 0a 09 09 20 20 75 6e diskfree... un
21e0: 61 6d 65 0a 09 09 20 20 72 75 6e 70 61 74 68 0a ame... runpath.
21f0: 09 09 20 20 72 75 6e 2d 69 64 0a 09 09 20 20 74 .. run-id... t
2200: 65 73 74 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d estname... item
2210: 2d 70 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e -path)))..(defin
2220: 65 20 28 74 65 73 74 2d 75 70 64 61 74 65 2d 6d e (test-update-m
2230: 65 74 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d eta-info db run-
2240: 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d id testname item
2250: 64 61 74 20 6d 69 6e 75 74 65 73 29 0a 20 20 28 dat minutes). (
2260: 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 let ((item-path
2270: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 (item-list->path
2280: 20 69 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 itemdat))..(cpu
2290: 6c 6f 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c load (get-cpu-l
22a0: 6f 61 64 29 29 0a 09 28 64 69 73 6b 66 72 65 65 oad))..(diskfree
22b0: 20 28 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e (get-df (curren
22c0: 74 2d 64 69 72 65 63 74 6f 72 79 29 29 29 29 0a t-directory)))).
22d0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 63 70 75 (if (not cpu
22e0: 6c 6f 61 64 29 20 20 28 62 65 67 69 6e 20 28 70 load) (begin (p
22f0: 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20 43 rint "WARNING: C
2300: 50 55 4c 4f 41 44 20 6e 6f 74 20 66 6f 75 6e 64 PULOAD not found
2310: 2e 22 29 20 20 28 73 65 74 21 20 63 70 75 6c 6f .") (set! cpulo
2320: 61 64 20 22 6e 2f 61 22 29 29 29 0a 20 20 20 20 ad "n/a"))).
2330: 28 69 66 20 28 6e 6f 74 20 64 69 73 6b 66 72 65 (if (not diskfre
2340: 65 29 20 28 62 65 67 69 6e 20 28 70 72 69 6e 74 e) (begin (print
2350: 20 22 57 41 52 4e 49 4e 47 3a 20 44 49 53 4b 46 "WARNING: DISKF
2360: 52 45 45 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 REE not found.")
2370: 20 28 73 65 74 21 20 64 69 73 6b 66 72 65 65 20 (set! diskfree
2380: 22 6e 2f 61 22 29 29 29 0a 20 20 20 20 28 69 66 "n/a"))). (if
2390: 20 28 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29 (not item-path)
23a0: 28 62 65 67 69 6e 20 28 70 72 69 6e 74 20 22 57 (begin (print "W
23b0: 41 52 4e 49 4e 47 3a 20 49 54 45 4d 50 41 54 48 ARNING: ITEMPATH
23c0: 20 6e 6f 74 20 73 65 74 2e 22 29 20 20 20 28 73 not set.") (s
23d0: 65 74 21 20 69 74 65 6d 2d 70 61 74 68 20 22 22 et! item-path ""
23e0: 29 29 29 0a 20 20 20 20 3b 3b 20 28 6c 65 74 20 ))). ;; (let
23f0: 28 28 74 65 73 74 69 6e 66 6f 20 28 64 62 3a 67 ((testinfo (db:g
2400: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 et-test-info db
2410: 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 run-id testname
2420: 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 item-path))).
2430: 20 3b 3b 20 20 20 28 69 66 20 28 61 6e 64 20 28 ;; (if (and (
2440: 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62 3a not (equal? (db:
2450: 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73 20 test-get-status
2460: 74 65 73 74 69 6e 66 6f 29 20 22 43 4f 4d 50 4c testinfo) "COMPL
2470: 45 54 45 44 22 29 29 0a 20 20 20 20 3b 3b 20 20 ETED")). ;;
2480: 20 20 20 20 20 20 20 20 20 20 28 6e 6f 74 20 28 (not (
2490: 65 71 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d equal? (db:test-
24a0: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 69 get-status testi
24b0: 6e 66 6f 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 nfo) "KILLREQ"))
24c0: 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 . (sqlite3:ex
24d0: 65 63 75 74 65 0a 20 20 20 20 20 64 62 0a 20 20 ecute. db.
24e0: 20 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73 "UPDATE tests
24f0: 20 53 45 54 20 63 70 75 6c 6f 61 64 3d 3f 2c 64 SET cpuload=?,d
2500: 69 73 6b 66 72 65 65 3d 3f 2c 72 75 6e 5f 64 75 iskfree=?,run_du
2510: 72 61 74 69 6f 6e 3d 3f 2c 73 74 61 74 65 3d 27 ration=?,state='
2520: 52 55 4e 4e 49 4e 47 27 20 57 48 45 52 45 20 72 RUNNING' WHERE r
2530: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 un_id=? AND test
2540: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f name=? AND item_
2550: 70 61 74 68 3d 3f 20 41 4e 44 20 73 74 61 74 65 path=? AND state
2560: 20 4e 4f 54 20 49 4e 20 28 27 43 4f 4d 50 4c 45 NOT IN ('COMPLE
2570: 54 45 44 27 2c 27 4b 49 4c 4c 52 45 51 27 2c 27 TED','KILLREQ','
2580: 4b 49 4c 4c 45 44 27 29 3b 22 0a 20 20 20 20 20 KILLED');".
2590: 63 70 75 6c 6f 61 64 0a 20 20 20 20 20 64 69 73 cpuload. dis
25a0: 6b 66 72 65 65 0a 20 20 20 20 20 6d 69 6e 75 74 kfree. minut
25b0: 65 73 0a 20 20 20 20 20 72 75 6e 2d 69 64 0a 20 es. run-id.
25c0: 20 20 20 20 74 65 73 74 6e 61 6d 65 0a 20 20 20 testname.
25d0: 20 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a item-path)))..
25e0: 28 64 65 66 69 6e 65 20 28 73 65 74 2d 6d 65 67 (define (set-meg
25f0: 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 atest-env-vars d
2600: 62 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c 65 74 b run-id). (let
2610: 20 28 28 6b 65 79 73 20 28 64 62 2d 67 65 74 2d ((keys (db-get-
2620: 6b 65 79 73 20 64 62 29 29 29 0a 20 20 20 20 28 keys db))). (
2630: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 for-each (lambda
2640: 20 28 6b 65 79 29 0a 09 09 28 73 71 6c 69 74 65 (key)...(sqlite
2650: 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 3:for-each-row..
2660: 09 20 28 6c 61 6d 62 64 61 20 28 76 61 6c 29 0a . (lambda (val).
2670: 09 09 20 20 20 28 70 72 69 6e 74 20 22 73 65 74 .. (print "set
2680: 65 6e 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 env " (key:get-f
2690: 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 ieldname key) "
26a0: 22 20 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 " val)... (set
26b0: 65 6e 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 env (key:get-fie
26c0: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 ldname key) val)
26d0: 29 0a 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e )... db ... (con
26e0: 63 20 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 c "SELECT " (key
26f0: 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b :get-fieldname k
2700: 65 79 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 ey) " FROM runs
2710: 57 48 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 WHERE id=?;")...
2720: 20 72 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 run-id))..
2730: 20 6b 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e keys)))..(defin
2740: 65 20 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d e (set-item-env-
2750: 76 61 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 vars itemdat).
2760: 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 (for-each (lambd
2770: 61 20 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 a (item)..
2780: 28 70 72 69 6e 74 20 22 73 65 74 65 6e 76 20 22 (print "setenv "
2790: 20 28 63 61 72 20 69 74 65 6d 29 20 22 20 22 20 (car item) " "
27a0: 28 63 61 64 72 20 69 74 65 6d 29 29 0a 09 20 20 (cadr item))..
27b0: 20 20 20 20 28 73 65 74 65 6e 76 20 28 63 61 72 (setenv (car
27c0: 20 69 74 65 6d 29 20 28 63 61 64 72 20 69 74 65 item) (cadr ite
27d0: 6d 29 29 29 0a 09 20 20 20 20 69 74 65 6d 64 61 m))).. itemda
27e0: 74 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 t))..(define (ge
27f0: 74 2d 61 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 t-all-legal-test
2800: 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 s). (let* ((tes
2810: 74 73 20 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 ts (glob (conc
2820: 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 *toppath* "/test
2830: 73 2f 2a 22 29 29 29 0a 09 20 28 72 65 73 20 20 s/*"))).. (res
2840: 20 20 27 28 29 29 29 0a 20 20 20 20 3b 3b 20 28 '())). ;; (
2850: 70 72 69 6e 74 20 22 49 4e 46 4f 3a 20 4c 6f 6f print "INFO: Loo
2860: 6b 69 6e 67 20 61 74 20 74 65 73 74 73 20 22 20 king at tests "
2870: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 (string-interspe
2880: 72 73 65 20 74 65 73 74 73 20 22 2c 22 29 29 0a rse tests ",")).
2890: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c (for-each (l
28a0: 61 6d 62 64 61 20 28 74 65 73 74 70 61 74 68 29 ambda (testpath)
28b0: 0a 09 09 28 69 66 20 28 66 69 6c 65 2d 65 78 69 ...(if (file-exi
28c0: 73 74 73 3f 20 28 63 6f 6e 63 20 74 65 73 74 70 sts? (conc testp
28d0: 61 74 68 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 ath "/testconfig
28e0: 22 29 29 0a 09 09 20 20 20 20 28 73 65 74 21 20 "))... (set!
28f0: 72 65 73 20 28 63 6f 6e 73 20 28 6c 61 73 74 20 res (cons (last
2900: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 (string-split te
2910: 73 74 70 61 74 68 20 22 2f 22 29 29 20 72 65 73 stpath "/")) res
2920: 29 29 29 29 0a 09 20 20 20 20 20 20 74 65 73 74 )))).. test
2930: 73 29 0a 20 20 20 20 72 65 73 29 29 0a 0a 28 64 s). res))..(d
2940: 65 66 69 6e 65 20 28 72 75 6e 73 3a 63 61 6e 2d efine (runs:can-
2950: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 run-more-tests d
2960: 62 29 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 2d b). (let ((num-
2970: 72 75 6e 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d running (db:get-
2980: 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e count-tests-runn
2990: 69 6e 67 20 64 62 29 29 0a 09 28 6d 61 78 2d 63 ing db))..(max-c
29a0: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28 oncurrent-jobs (
29b0: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 config-lookup *c
29c0: 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 70 onfigdat* "setup
29d0: 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e " "max_concurren
29e0: 74 5f 6a 6f 62 73 22 29 29 29 0a 20 20 20 20 3b t_jobs"))). ;
29f0: 3b 20 28 70 72 69 6e 74 20 22 6d 61 78 2d 63 6f ; (print "max-co
2a00: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 ncurrent-jobs: "
2a10: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d max-concurrent-
2a20: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e jobs ", num-runn
2a30: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 ing: " num-runni
2a40: 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20 ng). (if (or
2a50: 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75 72 72 (not max-concurr
2a60: 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20 20 28 ent-jobs).. (
2a70: 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 and max-concurre
2a80: 6e 74 2d 6a 6f 62 73 0a 09 09 20 28 73 74 72 69 nt-jobs... (stri
2a90: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 ng->number max-c
2aa0: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a oncurrent-jobs).
2ab0: 09 09 20 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d .. (not (>= num-
2ac0: 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d running (string-
2ad0: 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 >number max-conc
2ae0: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29 urrent-jobs)))))
2af0: 0a 09 23 74 0a 09 28 62 65 67 69 6e 20 0a 09 20 ..#t..(begin ..
2b00: 20 28 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 (print "WARNING
2b10: 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f : Max running jo
2b20: 62 73 20 65 78 63 65 65 64 65 64 2c 20 63 75 72 bs exceeded, cur
2b30: 72 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e rent number runn
2b40: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 ing: " num-runni
2b50: 6e 67 20 0a 09 09 09 20 22 2c 20 6d 61 78 5f 63 ng .... ", max_c
2b60: 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 oncurrent_jobs:
2b70: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 " max-concurrent
2b80: 2d 6a 6f 62 73 29 0a 09 20 20 23 66 29 29 29 29 -jobs).. #f))))
2b90: 0a 20 20 0a 28 64 65 66 69 6e 65 20 28 72 75 6e . .(define (run
2ba0: 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d 6e -tests db test-n
2bb0: 61 6d 65 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 ames). (let* ((
2bc0: 6b 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d keys (db-
2bd0: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 get-keys db))..
2be0: 28 6b 65 79 76 61 6c 6c 73 74 20 20 20 28 6b 65 (keyvallst (ke
2bf0: 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 ys->vallist keys
2c00: 20 23 74 29 29 0a 09 20 28 72 75 6e 2d 69 64 20 #t)).. (run-id
2c10: 20 20 20 20 20 28 72 65 67 69 73 74 65 72 2d 72 (register-r
2c20: 75 6e 20 64 62 20 6b 65 79 73 29 29 29 20 3b 3b un db keys))) ;;
2c30: 20 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 test-name))).
2c40: 20 20 20 3b 3b 20 6f 6e 20 74 68 65 20 66 69 72 ;; on the fir
2c50: 73 74 20 70 61 73 73 20 6f 72 20 63 61 6c 6c 20 st pass or call
2c60: 74 6f 20 72 75 6e 2d 74 65 73 74 73 20 73 65 74 to run-tests set
2c70: 20 46 41 49 4c 53 20 74 6f 20 4e 4f 54 5f 53 54 FAILS to NOT_ST
2c80: 41 52 54 45 44 20 69 66 0a 20 20 20 20 3b 3b 20 ARTED if. ;;
2c90: 2d 6b 65 65 70 67 6f 69 6e 67 20 69 73 20 73 70 -keepgoing is sp
2ca0: 65 63 69 66 69 65 64 0a 20 20 20 20 28 69 66 20 ecified. (if
2cb0: 28 61 6e 64 20 28 65 71 3f 20 2a 70 61 73 73 6e (and (eq? *passn
2cc0: 75 6d 2a 20 30 29 0a 09 20 20 20 20 20 28 61 72 um* 0).. (ar
2cd0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 gs:get-arg "-kee
2ce0: 70 67 6f 69 6e 67 22 29 29 0a 09 28 64 62 3a 73 pgoing"))..(db:s
2cf0: 65 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d 73 et-tests-state-s
2d00: 74 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64 20 tatus db run-id
2d10: 74 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 test-names #f "F
2d20: 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 AIL" "NOT_STARTE
2d30: 44 22 20 22 46 41 49 4c 22 29 29 0a 20 20 20 20 D" "FAIL")).
2d40: 28 73 65 74 21 20 2a 70 61 73 73 6e 75 6d 2a 20 (set! *passnum*
2d50: 28 2b 20 2a 70 61 73 73 6e 75 6d 2a 20 31 29 29 (+ *passnum* 1))
2d60: 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 . (let loop (
2d70: 28 6e 75 6d 74 69 6d 65 73 20 30 29 29 0a 20 20 (numtimes 0)).
2d80: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 (for-each .
2d90: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 (lambda (t
2da0: 65 73 74 2d 6e 61 6d 65 29 0a 09 20 28 69 66 20 est-name).. (if
2db0: 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f (runs:can-run-mo
2dc0: 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09 20 20 re-tests db)..
2dd0: 20 20 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 (run-one-test
2de0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d db run-id test-
2df0: 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a name keyvallst).
2e00: 09 20 20 20 20 20 3b 3b 20 61 64 64 20 73 6f 6d . ;; add som
2e10: 65 20 64 65 6c 61 79 20 0a 09 20 20 20 20 20 28 e delay .. (
2e20: 73 6c 65 65 70 20 32 29 29 29 0a 20 20 20 20 20 sleep 2))).
2e30: 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 20 20 test-names).
2e40: 20 20 20 20 3b 3b 20 28 72 75 6e 2d 77 61 69 74 ;; (run-wait
2e50: 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a 20 20 ing-tests db).
2e60: 20 20 20 20 28 69 66 20 28 61 72 67 73 3a 67 65 (if (args:ge
2e70: 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e t-arg "-keepgoin
2e80: 67 22 29 0a 09 20 20 28 6c 65 74 20 28 28 65 73 g").. (let ((es
2e90: 74 72 65 6d 20 28 64 62 3a 65 73 74 69 6d 61 74 trem (db:estimat
2ea0: 65 64 2d 74 65 73 74 73 2d 72 65 6d 61 69 6e 69 ed-tests-remaini
2eb0: 6e 67 20 64 62 20 72 75 6e 2d 69 64 29 29 29 0a ng db run-id))).
2ec0: 09 20 20 20 20 28 69 66 20 28 3e 20 65 73 74 72 . (if (> estr
2ed0: 65 6d 20 30 29 0a 09 09 28 62 65 67 69 6e 0a 09 em 0)...(begin..
2ee0: 09 20 20 28 70 72 69 6e 74 20 22 4b 65 65 70 20 . (print "Keep
2ef0: 67 6f 69 6e 67 2c 20 65 73 74 69 6d 61 74 65 64 going, estimated
2f00: 20 22 20 65 73 74 72 65 6d 20 22 20 74 65 73 74 " estrem " test
2f10: 73 20 72 65 6d 61 69 6e 69 6e 67 20 74 6f 20 72 s remaining to r
2f20: 75 6e 2c 20 77 69 6c 6c 20 63 6f 6e 74 69 6e 75 un, will continu
2f30: 65 20 69 6e 20 31 30 20 73 65 63 6f 6e 64 73 20 e in 10 seconds
2f40: 2e 2e 2e 22 29 0a 09 09 20 20 28 73 6c 65 65 70 ...")... (sleep
2f50: 20 31 30 29 0a 09 09 20 20 28 72 75 6e 2d 77 61 10)... (run-wa
2f60: 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a iting-tests db).
2f70: 09 09 20 20 28 6c 6f 6f 70 20 28 2b 20 6e 75 6d .. (loop (+ num
2f80: 74 69 6d 65 73 20 31 29 29 29 29 29 29 29 29 29 times 1)))))))))
2f90: 0a 09 20 20 20 0a 3b 3b 20 56 45 52 59 20 49 4e .. .;; VERY IN
2fa0: 45 46 46 49 43 49 45 4e 54 21 20 4d 6f 76 65 20 EFFICIENT! Move
2fb0: 73 74 75 66 66 20 74 68 61 74 20 73 68 6f 75 6c stuff that shoul
2fc0: 64 20 62 65 20 64 6f 6e 65 20 6f 6e 63 65 20 75 d be done once u
2fd0: 70 20 74 6f 20 63 61 6c 6c 69 6e 67 20 70 72 6f p to calling pro
2fe0: 63 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 6f c.(define (run-o
2ff0: 6e 65 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 ne-test db run-i
3000: 64 20 74 65 73 74 2d 6e 61 6d 65 20 6b 65 79 76 d test-name keyv
3010: 61 6c 6c 73 74 29 0a 20 20 28 70 72 69 6e 74 20 allst). (print
3020: 22 4c 61 75 6e 63 68 69 6e 67 20 74 65 73 74 20 "Launching test
3030: 22 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 3b " test-name). ;
3040: 3b 20 41 6c 6c 20 74 68 65 73 65 20 76 61 72 73 ; All these vars
3050: 20 6d 69 67 68 74 20 62 65 20 72 65 66 65 72 65 might be refere
3060: 6e 63 65 64 20 62 79 20 74 68 65 20 74 65 73 74 nced by the test
3070: 63 6f 6e 66 69 67 20 66 69 6c 65 20 72 65 61 64 config file read
3080: 65 72 0a 20 20 28 73 65 74 65 6e 76 20 22 4d 54 er. (setenv "MT
3090: 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 _TEST_NAME" test
30a0: 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20 28 73 65 -name) ;; . (se
30b0: 74 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 tenv "MT_RUNNAME
30c0: 22 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 " (args:get-ar
30d0: 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29 0a 20 g ":runname")).
30e0: 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 (set-megatest-e
30f0: 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 nv-vars db run-i
3100: 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 d) ;; these may
3110: 62 65 20 6e 65 65 64 65 64 20 62 79 20 74 68 65 be needed by the
3120: 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 launching proce
3130: 73 73 0a 20 20 28 63 68 61 6e 67 65 2d 64 69 72 ss. (change-dir
3140: 65 63 74 6f 72 79 20 2a 74 6f 70 70 61 74 68 2a ectory *toppath*
3150: 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 ). (let* ((test
3160: 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63 20 2a -path (conc *
3170: 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 toppath* "/tests
3180: 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a 09 /" test-name))..
3190: 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 (test-configf (
31a0: 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 conc test-path "
31b0: 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 /testconfig"))..
31c0: 20 28 74 65 73 74 65 78 69 73 74 73 20 20 20 28 (testexists (
31d0: 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73 and (file-exists
31e0: 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 ? test-configf)(
31f0: 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73 file-read-access
3200: 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 ? test-configf))
3210: 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 ).. (test-conf
3220: 20 20 28 69 66 20 74 65 73 74 65 78 69 73 74 73 (if testexists
3230: 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 74 65 (read-config te
3240: 73 74 2d 63 6f 6e 66 69 67 66 29 20 28 6d 61 6b st-configf) (mak
3250: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a e-hash-table))).
3260: 09 20 28 77 61 69 74 6f 6e 20 20 20 20 20 20 20 . (waiton
3270: 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69 67 (let ((w (config
3280: 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e -lookup test-con
3290: 66 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 f "requirements"
32a0: 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 "waiton")))....
32b0: 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 77 29 (if (string? w)
32c0: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 77 29 (string-split w)
32d0: 27 28 29 29 29 29 29 0a 20 20 20 20 28 69 66 20 '())))). (if
32e0: 28 6e 6f 74 20 74 65 73 74 65 78 69 73 74 73 29 (not testexists)
32f0: 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 70 72 69 ..(begin.. (pri
3300: 6e 74 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 nt "ERROR: Can't
3310: 20 66 69 6e 64 20 63 6f 6e 66 69 67 20 66 69 6c find config fil
3320: 65 20 22 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 e " test-configf
3330: 29 0a 09 20 20 28 65 78 69 74 20 32 29 29 0a 09 ).. (exit 2))..
3340: 3b 3b 20 70 75 74 20 74 6f 70 20 76 61 72 73 20 ;; put top vars
3350: 69 6e 74 6f 20 63 6f 6e 76 65 6e 69 65 6e 74 20 into convenient
3360: 76 61 72 69 61 62 6c 65 73 20 61 6e 64 20 6f 70 variables and op
3370: 65 6e 20 74 68 65 20 64 62 0a 09 28 6c 65 74 2a en the db..(let*
3380: 20 28 3b 3b 20 64 62 20 69 73 20 61 6c 77 61 79 (;; db is alway
3390: 73 20 61 74 20 2a 74 6f 70 70 61 74 68 2a 2f 64 s at *toppath*/d
33a0: 62 2f 6d 65 67 61 74 65 73 74 2e 64 62 0a 09 20 b/megatest.db..
33b0: 20 20 20 20 20 20 28 69 74 65 6d 73 20 20 20 20 (items
33c0: 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 (hash-table-r
33d0: 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d ef/default test-
33e0: 63 6f 6e 66 20 22 69 74 65 6d 73 22 20 27 28 29 conf "items" '()
33f0: 29 29 0a 09 20 20 20 20 20 20 20 28 69 74 65 6d )).. (item
3400: 73 74 61 62 6c 65 20 20 28 68 61 73 68 2d 74 61 stable (hash-ta
3410: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 ble-ref/default
3420: 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d 73 test-conf "items
3430: 74 61 62 6c 65 22 20 27 28 29 29 29 0a 09 20 20 table" '()))..
3440: 20 20 20 20 20 28 61 6c 6c 69 74 65 6d 73 20 20 (allitems
3450: 20 20 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 28 (if (or (not (
3460: 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 6e 6f null? items))(no
3470: 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 74 61 t (null? itemsta
3480: 62 6c 65 29 29 29 0a 09 09 09 09 28 61 70 70 65 ble))).....(appe
3490: 6e 64 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e nd (item-assoc->
34a0: 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29 item-list items)
34b0: 0a 09 09 09 09 09 28 69 74 65 6d 2d 74 61 62 6c ......(item-tabl
34c0: 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 e->item-list ite
34d0: 6d 73 74 61 62 6c 65 29 29 0a 09 09 09 09 27 28 mstable)).....'(
34e0: 28 29 29 29 29 20 3b 3b 20 61 20 6c 69 73 74 20 ()))) ;; a list
34f0: 77 69 74 68 20 6f 6e 65 20 6e 75 6c 6c 20 6c 69 with one null li
3500: 73 74 20 69 73 20 61 20 74 65 73 74 20 77 69 74 st is a test wit
3510: 68 20 6e 6f 20 69 74 65 6d 73 0a 09 20 20 20 20 h no items..
3520: 20 20 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20 (runconfigf
3530: 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a (conc *toppath*
3540: 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f "/runconfigs.co
3550: 6e 66 69 67 22 29 29 29 0a 09 20 20 28 70 72 69 nfig"))).. (pri
3560: 6e 74 20 22 69 74 65 6d 73 3a 20 22 29 28 70 70 nt "items: ")(pp
3570: 20 61 6c 6c 69 74 65 6d 73 29 0a 09 20 20 28 69 allitems).. (i
3580: 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 f (args:get-arg
3590: 22 2d 6d 22 29 0a 09 20 20 20 20 20 20 28 64 62 "-m").. (db
35a0: 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d 66 6f 72 :set-comment-for
35b0: 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 20 28 -run db run-id (
35c0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d args:get-arg "-m
35d0: 22 29 29 29 0a 09 20 20 28 6c 65 74 20 6c 6f 6f "))).. (let loo
35e0: 70 20 28 28 69 74 65 6d 64 61 74 20 28 63 61 72 p ((itemdat (car
35f0: 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 09 20 20 allitems))...
3600: 20 20 20 28 74 61 6c 20 20 20 20 20 28 63 64 72 (tal (cdr
3610: 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a 09 20 20 allitems)))..
3620: 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69 74 ;; (lambda (it
3630: 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69 70 emdat) ;;; ((rip
3640: 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65 22 eness "overripe"
3650: 29 20 28 74 65 6d 70 65 72 61 74 75 72 65 20 22 ) (temperature "
3660: 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20 22 cool") (season "
3670: 73 75 6d 6d 65 72 22 29 29 0a 09 20 20 20 20 3b summer")).. ;
3680: 3b 20 48 61 6e 64 6c 65 20 6c 69 73 74 73 20 6f ; Handle lists o
3690: 66 20 69 74 65 6d 73 0a 09 20 20 20 20 28 6c 65 f items.. (le
36a0: 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 20 t* ((item-path
36b0: 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 (item-list->p
36c0: 61 74 68 20 69 74 65 6d 64 61 74 29 29 20 3b 3b ath itemdat)) ;;
36d0: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 (string-intersp
36e0: 65 72 73 65 20 28 6d 61 70 20 63 61 64 72 20 69 erse (map cadr i
36f0: 74 65 6d 64 61 74 29 20 22 2f 22 29 29 0a 09 09 temdat) "/"))...
3700: 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 70 61 74 (new-test-pat
3710: 68 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 h (string-inters
3720: 70 65 72 73 65 20 28 63 6f 6e 73 20 74 65 73 74 perse (cons test
3730: 2d 70 61 74 68 20 28 6d 61 70 20 63 61 64 72 20 -path (map cadr
3740: 69 74 65 6d 64 61 74 29 29 20 22 2f 22 29 29 0a itemdat)) "/")).
3750: 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e .. (new-test-n
3760: 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20 ame (if (equal?
3770: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20 74 65 item-path "") te
3780: 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 st-name (conc te
3790: 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d st-name "/" item
37a0: 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75 73 74 -path))) ;; just
37b0: 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65 20 75 need it to be u
37c0: 6e 69 71 75 65 0a 09 09 20 20 20 28 74 65 73 74 nique... (test
37d0: 64 61 74 20 20 20 23 66 29 0a 09 09 20 20 20 28 dat #f)... (
37e0: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a num-running (db:
37f0: 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d get-count-tests-
3800: 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 09 20 running db))...
3810: 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e (max-concurren
3820: 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c t-jobs (config-l
3830: 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 ookup *configdat
3840: 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f 63 * "setup" "max_c
3850: 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29 oncurrent_jobs")
3860: 29 0a 09 09 20 20 20 28 70 61 72 65 6e 74 2d 74 )... (parent-t
3870: 65 73 74 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e est (and (not (n
3880: 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 65 71 75 ull? items))(equ
3890: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 al? item-path ""
38a0: 29 29 29 0a 09 09 20 20 20 28 73 69 6e 67 6c 65 )))... (single
38b0: 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 75 6c 6c -test (and (null
38c0: 3f 20 69 74 65 6d 73 29 20 28 65 71 75 61 6c 3f ? items) (equal?
38d0: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 item-path "")))
38e0: 0a 09 09 20 20 20 28 69 74 65 6d 2d 74 65 73 74 ... (item-test
38f0: 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 (not (equal?
3900: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 29 item-path ""))))
3910: 0a 09 20 20 20 20 20 20 3b 3b 20 28 70 72 69 6e .. ;; (prin
3920: 74 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e t "max-concurren
3930: 74 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f t-jobs: " max-co
3940: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c ncurrent-jobs ",
3950: 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 num-running: "
3960: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 09 20 20 num-running)..
3970: 20 20 20 20 28 69 66 20 28 72 75 6e 73 3a 63 61 (if (runs:ca
3980: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 n-run-more-tests
3990: 20 64 62 29 0a 09 09 20 20 28 62 65 67 69 6e 0a db)... (begin.
39a0: 09 09 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 32 .. (let loop2
39b0: 20 28 28 74 73 20 28 64 62 3a 67 65 74 2d 74 65 ((ts (db:get-te
39c0: 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 st-info db run-i
39d0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d d test-name item
39e0: 2d 70 61 74 68 29 29 20 3b 3b 20 23 66 29 0a 09 -path)) ;; #f)..
39f0: 09 09 09 28 63 74 20 30 29 29 0a 09 09 20 20 20 ...(ct 0))...
3a00: 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 (if (and (not
3a10: 20 74 73 29 0a 09 09 09 20 20 20 20 20 20 20 28 ts).... (
3a20: 3c 20 63 74 20 31 30 29 29 0a 09 09 09 20 20 28 < ct 10)).... (
3a30: 62 65 67 69 6e 0a 09 09 09 20 20 20 20 28 72 65 begin.... (re
3a40: 67 69 73 74 65 72 2d 74 65 73 74 20 64 62 20 72 gister-test db r
3a50: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 un-id test-name
3a60: 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 20 20 item-path)....
3a70: 20 20 28 64 62 3a 74 65 73 74 2d 73 65 74 2d 63 (db:test-set-c
3a80: 6f 6d 6d 65 6e 74 20 64 62 20 72 75 6e 2d 69 64 omment db run-id
3a90: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d test-name item-
3aa0: 70 61 74 68 20 22 22 29 0a 09 09 09 20 20 20 20 path "")....
3ab0: 28 6c 6f 6f 70 32 20 28 64 62 3a 67 65 74 2d 74 (loop2 (db:get-t
3ac0: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d est-info db run-
3ad0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 id test-name ite
3ae0: 6d 2d 70 61 74 68 29 0a 09 09 09 09 20 20 20 28 m-path)..... (
3af0: 2b 20 63 74 20 31 29 29 29 0a 09 09 09 20 20 28 + ct 1))).... (
3b00: 69 66 20 74 73 0a 09 09 09 20 20 20 20 20 20 28 if ts.... (
3b10: 73 65 74 21 20 74 65 73 74 64 61 74 20 74 73 29 set! testdat ts)
3b20: 0a 09 09 09 20 20 20 20 20 20 28 62 65 67 69 6e .... (begin
3b30: 0a 09 09 09 09 28 70 72 69 6e 74 20 22 57 41 52 .....(print "WAR
3b40: 4e 49 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72 NING: Couldn't r
3b50: 65 67 69 73 74 65 72 20 74 65 73 74 20 22 20 74 egister test " t
3b60: 65 73 74 2d 6e 61 6d 65 20 22 20 77 69 74 68 20 est-name " with
3b70: 69 74 65 6d 20 70 61 74 68 20 22 20 69 74 65 6d item path " item
3b80: 2d 70 61 74 68 20 22 2c 20 73 6b 69 70 70 69 6e -path ", skippin
3b90: 67 22 29 0a 09 09 09 09 28 69 66 20 28 6e 6f 74 g").....(if (not
3ba0: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 (null? tal))...
3bb0: 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 .. (loop (car
3bc0: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 tal)(cdr tal)))
3bd0: 29 29 29 29 0a 09 09 20 20 20 20 28 63 68 61 6e ))))... (chan
3be0: 67 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73 ge-directory tes
3bf0: 74 2d 70 61 74 68 29 0a 09 09 20 20 20 20 3b 3b t-path)... ;;
3c00: 20 74 68 69 73 20 62 6c 6f 63 6b 20 69 73 20 68 this block is h
3c10: 65 72 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f ere only to info
3c20: 72 6d 20 74 68 65 20 75 73 65 72 20 65 61 72 6c rm the user earl
3c30: 79 20 6f 6e 0a 09 09 20 20 20 20 28 69 66 20 28 y on... (if (
3c40: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e file-exists? run
3c50: 63 6f 6e 66 69 67 66 29 0a 09 09 09 28 73 65 74 configf)....(set
3c60: 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 up-env-defaults
3c70: 64 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 db runconfigf ru
3c80: 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 n-id *already-se
3c90: 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 en-runconfig-inf
3ca0: 6f 2a 29 0a 09 09 09 28 70 72 69 6e 74 20 22 57 o*)....(print "W
3cb0: 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e ARNING: You do n
3cc0: 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f ot have a run co
3cd0: 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e nfig file: " run
3ce0: 63 6f 6e 66 69 67 66 29 29 0a 09 09 20 20 20 20 configf))...
3cf0: 3b 3b 20 28 70 72 69 6e 74 20 22 72 75 6e 2d 69 ;; (print "run-i
3d00: 64 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 d: " run-id " te
3d10: 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d st-name: " test-
3d20: 6e 61 6d 65 20 22 20 69 74 65 6d 2d 70 61 74 68 name " item-path
3d30: 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 : " item-path "
3d40: 74 65 73 74 64 61 74 3a 20 22 20 28 74 65 73 74 testdat: " (test
3d50: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 :get-status test
3d60: 64 61 74 29 20 22 20 74 65 73 74 2d 73 74 61 74 dat) " test-stat
3d70: 65 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 e: " (test:get-s
3d80: 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 tate testdat))..
3d90: 09 20 20 20 20 28 63 61 73 65 20 28 69 66 20 28 . (case (if (
3da0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 args:get-arg "-f
3db0: 6f 72 63 65 22 29 0a 09 09 09 20 20 20 20 20 20 orce")....
3dc0: 27 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 09 'NOT_STARTED....
3dd0: 20 20 20 20 20 20 28 69 66 20 74 65 73 74 64 61 (if testda
3de0: 74 0a 09 09 09 09 20 20 28 73 74 72 69 6e 67 2d t..... (string-
3df0: 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65 >symbol (test:ge
3e00: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 t-state testdat)
3e10: 29 0a 09 09 09 09 20 20 27 66 61 69 6c 65 64 2d )..... 'failed-
3e20: 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09 09 20 20 to-insert))...
3e30: 20 20 20 20 28 28 66 61 69 6c 65 64 2d 74 6f 2d ((failed-to-
3e40: 69 6e 73 65 72 74 29 0a 09 09 20 20 20 20 20 20 insert)...
3e50: 20 28 70 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 (print "ERROR:
3e60: 46 61 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 Failed to insert
3e70: 20 74 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f the record into
3e80: 20 74 68 65 20 64 62 22 29 29 0a 09 09 20 20 20 the db"))...
3e90: 20 20 20 28 28 4e 4f 54 5f 53 54 41 52 54 45 44 ((NOT_STARTED
3ea0: 20 43 4f 4d 50 4c 45 54 45 44 29 0a 09 09 20 20 COMPLETED)...
3eb0: 20 20 20 20 20 3b 3b 20 28 70 72 69 6e 74 20 22 ;; (print "
3ec0: 47 6f 74 20 68 65 72 65 2c 20 22 20 28 74 65 73 Got here, " (tes
3ed0: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 t:get-state test
3ee0: 64 61 74 29 29 0a 09 09 20 20 20 20 20 20 20 28 dat))... (
3ef0: 6c 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23 66 let ((runflag #f
3f00: 29 29 0a 09 09 09 20 28 63 6f 6e 64 0a 09 09 09 )).... (cond....
3f10: 20 20 3b 3b 20 69 2e 65 2e 20 74 68 69 73 20 69 ;; i.e. this i
3f20: 73 20 74 68 65 20 70 61 72 65 6e 74 20 74 65 73 s the parent tes
3f30: 74 20 74 6f 20 61 20 73 75 69 74 65 20 6f 66 20 t to a suite of
3f40: 69 74 65 6d 73 2c 20 6e 65 76 65 72 20 22 72 75 items, never "ru
3f50: 6e 22 20 69 74 0a 09 09 09 20 20 28 70 61 72 65 n" it.... (pare
3f60: 6e 74 2d 74 65 73 74 0a 09 09 09 20 20 20 28 73 nt-test.... (s
3f70: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 et! runflag #f))
3f80: 0a 09 09 09 20 20 3b 3b 20 2d 66 6f 72 63 65 2c .... ;; -force,
3f90: 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 run no matter w
3fa0: 68 61 74 0a 09 09 09 20 20 28 28 61 72 67 73 3a hat.... ((args:
3fb0: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 get-arg "-force"
3fc0: 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 )(set! runflag #
3fd0: 74 29 29 0a 09 09 09 20 20 3b 3b 20 4e 4f 54 5f t)).... ;; NOT_
3fe0: 53 54 41 52 54 45 44 2c 20 72 75 6e 20 6e 6f 20 STARTED, run no
3ff0: 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09 09 20 matter what....
4000: 20 28 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a ((equal? (test:
4010: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 get-state testda
4020: 74 29 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 t) "NOT_STARTED"
4030: 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 )(set! runflag #
4040: 74 29 29 0a 09 09 09 20 20 3b 3b 20 6e 6f 74 20 t)).... ;; not
4050: 2d 72 65 72 75 6e 20 61 6e 64 20 50 41 53 53 2c -rerun and PASS,
4060: 20 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 2c 20 WARN or CHECK,
4070: 64 6f 20 6e 6f 20 72 75 6e 0a 09 09 09 20 20 28 do no run.... (
4080: 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20 28 61 (and (or (not (a
4090: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 rgs:get-arg "-re
40a0: 72 75 6e 22 29 29 0a 09 09 09 09 20 20 20 20 28 run"))..... (
40b0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b args:get-arg "-k
40c0: 65 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 eepgoing")).....
40d0: 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 (member (test:ge
40e0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 t-status testdat
40f0: 29 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e ) '("PASS" "WARN
4100: 22 20 22 43 48 45 43 4b 22 29 29 29 0a 09 09 09 " "CHECK")))....
4110: 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 (set! runflag
4120: 20 23 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d 72 #f)).... ;; -r
4130: 65 72 75 6e 20 61 6e 64 20 73 74 61 74 75 73 20 erun and status
4140: 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 73 70 is one of the sp
4150: 65 63 69 66 65 64 2c 20 72 75 6e 20 69 74 0a 09 ecifed, run it..
4160: 09 09 20 20 28 28 61 6e 64 20 28 61 72 67 73 3a .. ((and (args:
4170: 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 get-arg "-rerun"
4180: 29 0a 09 09 09 09 28 6c 65 74 20 28 28 72 65 72 ).....(let ((rer
4190: 75 6e 6c 73 74 20 28 73 74 72 69 6e 67 2d 73 70 unlst (string-sp
41a0: 6c 69 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72 lit (args:get-ar
41b0: 67 20 22 2d 72 65 72 75 6e 22 29 20 22 2c 22 29 g "-rerun") ",")
41c0: 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 09 09 )) ;; FAIL,.....
41d0: 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a (member (test:
41e0: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 get-status testd
41f0: 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29 29 0a at) rerunlst))).
4200: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 ... (set! runf
4210: 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b lag #t)).... ;;
4220: 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20 -keepgoing, do
4230: 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a 09 not rerun FAIL..
4240: 09 09 20 20 28 28 61 6e 64 20 28 61 72 67 73 3a .. ((and (args:
4250: 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f get-arg "-keepgo
4260: 69 6e 67 22 29 0a 09 09 09 09 28 6d 65 6d 62 65 ing").....(membe
4270: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 r (test:get-stat
4280: 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46 us testdat) '("F
4290: 41 49 4c 22 29 29 29 0a 09 09 09 20 20 20 28 73 AIL"))).... (s
42a0: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 et! runflag #f))
42b0: 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6e 6f 74 .... ((and (not
42c0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 (args:get-arg "
42d0: 2d 72 65 72 75 6e 22 29 29 0a 09 09 09 09 28 6d -rerun")).....(m
42e0: 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d ember (test:get-
42f0: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 status testdat)
4300: 27 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 '("FAIL" "n/a"))
4310: 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 ).... (set! ru
4320: 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 nflag #t))....
4330: 28 65 6c 73 65 20 28 73 65 74 21 20 72 75 6e 66 (else (set! runf
4340: 6c 61 67 20 23 66 29 29 29 0a 09 09 09 20 3b 3b lag #f))).... ;;
4350: 20 28 70 72 69 6e 74 20 22 52 55 4e 4e 49 4e 47 (print "RUNNING
4360: 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 => runflag: " r
4370: 75 6e 66 6c 61 67 20 22 20 53 54 41 54 45 3a 20 unflag " STATE:
4380: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 " (test:get-stat
4390: 65 20 74 65 73 74 64 61 74 29 20 22 20 53 54 41 e testdat) " STA
43a0: 54 55 53 3a 20 22 20 28 74 65 73 74 3a 67 65 74 TUS: " (test:get
43b0: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 -status testdat)
43c0: 29 0a 09 09 09 20 28 69 66 20 28 6e 6f 74 20 72 ).... (if (not r
43d0: 75 6e 66 6c 61 67 29 0a 09 09 09 20 20 20 20 20 unflag)....
43e0: 28 69 66 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d (if (not parent-
43f0: 74 65 73 74 29 0a 09 09 09 09 20 28 70 72 69 6e test)..... (prin
4400: 74 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61 t "NOTE: Not sta
4410: 72 74 69 6e 67 20 74 65 73 74 20 22 20 6e 65 77 rting test " new
4420: 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 73 20 -test-name " as
4430: 69 74 20 69 73 20 73 74 61 74 65 20 5c 22 43 4f it is state \"CO
4440: 4d 50 4c 45 54 45 44 5c 22 20 61 6e 64 20 73 74 MPLETED\" and st
4450: 61 74 75 73 20 5c 22 22 20 28 74 65 73 74 3a 67 atus \"" (test:g
4460: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 et-status testda
4470: 74 29 20 22 5c 22 2c 20 75 73 65 20 2d 66 6f 72 t) "\", use -for
4480: 63 65 20 74 6f 20 6f 76 65 72 72 69 64 65 22 29 ce to override")
4490: 29 0a 09 09 09 20 20 20 20 20 28 6c 65 74 2a 20 ).... (let*
44a0: 28 28 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d ((get-prereqs-cm
44b0: 64 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 d (lambda ()....
44c0: 09 09 09 20 20 20 20 20 20 20 28 64 62 2d 67 65 ... (db-ge
44d0: 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 t-prereqs-not-me
44e0: 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74 t db run-id wait
44f0: 6f 6e 29 29 29 20 3b 3b 20 63 68 65 63 6b 20 62 on))) ;; check b
4500: 65 66 6f 72 65 20 72 75 6e 6e 69 6e 67 20 2e 2e efore running ..
4510: 2e 2e 0a 09 09 09 09 20 20 20 20 28 6c 61 75 6e ....... (laun
4520: 63 68 2d 63 6d 64 20 20 20 20 20 20 28 6c 61 6d ch-cmd (lam
4530: 62 64 61 20 28 29 0a 09 09 09 09 09 09 20 20 20 bda ().......
4540: 20 20 20 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 (launch-test
4550: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d db run-id test-
4560: 63 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 conf keyvallst t
4570: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 est-name test-pa
4580: 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a 09 09 th itemdat)))...
4590: 09 09 20 20 20 20 28 74 65 73 74 72 75 6e 64 61 .. (testrunda
45a0: 74 20 20 20 20 20 20 28 6c 69 73 74 20 67 65 74 t (list get
45b0: 2d 70 72 65 72 65 71 73 2d 63 6d 64 20 6c 61 75 -prereqs-cmd lau
45c0: 6e 63 68 2d 63 6d 64 29 29 29 0a 09 09 09 20 20 nch-cmd)))....
45d0: 20 20 20 20 20 28 69 66 20 28 6f 72 20 28 61 72 (if (or (ar
45e0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 gs:get-arg "-for
45f0: 63 65 22 29 0a 09 09 09 09 20 20 20 20 20 20 20 ce").....
4600: 28 6e 75 6c 6c 3f 20 28 28 63 61 72 20 74 65 73 (null? ((car tes
4610: 74 72 75 6e 64 61 74 29 29 29 29 20 3b 3b 20 61 trundat)))) ;; a
4620: 72 65 20 74 68 65 72 65 20 61 6e 79 20 74 65 73 re there any tes
4630: 74 73 20 74 68 61 74 20 6d 75 73 74 20 62 65 20 ts that must be
4640: 72 75 6e 20 62 65 66 6f 72 65 20 74 68 69 73 20 run before this
4650: 6f 6e 65 2e 2e 2e 0a 09 09 09 09 20 20 20 28 28 one........ ((
4660: 63 61 64 72 20 74 65 73 74 72 75 6e 64 61 74 29 cadr testrundat)
4670: 29 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65 ) ;; this is the
4680: 20 6c 69 6e 65 20 74 68 61 74 20 6c 61 75 6e 63 line that launc
4690: 68 65 73 20 74 68 65 20 74 65 73 74 20 74 6f 20 hes the test to
46a0: 74 68 65 20 72 65 6d 6f 74 65 20 68 6f 73 74 0a the remote host.
46b0: 09 09 09 09 20 20 20 28 68 61 73 68 2d 74 61 62 .... (hash-tab
46c0: 6c 65 2d 73 65 74 21 20 2a 77 61 69 74 69 6e 67 le-set! *waiting
46d0: 2d 71 75 65 75 65 2a 20 6e 65 77 2d 74 65 73 74 -queue* new-test
46e0: 2d 6e 61 6d 65 20 74 65 73 74 72 75 6e 64 61 74 -name testrundat
46f0: 29 29 29 29 29 29 0a 09 09 20 20 20 20 20 20 28 ))))))... (
4700: 28 4b 49 4c 4c 45 44 29 20 0a 09 09 20 20 20 20 (KILLED) ...
4710: 20 20 20 28 70 72 69 6e 74 20 22 4e 4f 54 45 3a (print "NOTE:
4720: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 " new-test-name
4730: 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 " is already ru
4740: 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78 70 nning or was exp
4750: 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20 75 lictly killed, u
4760: 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61 75 se -force to lau
4770: 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20 20 20 nch it."))...
4780: 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20 52 45 ((LAUNCHED RE
4790: 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52 55 MOTEHOSTSTART RU
47a0: 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20 20 20 NNING) ...
47b0: 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75 72 (if (> (- (cur
47c0: 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b 20 rent-seconds)(+
47d0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76 65 (db:test-get-eve
47e0: 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61 74 29 nt_time testdat)
47f0: 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 62 3a ....... (db:
4800: 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75 72 test-get-run_dur
4810: 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29 29 29 ation testdat)))
4820: 0a 09 09 09 20 20 20 20 20 20 31 30 30 29 20 3b .... 100) ;
4830: 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74 65 ; i.e. no update
4840: 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 31 for more than 1
4850: 30 30 20 73 65 63 6f 6e 64 73 0a 09 09 09 20 20 00 seconds....
4860: 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 20 (begin....
4870: 28 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a (print "WARNING:
4880: 20 54 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d Test " test-nam
4890: 65 20 22 20 61 70 70 65 61 72 73 20 74 6f 20 62 e " appears to b
48a0: 65 20 64 65 61 64 2e 20 46 6f 72 63 69 6e 67 20 e dead. Forcing
48b0: 69 74 20 74 6f 20 73 74 61 74 65 20 49 4e 43 4f it to state INCO
48c0: 4d 50 4c 45 54 45 20 61 6e 64 20 73 74 61 74 75 MPLETE and statu
48d0: 73 20 53 54 55 43 4b 2f 44 45 41 44 22 29 0a 09 s STUCK/DEAD")..
48e0: 09 09 20 20 20 20 20 28 74 65 73 74 2d 73 65 74 .. (test-set
48f0: 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d -status! db run-
4900: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 22 49 4e id test-name "IN
4910: 43 4f 4d 50 4c 45 54 45 22 20 22 53 54 55 43 4b COMPLETE" "STUCK
4920: 2f 44 45 41 44 22 20 69 74 65 6d 64 61 74 20 22 /DEAD" itemdat "
4930: 54 65 73 74 20 69 73 20 73 74 75 63 6b 20 6f 72 Test is stuck or
4940: 20 64 65 61 64 22 29 29 0a 09 09 09 20 20 20 28 dead")).... (
4950: 70 72 69 6e 74 20 22 4e 4f 54 45 3a 20 22 20 74 print "NOTE: " t
4960: 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c est-name " is al
4970: 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 22 29 29 ready running"))
4980: 29 0a 09 09 20 20 20 20 20 20 28 65 6c 73 65 20 )... (else
4990: 20 20 20 20 20 20 28 70 72 69 6e 74 20 22 45 52 (print "ER
49a0: 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c ROR: Failed to l
49b0: 61 75 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77 aunch test " new
49c0: 2d 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e -test-name ". Un
49d0: 72 65 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65 recognised state
49e0: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 " (test:get-sta
49f0: 74 65 20 74 65 73 74 64 61 74 29 29 29 29 29 29 te testdat))))))
4a00: 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 .. (if (not
4a10: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 (null? tal))...
4a20: 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c (loop (car tal
4a30: 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 )(cdr tal)))))))
4a40: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e ))..(define (run
4a50: 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 -waiting-tests d
4a60: 62 29 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 74 b). (let ((numt
4a70: 72 69 65 73 20 20 20 20 20 20 20 20 20 20 20 30 ries 0
4a80: 29 0a 09 28 6c 61 73 74 2d 74 72 79 2d 74 69 6d )..(last-try-tim
4a90: 65 20 20 20 20 20 20 28 63 75 72 72 65 6e 74 2d e (current-
4aa0: 73 65 63 6f 6e 64 73 29 29 0a 09 28 74 69 6d 65 seconds))..(time
4ab0: 73 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 s (
4ac0: 6c 69 73 74 20 31 29 29 29 20 3b 3b 20 6d 69 6e list 1))) ;; min
4ad0: 75 74 65 73 20 74 6f 20 77 61 69 74 20 62 65 66 utes to wait bef
4ae0: 6f 72 65 20 74 72 79 69 6e 67 20 61 67 61 69 6e ore trying again
4af0: 20 74 6f 20 6b 69 63 6b 20 6f 66 66 20 72 75 6e to kick off run
4b00: 73 0a 20 20 20 20 3b 3b 20 42 55 47 20 74 68 69 s. ;; BUG thi
4b10: 73 20 68 61 63 6b 20 6f 66 20 62 72 75 74 65 20 s hack of brute
4b20: 66 6f 72 63 65 20 72 65 74 72 79 69 6e 67 20 77 force retrying w
4b30: 6f 72 6b 73 20 71 75 69 74 65 20 77 65 6c 6c 20 orks quite well
4b40: 66 6f 72 20 6d 61 6e 79 20 63 61 73 65 73 20 62 for many cases b
4b50: 75 74 20 0a 20 20 20 20 3b 3b 20 20 20 20 20 77 ut . ;; w
4b60: 68 61 74 20 69 73 20 6e 65 65 64 65 64 20 69 73 hat is needed is
4b70: 20 74 6f 20 63 68 65 63 6b 20 74 68 65 20 64 62 to check the db
4b80: 20 66 6f 72 20 74 65 73 74 73 20 74 68 61 74 20 for tests that
4b90: 68 61 76 65 20 66 61 69 6c 65 64 20 6c 65 73 73 have failed less
4ba0: 20 74 68 61 6e 0a 20 20 20 20 3b 3b 20 20 20 20 than. ;;
4bb0: 20 4e 20 74 69 6d 65 73 20 6f 72 20 6e 65 76 65 N times or neve
4bc0: 72 20 62 65 65 6e 20 73 74 61 72 74 65 64 20 61 r been started a
4bd0: 6e 64 20 6b 69 63 6b 20 74 68 65 6d 20 6f 66 66 nd kick them off
4be0: 20 61 67 61 69 6e 0a 20 20 20 20 28 6c 65 74 20 again. (let
4bf0: 6c 6f 6f 70 20 28 28 77 61 69 74 69 6e 67 2d 74 loop ((waiting-t
4c00: 65 73 74 2d 6e 61 6d 65 73 20 28 68 61 73 68 2d est-names (hash-
4c10: 74 61 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 table-keys *wait
4c20: 69 6e 67 2d 71 75 65 75 65 2a 29 29 29 0a 20 20 ing-queue*))).
4c30: 20 20 20 20 28 63 6f 6e 64 0a 20 20 20 20 20 20 (cond.
4c40: 20 28 28 6e 6f 74 20 28 72 75 6e 73 3a 63 61 6e ((not (runs:can
4c50: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 -run-more-tests
4c60: 64 62 29 29 0a 09 28 73 6c 65 65 70 20 32 29 0a db))..(sleep 2).
4c70: 09 28 6c 6f 6f 70 20 77 61 69 74 69 6e 67 2d 74 .(loop waiting-t
4c80: 65 73 74 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20 est-names)).
4c90: 20 20 20 28 28 6e 75 6c 6c 3f 20 77 61 69 74 69 ((null? waiti
4ca0: 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09 ng-test-names)..
4cb0: 28 70 72 69 6e 74 20 22 41 6c 6c 20 74 65 73 74 (print "All test
4cc0: 73 20 6c 61 75 6e 63 68 65 64 22 29 29 0a 20 20 s launched")).
4cd0: 20 20 20 20 20 28 65 6c 73 65 0a 09 28 73 65 74 (else..(set
4ce0: 21 20 6e 75 6d 74 72 69 65 73 20 28 2b 20 6e 75 ! numtries (+ nu
4cf0: 6d 74 72 69 65 73 20 31 29 29 0a 09 28 66 6f 72 mtries 1))..(for
4d00: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 74 -each (lambda (t
4d10: 65 73 74 6e 61 6d 65 29 0a 09 09 20 20 20 20 28 estname)... (
4d20: 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e if (runs:can-run
4d30: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a -more-tests db).
4d40: 09 09 09 28 6c 65 74 2a 20 28 28 74 65 73 74 64 ...(let* ((testd
4d50: 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 at (hash-table-r
4d60: 65 66 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 ef *waiting-queu
4d70: 65 2a 20 74 65 73 74 6e 61 6d 65 29 29 0a 09 09 e* testname))...
4d80: 09 20 20 20 20 20 20 20 28 70 72 65 72 65 71 73 . (prereqs
4d90: 20 28 28 63 61 72 20 74 65 73 74 64 61 74 29 29 ((car testdat))
4da0: 29 0a 09 09 09 20 20 20 20 20 20 20 28 6c 64 62 ).... (ldb
4db0: 20 20 20 20 20 28 69 66 20 64 62 20 64 62 20 28 (if db db (
4dc0: 6f 70 65 6e 2d 64 62 29 29 29 29 0a 09 09 09 20 open-db))))....
4dd0: 20 3b 3b 20 28 70 72 69 6e 74 20 22 70 72 65 72 ;; (print "prer
4de0: 65 71 73 20 72 65 6d 61 69 6e 69 6e 67 3a 20 22 eqs remaining: "
4df0: 20 70 72 65 72 65 71 73 29 0a 09 09 09 20 20 28 prereqs).... (
4e00: 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65 71 if (null? prereq
4e10: 73 29 0a 09 09 09 20 20 20 20 20 20 28 62 65 67 s).... (beg
4e20: 69 6e 0a 09 09 09 09 28 70 72 69 6e 74 20 22 50 in.....(print "P
4e30: 72 65 72 65 71 75 69 73 69 74 65 73 20 6d 65 74 rerequisites met
4e40: 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22 20 74 65 , launching " te
4e50: 73 74 6e 61 6d 65 29 0a 09 09 09 09 28 28 63 61 stname).....((ca
4e60: 64 72 20 74 65 73 74 64 61 74 29 29 0a 09 09 09 dr testdat))....
4e70: 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 64 65 6c .(hash-table-del
4e80: 65 74 65 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 ete! *waiting-qu
4e90: 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29 29 eue* testname)))
4ea0: 0a 09 09 09 20 20 28 69 66 20 28 6e 6f 74 20 64 .... (if (not d
4eb0: 62 29 0a 09 09 09 20 20 20 20 20 20 28 73 71 6c b).... (sql
4ec0: 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 6c ite3:finalize! l
4ed0: 64 62 29 29 29 29 29 0a 09 09 20 20 77 61 69 74 db)))))... wait
4ee0: 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a ing-test-names).
4ef0: 09 3b 3b 20 28 73 6c 65 65 70 20 31 30 29 20 3b .;; (sleep 10) ;
4f00: 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e 20 72 75 ; no point in ru
4f10: 73 68 69 6e 67 20 74 68 69 6e 67 73 20 61 74 20 shing things at
4f20: 74 68 69 73 20 73 74 61 67 65 3f 0a 09 28 6c 6f this stage?..(lo
4f30: 6f 70 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b op (hash-table-k
4f40: 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 eys *waiting-que
4f50: 75 65 2a 29 29 29 29 29 29 29 0a 0a 28 64 65 66 ue*)))))))..(def
4f60: 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75 70 2d ine (get-dir-up-
4f70: 6f 6e 65 20 64 69 72 29 20 0a 20 20 28 6c 65 74 one dir) . (let
4f80: 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69 ((dparts (stri
4f90: 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22 2f 22 ng-split dir "/"
4fa0: 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f ))). (conc "/
4fb0: 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 " (string-inters
4fc0: 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20 28 perse .. (
4fd0: 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 take dparts (- (
4fe0: 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 31 length dparts) 1
4ff0: 29 29 0a 09 20 20 20 20 20 20 20 22 2f 22 29 29 )).. "/"))
5000: 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72 75 6e )).;; Remove run
5010: 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72 65 20 s.;; fields are
5020: 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72 6f 75 passing in throu
5030: 67 68 20 0a 28 64 65 66 69 6e 65 20 28 72 75 6e gh .(define (run
5040: 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20 64 62 s:remove-runs db
5050: 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74 65 73 runnamepatt tes
5060: 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29 0a tpatt itempatt).
5070: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 (let* ((keys
5080: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 (db-get-ke
5090: 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e 64 61 ys db)).. (runda
50a0: 74 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65 74 t (runs:get
50b0: 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 -runs-by-patt db
50c0: 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 keys runnamepat
50d0: 74 29 29 0a 09 20 28 68 65 61 64 65 72 20 20 20 t)).. (header
50e0: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 72 (vector-ref r
50f0: 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72 75 6e undat 0)).. (run
5100: 73 20 20 20 20 20 20 20 20 28 76 65 63 74 6f 72 s (vector
5110: 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29 29 29 -ref rundat 1)))
5120: 0a 20 20 20 20 28 70 72 69 6e 74 20 22 48 65 61 . (print "Hea
5130: 64 65 72 3a 20 22 20 68 65 61 64 65 72 29 0a 20 der: " header).
5140: 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 (for-each.
5150: 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a (lambda (run).
5160: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75 (let ((ru
5170: 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 nkey (string-int
5180: 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c ersperse (map (l
5190: 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09 09 09 ambda (k).......
51a0: 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62 79 (db-get-value-by
51b0: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 -header run head
51c0: 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b er (vector-ref k
51d0: 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f 22 29 0))) keys) "/")
51e0: 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 72 75 6e )).. (let* ((run
51f0: 2d 69 64 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 -id (db-get-valu
5200: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 e-by-header run
5210: 68 65 61 64 65 72 20 22 69 64 22 29 20 29 0a 09 header "id") )..
5220: 09 28 74 65 73 74 73 20 20 28 64 62 2d 67 65 74 .(tests (db-get
5230: 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 -tests-for-run d
5240: 62 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d b (db-get-value-
5250: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 by-header run he
5260: 61 64 65 72 20 22 69 64 22 29 20 74 65 73 74 70 ader "id") testp
5270: 61 74 74 20 69 74 65 6d 70 61 74 74 29 29 0a 09 att itempatt))..
5280: 09 28 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f .(lasttpath "/do
5290: 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 es/not/exist/I/h
52a0: 6f 70 65 22 29 29 0a 09 20 20 20 28 69 66 20 28 ope")).. (if (
52b0: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 not (null? tests
52c0: 29 29 0a 09 20 20 20 20 20 20 20 28 62 65 67 69 )).. (begi
52d0: 6e 0a 09 09 20 28 70 72 69 6e 74 20 22 52 65 6d n... (print "Rem
52e0: 6f 76 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 oving tests for
52f0: 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 run: " runkey "
5300: 22 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d " (db-get-value-
5310: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 by-header run he
5320: 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 ader "runname"))
5330: 0a 09 09 20 28 66 6f 72 2d 65 61 63 68 0a 09 09 ... (for-each...
5340: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 29 (lambda (test)
5350: 0a 09 09 20 20 20 20 28 70 72 69 6e 74 20 22 20 ... (print "
5360: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d " (db:test-get-
5370: 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 20 22 testname test) "
5380: 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73 74 2d id: " (db:test-
5390: 67 65 74 2d 69 64 20 74 65 73 74 29 20 22 20 22 get-id test) " "
53a0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 (db:test-get-it
53b0: 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09 em-path test))..
53c0: 09 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d . (db:delete-
53d0: 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62 20 test-records db
53e0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 (db:test-get-id
53f0: 74 65 73 74 29 29 0a 09 09 20 20 20 20 28 69 66 test))... (if
5400: 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67 (> (string-leng
5410: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d th (db:test-get-
5420: 72 75 6e 64 69 72 20 74 65 73 74 29 29 20 35 29 rundir test)) 5)
5430: 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74 69 ;; bad heuristi
5440: 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72 65 c but should pre
5450: 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65 20 vent /tmp /home
5460: 65 74 63 2e 0a 09 09 09 28 6c 65 74 20 28 28 66 etc.....(let ((f
5470: 75 6c 6c 70 61 74 68 20 28 64 62 3a 74 65 73 74 ullpath (db:test
5480: 2d 67 65 74 2d 72 75 6e 64 69 72 20 74 65 73 74 -get-rundir test
5490: 29 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a 74 ))) ;; "/" (db:t
54a0: 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 est-get-item-pat
54b0: 68 20 74 65 73 74 29 29 29 29 0a 09 09 09 20 20 h test))))....
54c0: 28 73 65 74 21 20 6c 61 73 74 74 70 61 74 68 20 (set! lasttpath
54d0: 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20 28 fullpath).... (
54e0: 70 72 69 6e 74 20 22 72 6d 20 2d 72 66 20 22 20 print "rm -rf "
54f0: 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20 28 fullpath).... (
5500: 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d system (conc "rm
5510: 20 2d 72 66 20 22 20 66 75 6c 6c 70 61 74 68 29 -rf " fullpath)
5520: 29 0a 09 09 09 20 20 28 6c 65 74 20 28 28 63 6d ).... (let ((cm
5530: 64 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d d (conc "rmdir -
5540: 70 20 22 20 28 67 65 74 2d 64 69 72 2d 75 70 2d p " (get-dir-up-
5550: 6f 6e 65 20 66 75 6c 6c 70 61 74 68 29 29 29 29 one fullpath))))
5560: 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20 63 .... (print c
5570: 6d 64 29 0a 09 09 09 20 20 20 20 28 73 79 73 74 md).... (syst
5580: 65 6d 20 63 6d 64 29 29 0a 09 09 09 20 20 29 29 em cmd)).... ))
5590: 29 0a 09 09 20 20 74 65 73 74 73 29 29 29 0a 09 )... tests)))..
55a0: 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73 (let ((remtes
55b0: 74 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 ts (db-get-tests
55c0: 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 2d -for-run db (db-
55d0: 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 get-value-by-hea
55e0: 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 der run header "
55f0: 69 64 22 29 29 29 29 0a 09 20 20 20 20 20 28 69 id")))).. (i
5600: 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 f (null? remtest
5610: 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 s) ;; no more te
5620: 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09 sts remaining...
5630: 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20 (let* ((dparts
5640: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c (string-split l
5650: 61 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09 asttpath "/"))..
5660: 09 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 ..(runpath (conc
5670: 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 "/" (string-int
5680: 65 72 73 70 65 72 73 65 20 0a 09 09 09 09 09 20 ersperse ......
5690: 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 (take dparts
56a0: 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 (- (length dpart
56b0: 73 29 20 31 29 29 0a 09 09 09 09 09 20 20 20 20 s) 1))......
56c0: 22 2f 22 29 29 29 29 0a 09 09 20 20 20 28 70 72 "/"))))... (pr
56d0: 69 6e 74 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 int "Removing ru
56e0: 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 n: " runkey " "
56f0: 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62 79 (db-get-value-by
5700: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 -header run head
5710: 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 er "runname"))..
5720: 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 72 . (db:delete-r
5730: 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09 09 un db run-id)...
5740: 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66 69 ;; need to fi
5750: 67 75 72 65 20 6f 75 74 20 74 68 65 20 70 61 74 gure out the pat
5760: 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69 72 h to the run dir
5770: 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20 69 and remove it i
5780: 66 20 65 6d 70 74 79 0a 09 09 3b 3b 20 20 20 20 f empty...;;
5790: 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67 6c 6f 62 (if (null? (glob
57a0: 20 28 63 6f 6e 63 20 72 75 6e 70 61 74 68 20 22 (conc runpath "
57b0: 2f 2a 22 29 29 29 0a 09 09 3b 3b 20 20 20 20 20 /*")))...;;
57c0: 20 20 20 28 62 65 67 69 6e 0a 09 09 3b 3b 20 09 (begin...;; .
57d0: 20 28 70 72 69 6e 74 20 22 52 65 6d 6f 76 69 6e (print "Removin
57e0: 67 20 72 75 6e 20 64 69 72 20 22 20 72 75 6e 70 g run dir " runp
57f0: 61 74 68 29 0a 09 09 3b 3b 20 09 20 28 73 79 73 ath)...;; . (sys
5800: 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 tem (conc "rmdir
5810: 20 2d 70 20 22 20 72 75 6e 70 61 74 68 29 29 29 -p " runpath)))
5820: 29 0a 09 09 20 20 20 29 29 29 0a 09 09 20 29 29 )... )))... ))
5830: 29 0a 20 20 20 20 20 72 75 6e 73 29 29 29 0a 0a ). runs)))..