Megatest

Hex Artifact Content
Login

Artifact 044d7bead54c5027dbf5be3341b3611b063e9147:


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 46 41 49 4c 22 29 29 29 0a 09 28 62 65 67 69  "FAIL")))..(begi
0fe0: 6e 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78  n..  (sqlite3:ex
0ff0: 65 63 75 74 65 20 0a 09 20 20 20 64 62 0a 09 20  ecute ..   db.. 
1000: 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20    "UPDATE tests 
1010: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53 45  .             SE
1020: 54 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 28 53 45  T fail_count=(SE
1030: 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46  LECT count(id) F
1040: 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20  ROM tests WHERE 
1050: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
1060: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
1070: 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20  _path != '' AND 
1080: 73 74 61 74 75 73 3d 27 46 41 49 4c 27 29 2c 0a  status='FAIL'),.
1090: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10a0: 20 70 61 73 73 5f 63 6f 75 6e 74 3d 28 53 45 4c   pass_count=(SEL
10b0: 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52  ECT count(id) FR
10c0: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
10d0: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
10e0: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
10f0: 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20 73  path != '' AND s
1100: 74 61 74 75 73 3d 27 50 41 53 53 27 29 0a 20 20  tatus='PASS').  
1110: 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52 45             WHERE
1120: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
1130: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
1140: 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20 20  m_path='';"..   
1150: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
1160: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1170: 65 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  e run-id test-na
1180: 6d 65 29 0a 09 20 20 28 73 71 6c 69 74 65 33 3a  me)..  (sqlite3:
1190: 65 78 65 63 75 74 65 0a 09 20 20 20 64 62 0a 09  execute..   db..
11a0: 20 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73     "UPDATE tests
11b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53 45  .             SE
11c0: 54 20 73 74 61 74 65 3d 27 43 4f 4d 50 4c 45 54  T state='COMPLET
11d0: 45 44 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  ED',.           
11e0: 20 20 20 20 20 73 74 61 74 75 73 3d 43 41 53 45       status=CASE
11f0: 20 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75 6e 74   WHEN fail_count
1200: 20 3e 20 30 20 54 48 45 4e 20 27 46 41 49 4c 27   > 0 THEN 'FAIL'
1210: 20 57 48 45 4e 20 70 61 73 73 5f 63 6f 75 6e 74   WHEN pass_count
1220: 20 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f 63 6f   > 0 AND fail_co
1230: 75 6e 74 3d 30 20 54 48 45 4e 20 27 50 41 53 53  unt=0 THEN 'PASS
1240: 27 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e 27  ' ELSE 'UNKNOWN'
1250: 20 45 4e 44 0a 20 20 20 20 20 20 20 20 20 20 20   END.           
1260: 20 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f    WHERE run_id=?
1270: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
1280: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27  AND item_path=''
1290: 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64 20 74 65  ;"..   run-id te
12a0: 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28  st-name))).    (
12b0: 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e 75  if (and (not (nu
12c0: 6c 6c 3f 20 63 6f 6d 6d 65 6e 74 29 29 0a 09 20  ll? comment)).. 
12d0: 20 20 20 20 28 63 61 72 20 63 6f 6d 6d 65 6e 74      (car comment
12e0: 29 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78 65  ))..(sqlite3:exe
12f0: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
1300: 74 65 73 74 73 20 53 45 54 20 63 6f 6d 6d 65 6e  tests SET commen
1310: 74 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64  t=? WHERE run_id
1320: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
1330: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
1340: 3f 3b 22 0a 09 09 09 20 28 63 61 72 20 63 6f 6d  ?;".... (car com
1350: 6d 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65 73  ment) run-id tes
1360: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
1370: 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74  ))))..(define (t
1380: 65 73 74 2d 73 65 74 2d 6c 6f 67 21 20 64 62 20  est-set-log! db 
1390: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
13a0: 20 69 74 65 6d 64 61 74 20 6c 6f 67 66 29 20 0a   itemdat logf) .
13b0: 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61    (let ((item-pa
13c0: 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70  th (item-list->p
13d0: 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a 20  ath itemdat))). 
13e0: 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63     (sqlite3:exec
13f0: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74  ute db "UPDATE t
1400: 65 73 74 73 20 53 45 54 20 66 69 6e 61 6c 5f 6c  ests SET final_l
1410: 6f 67 66 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f  ogf=? WHERE run_
1420: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
1430: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
1440: 68 3d 3f 3b 22 20 0a 09 09 20 20 20 20 20 6c 6f  h=?;" ...     lo
1450: 67 66 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  gf run-id test-n
1460: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ame item-path)))
1470: 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20 43 6f  ..;; ;; TODO: Co
1480: 6e 76 65 72 67 65 20 74 68 69 73 20 77 69 74 68  nverge this with
1490: 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66   db:get-test-inf
14a0: 6f 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28 72 75  o.;; (define (ru
14b0: 6e 73 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f  ns:get-test-info
14c0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
14d0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a  name item-path).
14e0: 3b 3b 20 20 20 28 6c 65 74 20 28 28 72 65 73 20  ;;   (let ((res 
14f0: 23 66 29 29 20 3b 3b 20 28 76 65 63 74 6f 72 20  #f)) ;; (vector 
1500: 23 66 20 23 66 20 23 66 20 23 66 20 23 66 20 23  #f #f #f #f #f #
1510: 66 29 29 29 0a 3b 3b 20 20 20 20 20 28 73 71 6c  f))).;;     (sql
1520: 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f  ite3:for-each-ro
1530: 77 20 0a 3b 3b 20 20 20 20 20 20 28 6c 61 6d 62  w .;;      (lamb
1540: 64 61 20 28 69 64 20 72 75 6e 2d 69 64 20 74 65  da (id run-id te
1550: 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74  st-name state st
1560: 61 74 75 73 29 0a 3b 3b 20 20 20 20 20 20 20 20  atus).;;        
1570: 28 73 65 74 21 20 72 65 73 20 28 76 65 63 74 6f  (set! res (vecto
1580: 72 20 69 64 20 72 75 6e 2d 69 64 20 74 65 73 74  r id run-id test
1590: 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74  -name state stat
15a0: 75 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a  us item-path))).
15b0: 3b 3b 20 20 20 20 20 20 64 62 20 22 53 45 4c 45  ;;      db "SELE
15c0: 43 54 20 69 64 2c 72 75 6e 5f 69 64 2c 74 65 73  CT id,run_id,tes
15d0: 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  tname,state,stat
15e0: 75 73 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48  us FROM tests WH
15f0: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44  ERE run_id=? AND
1600: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20   testname=? AND 
1610: 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 3b 3b  item_path=?;".;;
1620: 20 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65 73        run-id tes
1630: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
1640: 29 0a 3b 3b 20 20 20 20 20 72 65 73 29 29 0a 0a  ).;;     res))..
1650: 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28  (define-inline (
1660: 74 65 73 74 3a 67 65 74 2d 69 64 20 76 65 63 29  test:get-id vec)
1670: 20 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72         (vector-r
1680: 65 66 20 76 65 63 20 30 29 29 0a 28 64 65 66 69  ef vec 0)).(defi
1690: 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a  ne-inline (test:
16a0: 67 65 74 2d 72 75 6e 5f 69 64 20 76 65 63 29 20  get-run_id vec) 
16b0: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65    (vector-ref ve
16c0: 63 20 31 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e  c 1)).(define-in
16d0: 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 74  line (test:get-t
16e0: 65 73 74 2d 6e 61 6d 65 20 76 65 63 29 28 76 65  est-name vec)(ve
16f0: 63 74 6f 72 2d 72 65 66 20 76 65 63 20 32 29 29  ctor-ref vec 2))
1700: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20  .(define-inline 
1710: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
1720: 76 65 63 29 20 20 20 20 28 76 65 63 74 6f 72 2d  vec)    (vector-
1730: 72 65 66 20 76 65 63 20 33 29 29 0a 28 64 65 66  ref vec 3)).(def
1740: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74  ine-inline (test
1750: 3a 67 65 74 2d 73 74 61 74 75 73 20 76 65 63 29  :get-status vec)
1760: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76     (vector-ref v
1770: 65 63 20 34 29 29 0a 28 64 65 66 69 6e 65 2d 69  ec 4)).(define-i
1780: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d  nline (test:get-
1790: 69 74 65 6d 2d 70 61 74 68 20 76 65 63 29 28 76  item-path vec)(v
17a0: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 35 29  ector-ref vec 5)
17b0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  )..(define (runs
17c0: 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d 70  :test-get-full-p
17d0: 61 74 68 20 74 65 73 74 29 0a 20 20 28 6c 65 74  ath test).  (let
17e0: 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 28 64 62  * ((testname (db
17f0: 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61  :test-get-testna
1800: 6d 65 20 20 20 74 65 73 74 29 29 0a 09 20 28 69  me   test)).. (i
1810: 74 65 6d 70 61 74 68 20 28 64 62 3a 74 65 73 74  tempath (db:test
1820: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
1830: 65 73 74 29 29 29 0a 20 20 20 20 28 63 6f 6e 63  est))).    (conc
1840: 20 74 65 73 74 6e 61 6d 65 20 28 69 66 20 28 65   testname (if (e
1850: 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 22  qual? itempath "
1860: 22 29 20 22 22 20 28 63 6f 6e 63 20 22 28 22 20  ") "" (conc "(" 
1870: 69 74 65 6d 70 61 74 68 20 22 29 22 29 29 29 29  itempath ")"))))
1880: 29 0a 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e  )..(define-inlin
1890: 65 20 28 74 65 73 74 3a 74 65 73 74 2d 67 65 74  e (test:test-get
18a0: 2d 66 75 6c 6c 6e 61 6d 65 20 74 65 73 74 29 0a  -fullname test).
18b0: 20 20 20 28 63 6f 6e 63 20 28 64 62 3a 74 65 73     (conc (db:tes
18c0: 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74  t-get-testname t
18d0: 65 73 74 29 0a 09 20 28 69 66 20 28 65 71 75 61  est).. (if (equa
18e0: 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  l? (db:test-get-
18f0: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 20  item-path test) 
1900: 22 22 29 0a 09 20 20 20 20 20 22 22 0a 09 20 20  "")..     ""..  
1910: 20 20 20 28 63 6f 6e 63 20 22 28 22 20 28 64 62     (conc "(" (db
1920: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70  :test-get-item-p
1930: 61 74 68 20 74 65 73 74 29 20 22 29 22 29 29 29  ath test) ")")))
1940: 29 0a 0a 28 64 65 66 69 6e 65 20 28 63 68 65 63  )..(define (chec
1950: 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 63 6c  k-valid-items cl
1960: 61 73 73 20 69 74 65 6d 29 0a 20 20 28 6c 65 74  ass item).  (let
1970: 20 28 28 76 61 6c 69 64 2d 76 61 6c 75 65 73 20   ((valid-values 
1980: 28 6c 65 74 20 28 28 73 20 28 63 6f 6e 66 69 67  (let ((s (config
1990: 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64  -lookup *configd
19a0: 61 74 2a 20 22 76 61 6c 69 64 76 61 6c 75 65 73  at* "validvalues
19b0: 22 20 63 6c 61 73 73 29 29 29 0a 09 09 09 28 69  " class)))....(i
19c0: 66 20 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  f s (string-spli
19d0: 74 20 73 29 20 23 66 29 29 29 29 0a 20 20 20 20  t s) #f)))).    
19e0: 28 69 66 20 76 61 6c 69 64 2d 76 61 6c 75 65 73  (if valid-values
19f0: 0a 09 28 69 66 20 28 6d 65 6d 62 65 72 20 69 74  ..(if (member it
1a00: 65 6d 20 76 61 6c 69 64 2d 76 61 6c 75 65 73 29  em valid-values)
1a10: 0a 09 20 20 20 20 69 74 65 6d 20 23 66 29 0a 09  ..    item #f)..
1a20: 69 74 65 6d 29 29 29 0a 0a 28 64 65 66 69 6e 65  item)))..(define
1a30: 20 28 74 65 73 74 73 74 65 70 2d 73 65 74 2d 73   (teststep-set-s
1a40: 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64  tatus! db run-id
1a50: 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 73   test-name tests
1a60: 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65 2d 69  tep-name state-i
1a70: 6e 20 73 74 61 74 75 73 2d 69 6e 20 69 74 65 6d  n status-in item
1a80: 64 61 74 20 63 6f 6d 6d 65 6e 74 29 0a 20 20 3b  dat comment).  ;
1a90: 3b 20 28 70 72 69 6e 74 20 22 72 75 6e 2d 69 64  ; (print "run-id
1aa0: 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73  : " run-id " tes
1ab0: 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e  t-name: " test-n
1ac0: 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73  ame).  (let* ((s
1ad0: 74 61 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d  tate     (check-
1ae0: 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61  valid-items "sta
1af0: 74 65 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09  te" state-in))..
1b00: 20 28 73 74 61 74 75 73 20 20 20 20 28 63 68 65   (status    (che
1b10: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22  ck-valid-items "
1b20: 73 74 61 74 75 73 22 20 73 74 61 74 75 73 2d 69  status" status-i
1b30: 6e 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68  n)).. (item-path
1b40: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
1b50: 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74  h itemdat)).. (t
1b60: 65 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74  estdat   (db:get
1b70: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
1b80: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
1b90: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
1ba0: 3b 3b 20 28 70 72 69 6e 74 20 22 74 65 73 74 64  ;; (print "testd
1bb0: 61 74 3a 20 22 20 74 65 73 74 64 61 74 29 0a 20  at: " testdat). 
1bc0: 20 20 20 28 69 66 20 28 61 6e 64 20 74 65 73 74     (if (and test
1bd0: 64 61 74 20 3b 3b 20 69 66 20 74 68 65 20 73 65  dat ;; if the se
1be0: 63 74 69 6f 6e 20 65 78 69 73 74 73 20 74 68 65  ction exists the
1bf0: 6e 20 66 6f 72 63 65 20 73 70 65 63 69 66 69 63  n force specific
1c00: 61 74 69 6f 6e 20 42 55 47 2c 20 49 20 64 6f 6e  ation BUG, I don
1c10: 27 74 20 6c 69 6b 65 20 68 6f 77 20 74 68 69 73  't like how this
1c20: 20 77 6f 72 6b 73 2e 0a 09 20 20 20 20 20 28 6f   works...     (o
1c30: 72 20 28 6e 6f 74 20 73 74 61 74 65 29 28 6e 6f  r (not state)(no
1c40: 74 20 73 74 61 74 75 73 29 29 29 0a 09 28 70 72  t status)))..(pr
1c50: 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20 49 6e  int "WARNING: In
1c60: 76 61 6c 69 64 20 22 20 28 69 66 20 73 74 61 74  valid " (if stat
1c70: 75 73 20 22 73 74 61 74 75 73 22 20 22 73 74 61  us "status" "sta
1c80: 74 65 22 29 0a 09 20 20 20 20 20 20 20 22 20 76  te")..       " v
1c90: 61 6c 75 65 20 5c 22 22 20 28 69 66 20 73 74 61  alue \"" (if sta
1ca0: 74 75 73 20 73 74 61 74 75 73 2d 69 6e 20 73 74  tus status-in st
1cb0: 61 74 65 2d 69 6e 29 20 22 5c 22 2c 20 75 70 64  ate-in) "\", upd
1cc0: 61 74 65 20 79 6f 75 72 20 76 61 6c 69 64 73 74  ate your validst
1cd0: 61 74 65 73 20 73 65 63 74 69 6f 6e 20 69 6e 20  ates section in 
1ce0: 6d 65 67 61 74 65 73 74 2e 63 6f 6e 66 69 67 22  megatest.config"
1cf0: 29 29 0a 20 20 20 20 28 69 66 20 74 65 73 74 64  )).    (if testd
1d00: 61 74 0a 09 28 6c 65 74 20 28 28 74 65 73 74 2d  at..(let ((test-
1d10: 69 64 20 28 74 65 73 74 3a 67 65 74 2d 69 64 20  id (test:get-id 
1d20: 74 65 73 74 64 61 74 29 29 29 0a 09 20 20 28 73  testdat)))..  (s
1d30: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64  qlite3:execute d
1d40: 62 20 0a 09 09 09 22 49 4e 53 45 52 54 20 4f 52  b ...."INSERT OR
1d50: 20 52 45 50 4c 41 43 45 20 69 6e 74 6f 20 74 65   REPLACE into te
1d60: 73 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f 69  st_steps (test_i
1d70: 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65  d,stepname,state
1d80: 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69  ,status,event_ti
1d90: 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 56 41 4c 55  me,comment) VALU
1da0: 45 53 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74  ES(?,?,?,?,strft
1db0: 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c  ime('%s','now'),
1dc0: 3f 29 3b 22 0a 09 09 09 74 65 73 74 2d 69 64 20  ?);"....test-id 
1dd0: 74 65 73 74 73 74 65 70 2d 6e 61 6d 65 20 73 74  teststep-name st
1de0: 61 74 65 20 73 74 61 74 75 73 20 28 69 66 20 63  ate status (if c
1df0: 6f 6d 6d 65 6e 74 20 63 6f 6d 6d 65 6e 74 20 22  omment comment "
1e00: 22 29 29 29 0a 09 28 70 72 69 6e 74 20 22 45 52  ")))..(print "ER
1e10: 52 4f 52 3a 20 43 61 6e 27 74 20 75 70 64 61 74  ROR: Can't updat
1e20: 65 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  e " test-name " 
1e30: 66 6f 72 20 72 75 6e 20 22 20 72 75 6e 2d 69 64  for run " run-id
1e40: 20 22 20 2d 3e 20 6e 6f 20 73 75 63 68 20 74 65   " -> no such te
1e50: 73 74 20 69 6e 20 64 62 22 29 29 29 29 0a 0a 28  st in db"))))..(
1e60: 64 65 66 69 6e 65 20 28 74 65 73 74 2d 67 65 74  define (test-get
1e70: 2d 6b 69 6c 6c 2d 72 65 71 75 65 73 74 20 64 62  -kill-request db
1e80: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1e90: 65 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65  e itemdat).  (le
1ea0: 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28  t* ((item-path (
1eb0: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
1ec0: 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74 65 73  itemdat)).. (tes
1ed0: 74 64 61 74 20 20 20 28 64 62 3a 67 65 74 2d 74  tdat   (db:get-t
1ee0: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  est-info db run-
1ef0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
1f00: 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 28 65  m-path))).    (e
1f10: 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d  qual? (test:get-
1f20: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22  state testdat) "
1f30: 4b 49 4c 4c 52 45 51 22 29 29 29 0a 0a 28 64 65  KILLREQ")))..(de
1f40: 66 69 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 6d  fine (test-set-m
1f50: 65 74 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  eta-info db run-
1f60: 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d  id testname item
1f70: 64 61 74 29 0a 20 20 28 6c 65 74 20 28 28 69 74  dat).  (let ((it
1f80: 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69  em-path (item-li
1f90: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74  st->path itemdat
1fa0: 29 29 0a 09 28 63 70 75 6c 6f 61 64 20 20 28 67  ))..(cpuload  (g
1fb0: 65 74 2d 63 70 75 2d 6c 6f 61 64 29 29 0a 09 28  et-cpu-load))..(
1fc0: 68 6f 73 74 6e 61 6d 65 20 28 67 65 74 2d 68 6f  hostname (get-ho
1fd0: 73 74 2d 6e 61 6d 65 29 29 0a 09 28 64 69 73 6b  st-name))..(disk
1fe0: 66 72 65 65 20 28 67 65 74 2d 64 66 20 28 63 75  free (get-df (cu
1ff0: 72 72 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 29  rrent-directory)
2000: 29 29 0a 09 28 75 6e 61 6d 65 20 20 20 20 28 67  ))..(uname    (g
2010: 65 74 2d 75 6e 61 6d 65 20 22 2d 73 72 76 70 69  et-uname "-srvpi
2020: 6f 22 29 29 0a 09 28 72 75 6e 70 61 74 68 20 20  o"))..(runpath  
2030: 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74 6f  (current-directo
2040: 72 79 29 29 29 0a 20 20 20 20 28 73 71 6c 69 74  ry))).    (sqlit
2050: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
2060: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
2070: 68 6f 73 74 3d 3f 2c 63 70 75 6c 6f 61 64 3d 3f  host=?,cpuload=?
2080: 2c 64 69 73 6b 66 72 65 65 3d 3f 2c 75 6e 61 6d  ,diskfree=?,unam
2090: 65 3d 3f 2c 72 75 6e 64 69 72 3d 3f 20 57 48 45  e=?,rundir=? WHE
20a0: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
20b0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
20c0: 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 09 09 20  tem_path=?;"... 
20d0: 20 68 6f 73 74 6e 61 6d 65 0a 09 09 20 20 63 70   hostname...  cp
20e0: 75 6c 6f 61 64 0a 09 09 20 20 64 69 73 6b 66 72  uload...  diskfr
20f0: 65 65 0a 09 09 20 20 75 6e 61 6d 65 0a 09 09 20  ee...  uname... 
2100: 20 72 75 6e 70 61 74 68 0a 09 09 20 20 72 75 6e   runpath...  run
2110: 2d 69 64 0a 09 09 20 20 74 65 73 74 6e 61 6d 65  -id...  testname
2120: 0a 09 09 20 20 69 74 65 6d 2d 70 61 74 68 29 29  ...  item-path))
2130: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
2140: 2d 75 70 64 61 74 65 2d 6d 65 74 61 2d 69 6e 66  -update-meta-inf
2150: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
2160: 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6d 69 6e  name itemdat min
2170: 75 74 65 73 29 0a 20 20 28 6c 65 74 20 28 28 69  utes).  (let ((i
2180: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  tem-path (item-l
2190: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
21a0: 74 29 29 0a 09 28 63 70 75 6c 6f 61 64 20 20 28  t))..(cpuload  (
21b0: 67 65 74 2d 63 70 75 2d 6c 6f 61 64 29 29 0a 09  get-cpu-load))..
21c0: 28 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64  (diskfree (get-d
21d0: 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63  f (current-direc
21e0: 74 6f 72 79 29 29 29 29 0a 20 20 20 20 28 69 66  tory)))).    (if
21f0: 20 28 6e 6f 74 20 63 70 75 6c 6f 61 64 29 20 20   (not cpuload)  
2200: 28 62 65 67 69 6e 20 28 70 72 69 6e 74 20 22 57  (begin (print "W
2210: 41 52 4e 49 4e 47 3a 20 43 50 55 4c 4f 41 44 20  ARNING: CPULOAD 
2220: 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 20 20 28 73  not found.")  (s
2230: 65 74 21 20 63 70 75 6c 6f 61 64 20 22 6e 2f 61  et! cpuload "n/a
2240: 22 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f  "))).    (if (no
2250: 74 20 64 69 73 6b 66 72 65 65 29 20 28 62 65 67  t diskfree) (beg
2260: 69 6e 20 28 70 72 69 6e 74 20 22 57 41 52 4e 49  in (print "WARNI
2270: 4e 47 3a 20 44 49 53 4b 46 52 45 45 20 6e 6f 74  NG: DISKFREE not
2280: 20 66 6f 75 6e 64 2e 22 29 20 28 73 65 74 21 20   found.") (set! 
2290: 64 69 73 6b 66 72 65 65 20 22 6e 2f 61 22 29 29  diskfree "n/a"))
22a0: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 69  ).    (if (not i
22b0: 74 65 6d 2d 70 61 74 68 29 28 62 65 67 69 6e 20  tem-path)(begin 
22c0: 28 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a  (print "WARNING:
22d0: 20 49 54 45 4d 50 41 54 48 20 6e 6f 74 20 73 65   ITEMPATH not se
22e0: 74 2e 22 29 20 20 20 28 73 65 74 21 20 69 74 65  t.")   (set! ite
22f0: 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 20 20 20  m-path ""))).   
2300: 20 3b 3b 20 28 6c 65 74 20 28 28 74 65 73 74 69   ;; (let ((testi
2310: 6e 66 6f 20 28 64 62 3a 67 65 74 2d 74 65 73 74  nfo (db:get-test
2320: 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20  -info db run-id 
2330: 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61  testname item-pa
2340: 74 68 29 29 29 0a 20 20 20 20 3b 3b 20 20 20 28  th))).    ;;   (
2350: 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65 71  if (and (not (eq
2360: 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65  ual? (db:test-ge
2370: 74 2d 73 74 61 74 75 73 20 74 65 73 74 69 6e 66  t-status testinf
2380: 6f 29 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 29  o) "COMPLETED"))
2390: 0a 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20  .    ;;         
23a0: 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20     (not (equal? 
23b0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61  (db:test-get-sta
23c0: 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20 22 4b  tus testinfo) "K
23d0: 49 4c 4c 52 45 51 22 29 29 0a 20 20 20 20 28 73  ILLREQ")).    (s
23e0: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 0a 20  qlite3:execute. 
23f0: 20 20 20 20 64 62 0a 20 20 20 20 20 22 55 50 44      db.     "UPD
2400: 41 54 45 20 74 65 73 74 73 20 53 45 54 20 63 70  ATE tests SET cp
2410: 75 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65  uload=?,diskfree
2420: 3d 3f 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d  =?,run_duration=
2430: 3f 2c 73 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47  ?,state='RUNNING
2440: 27 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ' WHERE run_id=?
2450: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2460: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20  AND item_path=? 
2470: 41 4e 44 20 73 74 61 74 65 20 4e 4f 54 20 49 4e  AND state NOT IN
2480: 20 28 27 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b   ('COMPLETED','K
2490: 49 4c 4c 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27  ILLREQ','KILLED'
24a0: 29 3b 22 0a 20 20 20 20 20 63 70 75 6c 6f 61 64  );".     cpuload
24b0: 0a 20 20 20 20 20 64 69 73 6b 66 72 65 65 0a 20  .     diskfree. 
24c0: 20 20 20 20 6d 69 6e 75 74 65 73 0a 20 20 20 20      minutes.    
24d0: 20 72 75 6e 2d 69 64 0a 20 20 20 20 20 74 65 73   run-id.     tes
24e0: 74 6e 61 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d  tname.     item-
24f0: 70 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65  path)))..(define
2500: 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65   (set-megatest-e
2510: 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69  nv-vars db run-i
2520: 64 29 0a 20 20 28 6c 65 74 20 28 28 6b 65 79 73  d).  (let ((keys
2530: 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62   (db-get-keys db
2540: 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ))).    (for-eac
2550: 68 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a  h (lambda (key).
2560: 09 09 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65  ..(sqlite3:for-e
2570: 61 63 68 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62  ach-row... (lamb
2580: 64 61 20 28 76 61 6c 29 0a 09 09 20 20 20 28 70  da (val)...   (p
2590: 72 69 6e 74 20 22 73 65 74 65 6e 76 20 22 20 28  rint "setenv " (
25a0: 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d  key:get-fieldnam
25b0: 65 20 6b 65 79 29 20 22 20 22 20 76 61 6c 29 0a  e key) " " val).
25c0: 09 09 20 20 20 28 73 65 74 65 6e 76 20 28 6b 65  ..   (setenv (ke
25d0: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
25e0: 6b 65 79 29 20 76 61 6c 29 29 0a 09 09 20 64 62  key) val))... db
25f0: 20 0a 09 09 20 28 63 6f 6e 63 20 22 53 45 4c 45   ... (conc "SELE
2600: 43 54 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69  CT " (key:get-fi
2610: 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 46  eldname key) " F
2620: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 69  ROM runs WHERE i
2630: 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e 2d 69 64  d=?;")... run-id
2640: 29 29 0a 09 20 20 20 20 20 20 6b 65 79 73 29 29  ))..      keys))
2650: 29 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d  )..(define (set-
2660: 69 74 65 6d 2d 65 6e 76 2d 76 61 72 73 20 69 74  item-env-vars it
2670: 65 6d 64 61 74 29 0a 20 20 28 66 6f 72 2d 65 61  emdat).  (for-ea
2680: 63 68 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d  ch (lambda (item
2690: 29 0a 09 20 20 20 20 20 20 28 70 72 69 6e 74 20  )..      (print 
26a0: 22 73 65 74 65 6e 76 20 22 20 28 63 61 72 20 69  "setenv " (car i
26b0: 74 65 6d 29 20 22 20 22 20 28 63 61 64 72 20 69  tem) " " (cadr i
26c0: 74 65 6d 29 29 0a 09 20 20 20 20 20 20 28 73 65  tem))..      (se
26d0: 74 65 6e 76 20 28 63 61 72 20 69 74 65 6d 29 20  tenv (car item) 
26e0: 28 63 61 64 72 20 69 74 65 6d 29 29 29 0a 09 20  (cadr item))).. 
26f0: 20 20 20 69 74 65 6d 64 61 74 29 29 0a 0a 28 64     itemdat))..(d
2700: 65 66 69 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c  efine (get-all-l
2710: 65 67 61 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c  egal-tests).  (l
2720: 65 74 2a 20 28 28 74 65 73 74 73 20 20 28 67 6c  et* ((tests  (gl
2730: 6f 62 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74  ob (conc *toppat
2740: 68 2a 20 22 2f 74 65 73 74 73 2f 2a 22 29 29 29  h* "/tests/*")))
2750: 0a 09 20 28 72 65 73 20 20 20 20 27 28 29 29 29  .. (res    '()))
2760: 0a 20 20 20 20 3b 3b 20 28 70 72 69 6e 74 20 22  .    ;; (print "
2770: 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20 61 74  INFO: Looking at
2780: 20 74 65 73 74 73 20 22 20 28 73 74 72 69 6e 67   tests " (string
2790: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 74 65 73  -intersperse tes
27a0: 74 73 20 22 2c 22 29 29 0a 20 20 20 20 28 66 6f  ts ",")).    (fo
27b0: 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28  r-each (lambda (
27c0: 74 65 73 74 70 61 74 68 29 0a 09 09 28 69 66 20  testpath)...(if 
27d0: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 28 63  (file-exists? (c
27e0: 6f 6e 63 20 74 65 73 74 70 61 74 68 20 22 2f 74  onc testpath "/t
27f0: 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 09 20  estconfig"))... 
2800: 20 20 20 28 73 65 74 21 20 72 65 73 20 28 63 6f     (set! res (co
2810: 6e 73 20 28 6c 61 73 74 20 28 73 74 72 69 6e 67  ns (last (string
2820: 2d 73 70 6c 69 74 20 74 65 73 74 70 61 74 68 20  -split testpath 
2830: 22 2f 22 29 29 20 72 65 73 29 29 29 29 0a 09 20  "/")) res)))).. 
2840: 20 20 20 20 20 74 65 73 74 73 29 0a 20 20 20 20       tests).    
2850: 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  res))..(define (
2860: 72 75 6e 2d 74 65 73 74 73 20 64 62 20 74 65 73  run-tests db tes
2870: 74 2d 6e 61 6d 65 73 29 0a 20 20 28 66 6f 72 2d  t-names).  (for-
2880: 65 61 63 68 20 0a 20 20 20 28 6c 61 6d 62 64 61  each .   (lambda
2890: 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20   (test-name).   
28a0: 20 20 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e    (let ((num-run
28b0: 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75  ning (db:get-cou
28c0: 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67  nt-tests-running
28d0: 20 64 62 29 29 0a 09 20 20 20 28 6d 61 78 2d 63   db))..   (max-c
28e0: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28  oncurrent-jobs (
28f0: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63  config-lookup *c
2900: 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 70  onfigdat* "setup
2910: 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e  " "max_concurren
2920: 74 5f 6a 6f 62 73 22 29 29 29 0a 20 20 20 20 20  t_jobs"))).     
2930: 20 20 28 70 72 69 6e 74 20 22 6d 61 78 2d 63 6f    (print "max-co
2940: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22  ncurrent-jobs: "
2950: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
2960: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e  jobs ", num-runn
2970: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
2980: 6e 67 29 0a 20 20 20 20 20 20 20 28 69 66 20 28  ng).       (if (
2990: 6f 72 20 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63  or (not max-conc
29a0: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20  urrent-jobs)..  
29b0: 20 20 20 20 20 28 61 6e 64 20 6d 61 78 2d 63 6f       (and max-co
29c0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a 09 09  ncurrent-jobs...
29d0: 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d      (string->num
29e0: 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  ber max-concurre
29f0: 6e 74 2d 6a 6f 62 73 29 0a 09 09 20 20 20 20 28  nt-jobs)...    (
2a00: 6e 6f 74 20 28 3e 20 6e 75 6d 2d 72 75 6e 6e 69  not (> num-runni
2a10: 6e 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62  ng (string->numb
2a20: 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  er max-concurren
2a30: 74 2d 6a 6f 62 73 29 29 29 29 29 0a 09 20 20 20  t-jobs)))))..   
2a40: 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62  (run-one-test db
2a50: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 20 20   test-name)..   
2a60: 28 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a  (print "WARNING:
2a70: 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62   Max running job
2a80: 73 20 65 78 63 65 65 64 65 64 2c 20 63 75 72 72  s exceeded, curr
2a90: 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69  ent number runni
2aa0: 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ng: " num-runnin
2ab0: 67 20 0a 09 09 20 20 22 2c 20 6d 61 78 5f 63 6f  g ...  ", max_co
2ac0: 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22  ncurrent_jobs: "
2ad0: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
2ae0: 6a 6f 62 73 29 29 29 29 0a 20 20 20 74 65 73 74  jobs)))).   test
2af0: 2d 6e 61 6d 65 73 29 29 0a 0a 28 64 65 66 69 6e  -names))..(defin
2b00: 65 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20  e (run-one-test 
2b10: 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20  db test-name).  
2b20: 28 70 72 69 6e 74 20 22 4c 61 75 6e 63 68 69 6e  (print "Launchin
2b30: 67 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61  g test " test-na
2b40: 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65  me).  (let* ((te
2b50: 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63  st-path    (conc
2b60: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
2b70: 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29  ts/" test-name))
2b80: 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66  .. (test-configf
2b90: 20 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68   (conc test-path
2ba0: 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29   "/testconfig"))
2bb0: 0a 09 20 28 74 65 73 74 65 78 69 73 74 73 20 20  .. (testexists  
2bc0: 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73   (and (file-exis
2bd0: 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66  ts? test-configf
2be0: 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65  )(file-read-acce
2bf0: 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66  ss? test-configf
2c00: 29 29 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66  ))).. (test-conf
2c10: 20 20 20 20 28 69 66 20 74 65 73 74 65 78 69 73      (if testexis
2c20: 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20  ts (read-config 
2c30: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 20 28 6d  test-configf) (m
2c40: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29  ake-hash-table))
2c50: 29 0a 09 20 28 77 61 69 74 6f 6e 20 20 20 20 20  ).. (waiton     
2c60: 20 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66    (let ((w (conf
2c70: 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63  ig-lookup test-c
2c80: 6f 6e 66 20 22 72 65 71 75 69 72 65 6d 65 6e 74  onf "requirement
2c90: 73 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09  s" "waiton")))..
2ca0: 09 09 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20  .. (if (string? 
2cb0: 77 29 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  w)(string-split 
2cc0: 77 29 27 28 29 29 29 29 29 0a 20 20 20 20 28 69  w)'())))).    (i
2cd0: 66 20 28 6e 6f 74 20 74 65 73 74 65 78 69 73 74  f (not testexist
2ce0: 73 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 70  s)..(begin..  (p
2cf0: 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 43 61 6e  rint "ERROR: Can
2d00: 27 74 20 66 69 6e 64 20 63 6f 6e 66 69 67 20 66  't find config f
2d10: 69 6c 65 20 22 20 74 65 73 74 2d 63 6f 6e 66 69  ile " test-confi
2d20: 67 66 29 0a 09 20 20 28 65 78 69 74 20 32 29 29  gf)..  (exit 2))
2d30: 0a 09 3b 3b 20 70 75 74 20 74 6f 70 20 76 61 72  ..;; put top var
2d40: 73 20 69 6e 74 6f 20 63 6f 6e 76 65 6e 69 65 6e  s into convenien
2d50: 74 20 76 61 72 69 61 62 6c 65 73 20 61 6e 64 20  t variables and 
2d60: 6f 70 65 6e 20 74 68 65 20 64 62 0a 09 28 6c 65  open the db..(le
2d70: 74 2a 20 28 3b 3b 20 64 62 20 69 73 20 61 6c 77  t* (;; db is alw
2d80: 61 79 73 20 61 74 20 2a 74 6f 70 70 61 74 68 2a  ays at *toppath*
2d90: 2f 64 62 2f 6d 65 67 61 74 65 73 74 2e 64 62 0a  /db/megatest.db.
2da0: 09 20 20 20 20 20 20 20 28 6b 65 79 73 20 20 20  .       (keys   
2db0: 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79       (db-get-key
2dc0: 73 20 64 62 29 29 0a 09 20 20 20 20 20 20 20 28  s db))..       (
2dd0: 6b 65 79 76 61 6c 6c 73 74 20 20 20 28 6b 65 79  keyvallst   (key
2de0: 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20  s->vallist keys 
2df0: 23 74 29 29 0a 09 20 20 20 20 20 20 20 28 69 74  #t))..       (it
2e00: 65 6d 73 20 20 20 20 20 20 20 28 68 61 73 68 2d  ems       (hash-
2e10: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
2e20: 74 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65  t test-conf "ite
2e30: 6d 73 22 20 23 66 29 29 0a 09 20 20 20 20 20 20  ms" #f))..      
2e40: 20 28 61 6c 6c 69 74 65 6d 73 20 20 20 20 28 69   (allitems    (i
2e50: 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d  tem-assoc->item-
2e60: 6c 69 73 74 20 69 74 65 6d 73 29 29 0a 09 20 20  list items))..  
2e70: 20 20 20 20 20 28 72 75 6e 2d 69 64 20 20 20 20       (run-id    
2e80: 20 20 28 72 65 67 69 73 74 65 72 2d 72 75 6e 20    (register-run 
2e90: 64 62 20 6b 65 79 73 29 29 20 3b 3b 20 20 74 65  db keys)) ;;  te
2ea0: 73 74 2d 6e 61 6d 65 29 29 29 0a 09 20 20 20 20  st-name)))..    
2eb0: 20 20 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20     (runconfigf  
2ec0: 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a  (conc  *toppath*
2ed0: 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f   "/runconfigs.co
2ee0: 6e 66 69 67 22 29 29 29 0a 09 20 20 3b 3b 20 28  nfig")))..  ;; (
2ef0: 70 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 22 29  print "items: ")
2f00: 28 70 70 20 61 6c 6c 69 74 65 6d 73 29 0a 09 20  (pp allitems).. 
2f10: 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61   (if (args:get-a
2f20: 72 67 20 22 2d 6d 22 29 0a 09 20 20 20 20 20 20  rg "-m")..      
2f30: 28 64 62 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d  (db:set-comment-
2f40: 66 6f 72 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69  for-run db run-i
2f50: 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  d (args:get-arg 
2f60: 22 2d 6d 22 29 29 29 0a 09 20 20 28 6c 65 74 20  "-m")))..  (let 
2f70: 6c 6f 6f 70 20 28 28 69 74 65 6d 64 61 74 20 28  loop ((itemdat (
2f80: 63 61 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09  car allitems))..
2f90: 09 20 20 20 20 20 28 74 61 6c 20 20 20 20 20 28  .     (tal     (
2fa0: 63 64 72 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a  cdr allitems))).
2fb0: 09 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20  .    ;; (lambda 
2fc0: 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28  (itemdat) ;;; ((
2fd0: 72 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69  ripeness "overri
2fe0: 70 65 22 29 20 28 74 65 6d 70 65 72 61 74 75 72  pe") (temperatur
2ff0: 65 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f  e "cool") (seaso
3000: 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a 09 20 20  n "summer"))..  
3010: 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70    (let* ((item-p
3020: 61 74 68 20 20 20 20 20 28 69 74 65 6d 2d 6c 69  ath     (item-li
3030: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74  st->path itemdat
3040: 29 29 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69 6e  )) ;; (string-in
3050: 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 63  tersperse (map c
3060: 61 64 72 20 69 74 65 6d 64 61 74 29 20 22 2f 22  adr itemdat) "/"
3070: 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73  ))...   (new-tes
3080: 74 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69  t-path (string-i
3090: 6e 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73  ntersperse (cons
30a0: 20 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20   test-path (map 
30b0: 63 61 64 72 20 69 74 65 6d 64 61 74 29 29 20 22  cadr itemdat)) "
30c0: 2f 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74  /"))...   (new-t
30d0: 65 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71  est-name (if (eq
30e0: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22  ual? item-path "
30f0: 22 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f  ") test-name (co
3100: 6e 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22  nc test-name "/"
3110: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b   item-path))) ;;
3120: 20 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f   just need it to
3130: 20 62 65 20 75 6e 69 71 75 65 0a 09 09 20 20 20   be unique...   
3140: 28 74 65 73 74 2d 73 74 61 74 75 73 20 20 20 23  (test-status   #
3150: 66 29 0a 09 09 20 20 20 28 6e 75 6d 2d 72 75 6e  f)...   (num-run
3160: 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75  ning (db:get-cou
3170: 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67  nt-tests-running
3180: 20 64 62 29 29 0a 09 09 20 20 20 28 6d 61 78 2d   db))...   (max-
3190: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20  concurrent-jobs 
31a0: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a  (config-lookup *
31b0: 63 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75  configdat* "setu
31c0: 70 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65  p" "max_concurre
31d0: 6e 74 5f 6a 6f 62 73 22 29 29 29 0a 09 20 20 20  nt_jobs")))..   
31e0: 20 20 20 28 70 72 69 6e 74 20 22 6d 61 78 2d 63     (print "max-c
31f0: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20  oncurrent-jobs: 
3200: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  " max-concurrent
3210: 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e  -jobs ", num-run
3220: 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e  ning: " num-runn
3230: 69 6e 67 29 0a 09 20 20 20 20 20 20 28 69 66 20  ing)..      (if 
3240: 28 6e 6f 74 20 28 6f 72 20 28 6e 6f 74 20 6d 61  (not (or (not ma
3250: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
3260: 73 29 0a 09 09 09 20 20 20 28 61 6e 64 20 6d 61  s)....   (and ma
3270: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
3280: 73 0a 09 09 09 09 28 73 74 72 69 6e 67 2d 3e 6e  s.....(string->n
3290: 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72  umber max-concur
32a0: 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 09 09 28  rent-jobs).....(
32b0: 6e 6f 74 20 28 3e 20 6e 75 6d 2d 72 75 6e 6e 69  not (> num-runni
32c0: 6e 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62  ng (string->numb
32d0: 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  er max-concurren
32e0: 74 2d 6a 6f 62 73 29 29 29 29 29 29 0a 09 09 20  t-jobs))))))... 
32f0: 20 28 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47   (print "WARNING
3300: 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f  : Max running jo
3310: 62 73 20 65 78 63 65 65 64 65 64 2c 20 63 75 72  bs exceeded, cur
3320: 72 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e  rent number runn
3330: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
3340: 6e 67 20 0a 09 09 09 20 22 2c 20 6d 61 78 5f 63  ng .... ", max_c
3350: 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20  oncurrent_jobs: 
3360: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  " max-concurrent
3370: 2d 6a 6f 62 73 29 0a 09 09 20 20 28 62 65 67 69  -jobs)...  (begi
3380: 6e 0a 09 09 20 20 20 20 28 6c 65 74 20 6c 6f 6f  n...    (let loo
3390: 70 32 20 28 28 74 73 20 23 66 29 0a 09 09 09 09  p2 ((ts #f).....
33a0: 28 63 74 20 30 29 29 0a 09 09 20 20 20 20 20 20  (ct 0))...      
33b0: 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 74 73  (if (and (not ts
33c0: 29 0a 09 09 09 20 20 20 20 20 20 20 28 3c 20 63  )....       (< c
33d0: 74 20 31 30 29 29 0a 09 09 09 20 20 28 62 65 67  t 10))....  (beg
33e0: 69 6e 0a 09 09 09 20 20 20 20 28 72 65 67 69 73  in....    (regis
33f0: 74 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d  ter-test db run-
3400: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
3410: 6d 2d 70 61 74 68 29 0a 09 09 09 20 20 20 20 28  m-path)....    (
3420: 64 62 3a 74 65 73 74 2d 73 65 74 2d 63 6f 6d 6d  db:test-set-comm
3430: 65 6e 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65  ent db run-id te
3440: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
3450: 68 20 22 22 29 0a 09 09 09 20 20 20 20 3b 3b 20  h "")....    ;; 
3460: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73  (test-set-status
3470: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
3480: 2d 6e 61 6d 65 20 22 4e 4f 54 5f 53 54 41 52 54  -name "NOT_START
3490: 45 44 22 20 22 6e 2f 61 22 20 69 74 65 6d 64 61  ED" "n/a" itemda
34a0: 74 20 22 22 29 0a 09 09 09 20 20 20 20 3b 3b 20  t "")....    ;; 
34b0: 28 64 62 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d  (db:set-comment-
34c0: 66 6f 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d  for-test db run-
34d0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
34e0: 6d 2d 70 61 74 68 20 22 22 29 0a 09 09 09 20 20  m-path "")....  
34f0: 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73    (db:delete-tes
3500: 74 2d 73 74 65 70 2d 72 65 63 6f 72 64 73 20 64  t-step-records d
3510: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
3520: 6d 65 29 20 3b 3b 20 63 6c 65 61 6e 20 6f 75 74  me) ;; clean out
3530: 20 69 66 20 74 68 69 73 20 69 73 20 61 20 72 65   if this is a re
3540: 2d 72 75 6e 0a 09 09 09 20 20 20 20 28 6c 6f 6f  -run....    (loo
3550: 70 32 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d  p2 (db:get-test-
3560: 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74  info db run-id t
3570: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
3580: 74 68 29 0a 09 09 09 09 20 20 20 28 2b 20 63 74  th).....   (+ ct
3590: 20 31 29 29 29 0a 09 09 09 20 20 28 69 66 20 74   1)))....  (if t
35a0: 73 0a 09 09 09 20 20 20 20 20 20 28 73 65 74 21  s....      (set!
35b0: 20 74 65 73 74 2d 73 74 61 74 75 73 20 74 73 29   test-status ts)
35c0: 0a 09 09 09 20 20 20 20 20 20 28 62 65 67 69 6e  ....      (begin
35d0: 0a 09 09 09 09 28 70 72 69 6e 74 20 22 57 41 52  .....(print "WAR
35e0: 4e 49 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72  NING: Couldn't r
35f0: 65 67 69 73 74 65 72 20 74 65 73 74 20 22 20 74  egister test " t
3600: 65 73 74 2d 6e 61 6d 65 20 22 20 77 69 74 68 20  est-name " with 
3610: 69 74 65 6d 20 70 61 74 68 20 22 20 69 74 65 6d  item path " item
3620: 2d 70 61 74 68 20 22 2c 20 73 6b 69 70 70 69 6e  -path ", skippin
3630: 67 22 29 0a 09 09 09 09 28 69 66 20 28 6e 6f 74  g").....(if (not
3640: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09   (null? tal))...
3650: 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72  ..    (loop (car
3660: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29   tal)(cdr tal)))
3670: 29 29 29 29 0a 09 09 20 20 20 20 28 63 68 61 6e  ))))...    (chan
3680: 67 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73  ge-directory tes
3690: 74 2d 70 61 74 68 29 0a 09 09 20 20 20 20 3b 3b  t-path)...    ;;
36a0: 20 74 68 69 73 20 62 6c 6f 63 6b 20 69 73 20 68   this block is h
36b0: 65 72 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f  ere only to info
36c0: 72 6d 20 74 68 65 20 75 73 65 72 20 65 61 72 6c  rm the user earl
36d0: 79 20 6f 6e 0a 09 09 20 20 20 20 28 69 66 20 28  y on...    (if (
36e0: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e  file-exists? run
36f0: 63 6f 6e 66 69 67 66 29 0a 09 09 09 28 73 65 74  configf)....(set
3700: 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20  up-env-defaults 
3710: 64 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75  db runconfigf ru
3720: 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65  n-id *already-se
3730: 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66  en-runconfig-inf
3740: 6f 2a 29 0a 09 09 09 28 70 72 69 6e 74 20 22 57  o*)....(print "W
3750: 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e  ARNING: You do n
3760: 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f  ot have a run co
3770: 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e  nfig file: " run
3780: 63 6f 6e 66 69 67 66 29 29 0a 09 09 20 20 20 20  configf))...    
3790: 3b 3b 20 28 70 72 69 6e 74 20 22 72 75 6e 2d 69  ;; (print "run-i
37a0: 64 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65  d: " run-id " te
37b0: 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d  st-name: " test-
37c0: 6e 61 6d 65 20 22 20 69 74 65 6d 2d 70 61 74 68  name " item-path
37d0: 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20  : " item-path " 
37e0: 74 65 73 74 2d 73 74 61 74 75 73 3a 20 22 20 28  test-status: " (
37f0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
3800: 74 65 73 74 2d 73 74 61 74 75 73 29 20 22 20 74  test-status) " t
3810: 65 73 74 2d 73 74 61 74 65 3a 20 22 20 28 74 65  est-state: " (te
3820: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
3830: 74 2d 73 74 61 74 75 73 29 29 0a 09 09 20 20 20  t-status))...   
3840: 20 28 63 61 73 65 20 28 69 66 20 28 61 72 67 73   (case (if (args
3850: 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65  :get-arg "-force
3860: 22 29 0a 09 09 09 20 20 20 20 20 20 27 4e 4f 54  ")....      'NOT
3870: 5f 53 54 41 52 54 45 44 0a 09 09 09 20 20 20 20  _STARTED....    
3880: 20 20 28 69 66 20 74 65 73 74 2d 73 74 61 74 75    (if test-statu
3890: 73 0a 09 09 09 09 20 20 28 73 74 72 69 6e 67 2d  s.....  (string-
38a0: 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65  >symbol (test:ge
38b0: 74 2d 73 74 61 74 65 20 74 65 73 74 2d 73 74 61  t-state test-sta
38c0: 74 75 73 29 29 0a 09 09 09 09 20 20 27 66 61 69  tus)).....  'fai
38d0: 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a  led-to-insert)).
38e0: 09 09 20 20 20 20 20 20 28 28 66 61 69 6c 65 64  ..      ((failed
38f0: 2d 74 6f 2d 69 6e 73 65 72 74 29 0a 09 09 20 20  -to-insert)...  
3900: 20 20 20 20 20 28 70 72 69 6e 74 20 22 45 52 52       (print "ERR
3910: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e  OR: Failed to in
3920: 73 65 72 74 20 74 68 65 20 72 65 63 6f 72 64 20  sert the record 
3930: 69 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09  into the db"))..
3940: 09 20 20 20 20 20 20 28 28 4e 4f 54 5f 53 54 41  .      ((NOT_STA
3950: 52 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 20  RTED COMPLETED) 
3960: 3b 3b 20 28 63 61 64 72 20 73 74 61 74 75 73 20  ;; (cadr status 
3970: 69 73 20 74 68 65 20 72 6f 77 20 69 64 20 66 6f  is the row id fo
3980: 72 20 74 68 65 20 72 75 6e 20 72 65 63 6f 72 64  r the run record
3990: 29 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28  )...       (if (
39a0: 61 6e 64 20 28 65 71 75 61 6c 3f 20 28 74 65 73  and (equal? (tes
39b0: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
39c0: 2d 73 74 61 74 75 73 29 20 20 22 43 4f 4d 50 4c  -status)  "COMPL
39d0: 45 54 45 44 22 29 0a 09 09 09 09 28 6f 72 20 28  ETED").....(or (
39e0: 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74  equal? (test:get
39f0: 2d 73 74 61 74 75 73 20 74 65 73 74 2d 73 74 61  -status test-sta
3a00: 74 75 73 29 20 22 50 41 53 53 22 29 0a 09 09 09  tus) "PASS")....
3a10: 09 20 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65  .    (equal? (te
3a20: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
3a30: 73 74 2d 73 74 61 74 75 73 29 20 22 43 48 45 43  st-status) "CHEC
3a40: 4b 22 29 29 0a 09 09 09 09 28 6e 6f 74 20 28 61  K")).....(not (a
3a50: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f  rgs:get-arg "-fo
3a60: 72 63 65 22 29 29 29 0a 09 09 09 20 20 20 28 70  rce")))....   (p
3a70: 72 69 6e 74 20 22 4e 4f 54 45 3a 20 4e 6f 74 20  rint "NOTE: Not 
3a80: 73 74 61 72 74 69 6e 67 20 74 65 73 74 20 22 20  starting test " 
3a90: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20  new-test-name " 
3aa0: 61 73 20 69 74 20 69 73 20 73 74 61 74 65 20 5c  as it is state \
3ab0: 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20 61 6e 64  "COMPLETED\" and
3ac0: 20 73 74 61 74 75 73 20 5c 22 22 20 28 74 65 73   status \"" (tes
3ad0: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
3ae0: 74 2d 73 74 61 74 75 73 29 20 22 5c 22 2c 20 75  t-status) "\", u
3af0: 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65  se -force to ove
3b00: 72 72 69 64 65 22 29 0a 09 09 09 20 20 20 28 6c  rride")....   (l
3b10: 65 74 2a 20 28 28 67 65 74 2d 70 72 65 72 65 71  et* ((get-prereq
3b20: 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61 20 28 29  s-cmd (lambda ()
3b30: 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 62 2d  .......     (db-
3b40: 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d  get-prereqs-not-
3b50: 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61  met db run-id wa
3b60: 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68 65 63 6b  iton))) ;; check
3b70: 20 62 65 66 6f 72 65 20 72 75 6e 6e 69 6e 67 20   before running 
3b80: 2e 2e 2e 2e 0a 09 09 09 09 20 20 28 6c 61 75 6e  .........  (laun
3b90: 63 68 2d 63 6d 64 20 20 20 20 20 20 28 6c 61 6d  ch-cmd      (lam
3ba0: 62 64 61 20 28 29 0a 09 09 09 09 09 09 20 20 20  bda ().......   
3bb0: 20 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64    (launch-test d
3bc0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 63 6f  b run-id test-co
3bd0: 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73  nf keyvallst tes
3be0: 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68  t-name test-path
3bf0: 20 69 74 65 6d 64 61 74 29 29 29 0a 09 09 09 09   itemdat))).....
3c00: 20 20 28 74 65 73 74 72 75 6e 64 61 74 20 20 20    (testrundat   
3c10: 20 20 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65     (list get-pre
3c20: 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d  reqs-cmd launch-
3c30: 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20 28  cmd)))....     (
3c40: 69 66 20 28 6f 72 20 28 61 72 67 73 3a 67 65 74  if (or (args:get
3c50: 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09  -arg "-force")..
3c60: 09 09 09 20 20 20 20 20 28 6e 75 6c 6c 3f 20 28  ...     (null? (
3c70: 28 63 61 72 20 74 65 73 74 72 75 6e 64 61 74 29  (car testrundat)
3c80: 29 29 29 20 3b 3b 20 61 72 65 20 74 68 65 72 65  ))) ;; are there
3c90: 20 61 6e 79 20 74 65 73 74 73 20 74 68 61 74 20   any tests that 
3ca0: 6d 75 73 74 20 62 65 20 72 75 6e 20 62 65 66 6f  must be run befo
3cb0: 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09  re this one.....
3cc0: 09 09 09 20 28 28 63 61 64 72 20 74 65 73 74 72  ... ((cadr testr
3cd0: 75 6e 64 61 74 29 29 20 3b 3b 20 74 68 69 73 20  undat)) ;; this 
3ce0: 69 73 20 74 68 65 20 6c 69 6e 65 20 74 68 61 74  is the line that
3cf0: 20 6c 61 75 6e 63 68 65 73 20 74 68 65 20 74 65   launches the te
3d00: 73 74 20 74 6f 20 74 68 65 20 72 65 6d 6f 74 65  st to the remote
3d10: 20 68 6f 73 74 0a 09 09 09 09 20 28 68 61 73 68   host..... (hash
3d20: 2d 74 61 62 6c 65 2d 73 65 74 21 20 2a 77 61 69  -table-set! *wai
3d30: 74 69 6e 67 2d 71 75 65 75 65 2a 20 6e 65 77 2d  ting-queue* new-
3d40: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 72 75  test-name testru
3d50: 6e 64 61 74 29 29 29 29 29 0a 09 09 20 20 20 20  ndat)))))...    
3d60: 20 20 28 28 4b 49 4c 4c 45 44 29 20 0a 09 09 20    ((KILLED) ... 
3d70: 20 20 20 20 20 20 28 70 72 69 6e 74 20 22 4e 4f        (print "NO
3d80: 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  TE: " new-test-n
3d90: 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79  ame " is already
3da0: 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20   running or was 
3db0: 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64  explictly killed
3dc0: 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20  , use -force to 
3dd0: 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09  launch it."))...
3de0: 20 20 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44        ((LAUNCHED
3df0: 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54   REMOTEHOSTSTART
3e00: 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20   RUNNING)  ...  
3e10: 20 20 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28       (if (> (- (
3e20: 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29  current-seconds)
3e30: 28 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  (+ (db:test-get-
3e40: 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 2d  event_time test-
3e50: 73 74 61 74 75 73 29 0a 09 09 09 09 09 09 20 20  status).......  
3e60: 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d     (db:test-get-
3e70: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65 73  run_duration tes
3e80: 74 2d 73 74 61 74 75 73 29 29 29 0a 09 09 09 20  t-status))).... 
3e90: 20 20 20 20 20 31 30 30 29 20 3b 3b 20 69 2e 65       100) ;; i.e
3ea0: 2e 20 6e 6f 20 75 70 64 61 74 65 20 66 6f 72 20  . no update for 
3eb0: 6d 6f 72 65 20 74 68 61 6e 20 31 30 30 20 73 65  more than 100 se
3ec0: 63 6f 6e 64 73 0a 09 09 09 20 20 20 28 62 65 67  conds....   (beg
3ed0: 69 6e 0a 09 09 09 20 20 20 20 20 28 70 72 69 6e  in....     (prin
3ee0: 74 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74  t "WARNING: Test
3ef0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61   " test-name " a
3f00: 70 70 65 61 72 73 20 74 6f 20 62 65 20 64 65 61  ppears to be dea
3f10: 64 2e 22 29 0a 09 09 09 20 20 20 20 20 28 74 65  d.")....     (te
3f20: 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64  st-set-status! d
3f30: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
3f40: 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20  me "INCOMPLETE" 
3f50: 22 53 54 55 43 4b 2f 44 45 41 44 22 20 69 74 65  "STUCK/DEAD" ite
3f60: 6d 64 61 74 20 22 54 65 73 74 20 69 73 20 73 74  mdat "Test is st
3f70: 75 63 6b 20 6f 72 20 64 65 61 64 22 29 29 0a 09  uck or dead"))..
3f80: 09 09 20 20 20 28 70 72 69 6e 74 20 22 4e 4f 54  ..   (print "NOT
3f90: 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  E: " test-name "
3fa0: 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e   is already runn
3fb0: 69 6e 67 22 29 29 29 0a 09 09 20 20 20 20 20 20  ing")))...      
3fc0: 28 65 6c 73 65 20 20 20 20 20 20 20 28 70 72 69  (else       (pri
3fd0: 6e 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65  nt "ERROR: Faile
3fe0: 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74  d to launch test
3ff0: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65   " new-test-name
4000: 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64   ". Unrecognised
4010: 20 73 74 61 74 65 20 22 20 28 74 65 73 74 3a 67   state " (test:g
4020: 65 74 2d 73 74 61 74 65 20 74 65 73 74 2d 73 74  et-state test-st
4030: 61 74 75 73 29 29 29 29 29 29 0a 09 20 20 20 20  atus))))))..    
4040: 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c    (if (not (null
4050: 3f 20 74 61 6c 29 29 0a 09 09 20 20 28 6c 6f 6f  ? tal))...  (loo
4060: 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20  p (car tal)(cdr 
4070: 74 61 6c 29 29 29 29 29 29 29 29 29 0a 0a 28 64  tal)))))))))..(d
4080: 65 66 69 6e 65 20 28 72 75 6e 2d 77 61 69 74 69  efine (run-waiti
4090: 6e 67 2d 74 65 73 74 73 20 64 62 29 0a 20 20 28  ng-tests db).  (
40a0: 6c 65 74 20 28 28 6e 75 6d 74 72 69 65 73 20 20  let ((numtries  
40b0: 20 20 20 20 20 20 20 20 20 30 29 0a 09 28 6c 61           0)..(la
40c0: 73 74 2d 74 72 79 2d 74 69 6d 65 20 20 20 20 20  st-try-time     
40d0: 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64   (current-second
40e0: 73 29 29 0a 09 28 74 69 6d 65 73 20 20 20 20 20  s))..(times     
40f0: 20 20 20 20 20 20 20 20 20 28 6c 69 73 74 20 31           (list 1
4100: 29 29 29 20 3b 3b 20 6d 69 6e 75 74 65 73 20 74  ))) ;; minutes t
4110: 6f 20 77 61 69 74 20 62 65 66 6f 72 65 20 74 72  o wait before tr
4120: 79 69 6e 67 20 61 67 61 69 6e 20 74 6f 20 6b 69  ying again to ki
4130: 63 6b 20 6f 66 66 20 72 75 6e 73 0a 20 20 20 20  ck off runs.    
4140: 3b 3b 20 42 55 47 20 74 68 69 73 20 68 61 63 6b  ;; BUG this hack
4150: 20 6f 66 20 62 72 75 74 65 20 66 6f 72 63 65 20   of brute force 
4160: 72 65 74 72 79 69 6e 67 20 77 6f 72 6b 73 20 71  retrying works q
4170: 75 69 74 65 20 77 65 6c 6c 20 66 6f 72 20 6d 61  uite well for ma
4180: 6e 79 20 63 61 73 65 73 20 62 75 74 20 0a 20 20  ny cases but .  
4190: 20 20 3b 3b 20 20 20 20 20 77 68 61 74 20 69 73    ;;     what is
41a0: 20 6e 65 65 64 65 64 20 69 73 20 74 6f 20 63 68   needed is to ch
41b0: 65 63 6b 20 74 68 65 20 64 62 20 66 6f 72 20 74  eck the db for t
41c0: 65 73 74 73 20 74 68 61 74 20 68 61 76 65 20 66  ests that have f
41d0: 61 69 6c 65 64 20 6c 65 73 73 20 74 68 61 6e 0a  ailed less than.
41e0: 20 20 20 20 3b 3b 20 20 20 20 20 4e 20 74 69 6d      ;;     N tim
41f0: 65 73 20 6f 72 20 6e 65 76 65 72 20 62 65 65 6e  es or never been
4200: 20 73 74 61 72 74 65 64 20 61 6e 64 20 6b 69 63   started and kic
4210: 6b 20 74 68 65 6d 20 6f 66 66 20 61 67 61 69 6e  k them off again
4220: 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28  .    (let loop (
4230: 28 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61  (waiting-test-na
4240: 6d 65 73 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  mes (hash-table-
4250: 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75  keys *waiting-qu
4260: 65 75 65 2a 29 29 29 0a 20 20 20 20 20 20 28 63  eue*))).      (c
4270: 6f 6e 64 0a 20 20 20 20 20 20 20 28 28 6e 75 6c  ond.       ((nul
4280: 6c 3f 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d  l? waiting-test-
4290: 6e 61 6d 65 73 29 0a 09 28 70 72 69 6e 74 20 22  names)..(print "
42a0: 41 6c 6c 20 74 65 73 74 73 20 6c 61 75 6e 63 68  All tests launch
42b0: 65 64 22 29 29 0a 20 20 20 20 20 20 20 28 28 3e  ed")).       ((>
42c0: 20 6e 75 6d 74 72 69 65 73 20 34 29 0a 09 28 70   numtries 4)..(p
42d0: 72 69 6e 74 20 22 4e 4f 54 45 3a 20 54 72 69 65  rint "NOTE: Trie
42e0: 64 20 6c 61 75 6e 63 68 69 6e 67 20 66 6f 75 72  d launching four
42f0: 20 74 69 6d 65 73 2c 20 70 65 72 68 61 70 73 20   times, perhaps 
4300: 72 75 6e 20 6d 65 67 61 74 65 73 74 20 61 67 61  run megatest aga
4310: 69 6e 20 69 6e 20 61 20 66 65 77 20 6d 69 6e 75  in in a few minu
4320: 74 65 73 22 29 29 0a 20 20 20 20 20 20 20 28 65  tes")).       (e
4330: 6c 73 65 0a 09 28 73 65 74 21 20 6e 75 6d 74 72  lse..(set! numtr
4340: 69 65 73 20 28 2b 20 6e 75 6d 74 72 69 65 73 20  ies (+ numtries 
4350: 31 29 29 0a 09 28 66 6f 72 2d 65 61 63 68 20 28  1))..(for-each (
4360: 6c 61 6d 62 64 61 20 28 74 65 73 74 6e 61 6d 65  lambda (testname
4370: 29 0a 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28  )...    (let* ((
4380: 74 65 73 74 64 61 74 20 28 68 61 73 68 2d 74 61  testdat (hash-ta
4390: 62 6c 65 2d 72 65 66 20 2a 77 61 69 74 69 6e 67  ble-ref *waiting
43a0: 2d 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65  -queue* testname
43b0: 29 29 0a 09 09 09 20 20 20 28 70 72 65 72 65 71  ))....   (prereq
43c0: 73 20 28 28 63 61 72 20 74 65 73 74 64 61 74 29  s ((car testdat)
43d0: 29 29 0a 09 09 09 20 20 20 28 6c 64 62 20 20 20  ))....   (ldb   
43e0: 20 20 28 69 66 20 64 62 20 64 62 20 28 6f 70 65    (if db db (ope
43f0: 6e 2d 64 62 29 29 29 29 0a 09 09 20 20 20 20 20  n-db))))...     
4400: 20 3b 3b 20 28 70 72 69 6e 74 20 22 70 72 65 72   ;; (print "prer
4410: 65 71 73 20 72 65 6d 61 69 6e 69 6e 67 3a 20 22  eqs remaining: "
4420: 20 70 72 65 72 65 71 73 29 0a 09 09 20 20 20 20   prereqs)...    
4430: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65    (if (null? pre
4440: 72 65 71 73 29 0a 09 09 09 20 20 28 62 65 67 69  reqs)....  (begi
4450: 6e 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20  n....    (print 
4460: 22 50 72 65 72 65 71 75 69 73 69 74 65 73 20 6d  "Prerequisites m
4470: 65 74 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22 20  et, launching " 
4480: 74 65 73 74 6e 61 6d 65 29 0a 09 09 09 20 20 20  testname)....   
4490: 20 28 28 63 61 64 72 20 74 65 73 74 64 61 74 29   ((cadr testdat)
44a0: 29 0a 09 09 09 20 20 20 20 28 68 61 73 68 2d 74  )....    (hash-t
44b0: 61 62 6c 65 2d 64 65 6c 65 74 65 21 20 2a 77 61  able-delete! *wa
44c0: 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 74 65 73  iting-queue* tes
44d0: 74 6e 61 6d 65 29 29 29 0a 09 09 20 20 20 20 20  tname)))...     
44e0: 20 28 69 66 20 28 6e 6f 74 20 64 62 29 0a 09 09   (if (not db)...
44f0: 09 20 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61  .  (sqlite3:fina
4500: 6c 69 7a 65 21 20 6c 64 62 29 29 29 29 0a 09 09  lize! ldb))))...
4510: 20 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e    waiting-test-n
4520: 61 6d 65 73 29 0a 09 28 73 6c 65 65 70 20 31 30  ames)..(sleep 10
4530: 29 20 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e  ) ;; no point in
4540: 20 72 75 73 68 69 6e 67 20 74 68 69 6e 67 73 20   rushing things 
4550: 61 74 20 74 68 69 73 20 73 74 61 67 65 3f 0a 09  at this stage?..
4560: 28 6c 6f 6f 70 20 28 68 61 73 68 2d 74 61 62 6c  (loop (hash-tabl
4570: 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d  e-keys *waiting-
4580: 71 75 65 75 65 2a 29 29 29 29 29 29 29 0a 0a 28  queue*)))))))..(
4590: 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d  define (get-dir-
45a0: 75 70 2d 6f 6e 65 20 64 69 72 29 20 0a 20 20 28  up-one dir) .  (
45b0: 6c 65 74 20 28 28 64 70 61 72 74 73 20 20 28 73  let ((dparts  (s
45c0: 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20  tring-split dir 
45d0: 22 2f 22 29 29 29 0a 20 20 20 20 28 63 6f 6e 63  "/"))).    (conc
45e0: 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74   "/" (string-int
45f0: 65 72 73 70 65 72 73 65 20 0a 09 20 20 20 20 20  ersperse ..     
4600: 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28    (take dparts (
4610: 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73  - (length dparts
4620: 29 20 31 29 29 0a 09 20 20 20 20 20 20 20 22 2f  ) 1))..       "/
4630: 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20  ")))).;; Remove 
4640: 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61  runs.;; fields a
4650: 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68  re passing in th
4660: 72 6f 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28  rough .(define (
4670: 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73  runs:remove-runs
4680: 20 64 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20   db runnamepatt 
4690: 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 74  testpatt itempat
46a0: 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79  t).  (let* ((key
46b0: 73 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74  s        (db-get
46c0: 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28 72 75  -keys db)).. (ru
46d0: 6e 64 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a  ndat      (runs:
46e0: 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74  get-runs-by-patt
46f0: 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65   db keys runname
4700: 70 61 74 74 29 29 0a 09 20 28 68 65 61 64 65 72  patt)).. (header
4710: 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65        (vector-re
4720: 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28  f rundat 0)).. (
4730: 72 75 6e 73 20 20 20 20 20 20 20 20 28 76 65 63  runs        (vec
4740: 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31  tor-ref rundat 1
4750: 29 29 29 0a 20 20 20 20 28 70 72 69 6e 74 20 22  ))).    (print "
4760: 48 65 61 64 65 72 3a 20 22 20 68 65 61 64 65 72  Header: " header
4770: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a  ).    (for-each.
4780: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75       (lambda (ru
4790: 6e 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28  n).       (let (
47a0: 28 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d  (runkey (string-
47b0: 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70  intersperse (map
47c0: 20 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09   (lambda (k)....
47d0: 09 09 09 28 64 62 2d 67 65 74 2d 76 61 6c 75 65  ...(db-get-value
47e0: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
47f0: 65 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65  eader (vector-re
4800: 66 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22  f k 0))) keys) "
4810: 2f 22 29 29 29 0a 09 20 28 6c 65 74 2a 20 28 28  /"))).. (let* ((
4820: 72 75 6e 2d 69 64 20 28 64 62 2d 67 65 74 2d 76  run-id (db-get-v
4830: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
4840: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20  un header "id") 
4850: 29 0a 09 09 28 74 65 73 74 73 20 20 28 64 62 2d  )...(tests  (db-
4860: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75  get-tests-for-ru
4870: 6e 20 64 62 20 28 64 62 2d 67 65 74 2d 76 61 6c  n db (db-get-val
4880: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
4890: 20 68 65 61 64 65 72 20 22 69 64 22 29 20 74 65   header "id") te
48a0: 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29  stpatt itempatt)
48b0: 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68 20 22  )...(lasttpath "
48c0: 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f  /does/not/exist/
48d0: 49 2f 68 6f 70 65 22 29 29 0a 09 20 20 20 28 69  I/hope"))..   (i
48e0: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65  f (not (null? te
48f0: 73 74 73 29 29 0a 09 20 20 20 20 20 20 20 28 62  sts))..       (b
4900: 65 67 69 6e 0a 09 09 20 28 70 72 69 6e 74 20 22  egin... (print "
4910: 52 65 6d 6f 76 69 6e 67 20 74 65 73 74 73 20 66  Removing tests f
4920: 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79  or run: " runkey
4930: 20 22 20 22 20 28 64 62 2d 67 65 74 2d 76 61 6c   " " (db-get-val
4940: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
4950: 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65   header "runname
4960: 22 29 29 0a 09 09 20 28 66 6f 72 2d 65 61 63 68  "))... (for-each
4970: 0a 09 09 20 20 28 6c 61 6d 62 64 61 20 28 74 65  ...  (lambda (te
4980: 73 74 29 0a 09 09 20 20 20 20 28 70 72 69 6e 74  st)...    (print
4990: 20 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67   "  " (db:test-g
49a0: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
49b0: 29 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65  ) " id: " (db:te
49c0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20  st-get-id test) 
49d0: 22 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  " " (db:test-get
49e0: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29  -item-path test)
49f0: 29 0a 09 09 20 20 20 20 28 64 62 3a 64 65 6c 65  )...    (db:dele
4a00: 74 65 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20  te-test-records 
4a10: 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  db (db:test-get-
4a20: 69 64 20 74 65 73 74 29 29 0a 09 09 20 20 20 20  id test))...    
4a30: 28 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c  (if (> (string-l
4a40: 65 6e 67 74 68 20 28 64 62 3a 74 65 73 74 2d 67  ength (db:test-g
4a50: 65 74 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29  et-rundir test))
4a60: 20 35 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69   5) ;; bad heuri
4a70: 73 74 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20  stic but should 
4a80: 70 72 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f  prevent /tmp /ho
4a90: 6d 65 20 65 74 63 2e 0a 09 09 09 28 6c 65 74 20  me etc.....(let 
4aa0: 28 28 66 75 6c 6c 70 61 74 68 20 28 64 62 3a 74  ((fullpath (db:t
4ab0: 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20 74  est-get-rundir t
4ac0: 65 73 74 29 29 29 20 3b 3b 20 22 2f 22 20 28 64  est))) ;; "/" (d
4ad0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
4ae0: 70 61 74 68 20 74 65 73 74 29 29 29 29 0a 09 09  path test))))...
4af0: 09 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61  .  (set! lasttpa
4b00: 74 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  th fullpath)....
4b10: 20 20 28 70 72 69 6e 74 20 22 72 6d 20 2d 72 66    (print "rm -rf
4b20: 20 22 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09   " fullpath)....
4b30: 20 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20    (system (conc 
4b40: 22 72 6d 20 2d 72 66 20 22 20 66 75 6c 6c 70 61  "rm -rf " fullpa
4b50: 74 68 29 29 0a 09 09 09 20 20 28 6c 65 74 20 28  th))....  (let (
4b60: 28 63 6d 64 20 28 63 6f 6e 63 20 22 72 6d 64 69  (cmd (conc "rmdi
4b70: 72 20 2d 70 20 22 20 28 67 65 74 2d 64 69 72 2d  r -p " (get-dir-
4b80: 75 70 2d 6f 6e 65 20 66 75 6c 6c 70 61 74 68 29  up-one fullpath)
4b90: 29 29 29 0a 09 09 09 20 20 20 20 28 70 72 69 6e  )))....    (prin
4ba0: 74 20 63 6d 64 29 0a 09 09 09 20 20 20 20 28 73  t cmd)....    (s
4bb0: 79 73 74 65 6d 20 63 6d 64 29 29 0a 09 09 09 20  ystem cmd)).... 
4bc0: 20 29 29 29 0a 09 09 20 20 74 65 73 74 73 29 29   )))...  tests))
4bd0: 29 0a 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d  )..   (let ((rem
4be0: 74 65 73 74 73 20 28 64 62 2d 67 65 74 2d 74 65  tests (db-get-te
4bf0: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28  sts-for-run db (
4c00: 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db-get-value-by-
4c10: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
4c20: 72 20 22 69 64 22 29 29 29 29 0a 09 20 20 20 20  r "id"))))..    
4c30: 20 28 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74   (if (null? remt
4c40: 65 73 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65  ests) ;; no more
4c50: 20 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67   tests remaining
4c60: 0a 09 09 20 28 6c 65 74 2a 20 28 28 64 70 61 72  ... (let* ((dpar
4c70: 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ts  (string-spli
4c80: 74 20 6c 61 73 74 74 70 61 74 68 20 22 2f 22 29  t lasttpath "/")
4c90: 29 0a 09 09 09 28 72 75 6e 70 61 74 68 20 28 63  )....(runpath (c
4ca0: 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d  onc "/" (string-
4cb0: 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09 09 09  intersperse ....
4cc0: 09 09 20 20 20 20 28 74 61 6b 65 20 64 70 61 72  ..    (take dpar
4cd0: 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70  ts (- (length dp
4ce0: 61 72 74 73 29 20 31 29 29 0a 09 09 09 09 09 20  arts) 1))...... 
4cf0: 20 20 20 22 2f 22 29 29 29 29 0a 09 09 20 20 20     "/"))))...   
4d00: 28 70 72 69 6e 74 20 22 52 65 6d 6f 76 69 6e 67  (print "Removing
4d10: 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22   run: " runkey "
4d20: 20 22 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 65   " (db-get-value
4d30: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
4d40: 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29  eader "runname")
4d50: 29 0a 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74  )...   (db:delet
4d60: 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29  e-run db run-id)
4d70: 0a 09 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f  ...   ;; need to
4d80: 20 66 69 67 75 72 65 20 6f 75 74 20 74 68 65 20   figure out the 
4d90: 70 61 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20  path to the run 
4da0: 64 69 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69  dir and remove i
4db0: 74 20 69 66 20 65 6d 70 74 79 0a 09 09 3b 3b 20  t if empty...;; 
4dc0: 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67     (if (null? (g
4dd0: 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61 74  lob (conc runpat
4de0: 68 20 22 2f 2a 22 29 29 29 0a 09 09 3b 3b 20 20  h "/*")))...;;  
4df0: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 3b        (begin...;
4e00: 3b 20 09 20 28 70 72 69 6e 74 20 22 52 65 6d 6f  ; . (print "Remo
4e10: 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72  ving run dir " r
4e20: 75 6e 70 61 74 68 29 0a 09 09 3b 3b 20 09 20 28  unpath)...;; . (
4e30: 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d  system (conc "rm
4e40: 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61 74 68  dir -p " runpath
4e50: 29 29 29 29 0a 09 09 20 20 20 29 29 29 0a 09 09  ))))...   )))...
4e60: 20 29 29 29 0a 20 20 20 20 20 72 75 6e 73 29 29   ))).     runs))
4e70: 29 0a 0a                                         )..