Megatest

Hex Artifact Content
Login

Artifact a13e1910a3378aca8ca30826daf7bdb960162555:


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 2d 74 65 73 74 73  efine (run-tests
2950: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a   db test-names).
2960: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20    (let* ((keys  
2970: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65        (db-get-ke
2980: 79 73 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61  ys db)).. (keyva
2990: 6c 6c 73 74 20 20 20 28 6b 65 79 73 2d 3e 76 61  llst   (keys->va
29a0: 6c 6c 69 73 74 20 6b 65 79 73 20 23 74 29 29 0a  llist keys #t)).
29b0: 09 20 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28  . (run-id      (
29c0: 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20  register-run db 
29d0: 6b 65 79 73 29 29 29 20 3b 3b 20 20 74 65 73 74  keys))) ;;  test
29e0: 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 66 6f  -name))).    (fo
29f0: 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61  r-each .     (la
2a00: 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65 29  mbda (test-name)
2a10: 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 6e  .       (let ((n
2a20: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a 67  um-running (db:g
2a30: 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72  et-count-tests-r
2a40: 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 20 20 20  unning db))..   
2a50: 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e    (max-concurren
2a60: 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c  t-jobs (config-l
2a70: 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74  ookup *configdat
2a80: 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f 63  * "setup" "max_c
2a90: 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29  oncurrent_jobs")
2aa0: 29 29 0a 09 20 28 70 72 69 6e 74 20 22 6d 61 78  )).. (print "max
2ab0: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
2ac0: 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  : " max-concurre
2ad0: 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72  nt-jobs ", num-r
2ae0: 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75  unning: " num-ru
2af0: 6e 6e 69 6e 67 29 0a 09 20 28 69 66 20 28 6f 72  nning).. (if (or
2b00: 20 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75 72   (not max-concur
2b10: 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 20 28 61  rent-jobs)... (a
2b20: 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  nd max-concurren
2b30: 74 2d 6a 6f 62 73 0a 09 09 20 20 20 20 20 20 28  t-jobs...      (
2b40: 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d  string->number m
2b50: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
2b60: 62 73 29 0a 09 09 20 20 20 20 20 20 28 6e 6f 74  bs)...      (not
2b70: 20 28 3e 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20   (> num-running 
2b80: 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20  (string->number 
2b90: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
2ba0: 6f 62 73 29 29 29 29 29 0a 09 20 20 20 20 20 28  obs)))))..     (
2bb0: 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20  run-one-test db 
2bc0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
2bd0: 20 6b 65 79 76 61 6c 6c 73 74 29 0a 09 20 20 20   keyvallst)..   
2be0: 20 20 28 70 72 69 6e 74 20 22 57 41 52 4e 49 4e    (print "WARNIN
2bf0: 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a  G: Max running j
2c00: 6f 62 73 20 65 78 63 65 65 64 65 64 2c 20 63 75  obs exceeded, cu
2c10: 72 72 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e  rrent number run
2c20: 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e  ning: " num-runn
2c30: 69 6e 67 20 0a 09 09 20 20 20 20 22 2c 20 6d 61  ing ...    ", ma
2c40: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
2c50: 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72  s: " max-concurr
2c60: 65 6e 74 2d 6a 6f 62 73 29 29 29 29 0a 20 20 20  ent-jobs)))).   
2c70: 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a    test-names))).
2c80: 0a 3b 3b 20 56 45 52 59 20 49 4e 45 46 46 49 43  .;; VERY INEFFIC
2c90: 49 45 4e 54 21 20 4d 6f 76 65 20 73 74 75 66 66  IENT! Move stuff
2ca0: 20 74 68 61 74 20 73 68 6f 75 6c 64 20 62 65 20   that should be 
2cb0: 64 6f 6e 65 20 6f 6e 63 65 20 75 70 20 74 6f 20  done once up to 
2cc0: 63 61 6c 6c 69 6e 67 20 70 72 6f 63 0a 28 64 65  calling proc.(de
2cd0: 66 69 6e 65 20 28 72 75 6e 2d 6f 6e 65 2d 74 65  fine (run-one-te
2ce0: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
2cf0: 74 2d 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74  t-name keyvallst
2d00: 29 0a 20 20 28 70 72 69 6e 74 20 22 4c 61 75 6e  ).  (print "Laun
2d10: 63 68 69 6e 67 20 74 65 73 74 20 22 20 74 65 73  ching test " tes
2d20: 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41 6c 6c  t-name).  ;; All
2d30: 20 74 68 65 73 65 20 76 61 72 73 20 6d 69 67 68   these vars migh
2d40: 74 20 62 65 20 72 65 66 65 72 65 6e 63 65 64 20  t be referenced 
2d50: 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66 69  by the testconfi
2d60: 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20 20  g file reader.  
2d70: 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53 54  (setenv "MT_TEST
2d80: 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65  _NAME" test-name
2d90: 29 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e 76 20  ) ;; .  (setenv 
2da0: 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20 28  "MT_RUNNAME"   (
2db0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72  args:get-arg ":r
2dc0: 75 6e 6e 61 6d 65 22 29 29 0a 20 20 28 73 65 74  unname")).  (set
2dd0: 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61  -megatest-env-va
2de0: 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b  rs db run-id) ;;
2df0: 20 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65   these may be ne
2e00: 65 64 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e  eded by the laun
2e10: 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20 20  ching process.  
2e20: 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72  (change-director
2e30: 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20 28  y *toppath*).  (
2e40: 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68  let* ((test-path
2e50: 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61      (conc *toppa
2e60: 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65  th* "/tests/" te
2e70: 73 74 2d 6e 61 6d 65 29 29 0a 09 20 28 74 65 73  st-name)).. (tes
2e80: 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20  t-configf (conc 
2e90: 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74  test-path "/test
2ea0: 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 74 65 73  config")).. (tes
2eb0: 74 65 78 69 73 74 73 20 20 20 28 61 6e 64 20 28  texists   (and (
2ec0: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65 73  file-exists? tes
2ed0: 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65 2d  t-configf)(file-
2ee0: 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65 73  read-access? tes
2ef0: 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 20 28  t-configf))).. (
2f00: 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66  test-conf    (if
2f10: 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65 61   testexists (rea
2f20: 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f  d-config test-co
2f30: 6e 66 69 67 66 29 20 28 6d 61 6b 65 2d 68 61 73  nfigf) (make-has
2f40: 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 28 77 61  h-table))).. (wa
2f50: 69 74 6f 6e 20 20 20 20 20 20 20 28 6c 65 74 20  iton       (let 
2f60: 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  ((w (config-look
2f70: 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 72 65  up test-conf "re
2f80: 71 75 69 72 65 6d 65 6e 74 73 22 20 22 77 61 69  quirements" "wai
2f90: 74 6f 6e 22 29 29 29 0a 09 09 09 20 28 69 66 20  ton"))).... (if 
2fa0: 28 73 74 72 69 6e 67 3f 20 77 29 28 73 74 72 69  (string? w)(stri
2fb0: 6e 67 2d 73 70 6c 69 74 20 77 29 27 28 29 29 29  ng-split w)'()))
2fc0: 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20  )).    (if (not 
2fd0: 74 65 73 74 65 78 69 73 74 73 29 0a 09 28 62 65  testexists)..(be
2fe0: 67 69 6e 0a 09 20 20 28 70 72 69 6e 74 20 22 45  gin..  (print "E
2ff0: 52 52 4f 52 3a 20 43 61 6e 27 74 20 66 69 6e 64  RROR: Can't find
3000: 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 22 20 74   config file " t
3010: 65 73 74 2d 63 6f 6e 66 69 67 66 29 0a 09 20 20  est-configf)..  
3020: 28 65 78 69 74 20 32 29 29 0a 09 3b 3b 20 70 75  (exit 2))..;; pu
3030: 74 20 74 6f 70 20 76 61 72 73 20 69 6e 74 6f 20  t top vars into 
3040: 63 6f 6e 76 65 6e 69 65 6e 74 20 76 61 72 69 61  convenient varia
3050: 62 6c 65 73 20 61 6e 64 20 6f 70 65 6e 20 74 68  bles and open th
3060: 65 20 64 62 0a 09 28 6c 65 74 2a 20 28 3b 3b 20  e db..(let* (;; 
3070: 64 62 20 69 73 20 61 6c 77 61 79 73 20 61 74 20  db is always at 
3080: 2a 74 6f 70 70 61 74 68 2a 2f 64 62 2f 6d 65 67  *toppath*/db/meg
3090: 61 74 65 73 74 2e 64 62 0a 09 20 20 20 20 20 20  atest.db..      
30a0: 20 28 69 74 65 6d 73 20 20 20 20 20 20 20 28 68   (items       (h
30b0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
30c0: 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66 20  fault test-conf 
30d0: 22 69 74 65 6d 73 22 20 27 28 29 29 29 0a 09 20  "items" '())).. 
30e0: 20 20 20 20 20 20 28 69 74 65 6d 73 74 61 62 6c        (itemstabl
30f0: 65 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72  e  (hash-table-r
3100: 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d  ef/default test-
3110: 63 6f 6e 66 20 22 69 74 65 6d 73 74 61 62 6c 65  conf "itemstable
3120: 22 20 27 28 29 29 29 0a 09 20 20 20 20 20 20 20  " '()))..       
3130: 28 61 6c 6c 69 74 65 6d 73 20 20 20 20 28 69 66  (allitems    (if
3140: 20 28 6f 72 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (or (not (null?
3150: 20 69 74 65 6d 73 29 29 28 6e 6f 74 20 28 6e 75   items))(not (nu
3160: 6c 6c 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 29  ll? itemstable))
3170: 29 0a 09 09 09 09 28 61 70 70 65 6e 64 20 28 69  ).....(append (i
3180: 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d  tem-assoc->item-
3190: 6c 69 73 74 20 69 74 65 6d 73 29 0a 09 09 09 09  list items).....
31a0: 09 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74  .(item-table->it
31b0: 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62  em-list itemstab
31c0: 6c 65 29 29 0a 09 09 09 09 27 28 28 29 29 29 29  le)).....'(())))
31d0: 20 3b 3b 20 61 20 6c 69 73 74 20 77 69 74 68 20   ;; a list with 
31e0: 6f 6e 65 20 6e 75 6c 6c 20 6c 69 73 74 20 69 73  one null list is
31f0: 20 61 20 74 65 73 74 20 77 69 74 68 20 6e 6f 20   a test with no 
3200: 69 74 65 6d 73 0a 09 20 20 20 20 20 20 20 28 72  items..       (r
3210: 75 6e 63 6f 6e 66 69 67 66 20 20 28 63 6f 6e 63  unconfigf  (conc
3220: 20 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75    *toppath* "/ru
3230: 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22  nconfigs.config"
3240: 29 29 29 0a 09 20 20 28 70 72 69 6e 74 20 22 69  )))..  (print "i
3250: 74 65 6d 73 3a 20 22 29 28 70 70 20 61 6c 6c 69  tems: ")(pp alli
3260: 74 65 6d 73 29 0a 09 20 20 28 69 66 20 28 61 72  tems)..  (if (ar
3270: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29  gs:get-arg "-m")
3280: 0a 09 20 20 20 20 20 20 28 64 62 3a 73 65 74 2d  ..      (db:set-
3290: 63 6f 6d 6d 65 6e 74 2d 66 6f 72 2d 72 75 6e 20  comment-for-run 
32a0: 64 62 20 72 75 6e 2d 69 64 20 28 61 72 67 73 3a  db run-id (args:
32b0: 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 29 29 0a  get-arg "-m"))).
32c0: 09 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 69  .  (let loop ((i
32d0: 74 65 6d 64 61 74 20 28 63 61 72 20 61 6c 6c 69  temdat (car alli
32e0: 74 65 6d 73 29 29 0a 09 09 20 20 20 20 20 28 74  tems))...     (t
32f0: 61 6c 20 20 20 20 20 28 63 64 72 20 61 6c 6c 69  al     (cdr alli
3300: 74 65 6d 73 29 29 29 0a 09 20 20 20 20 3b 3b 20  tems)))..    ;; 
3310: 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 64 61 74  (lambda (itemdat
3320: 29 20 3b 3b 3b 20 28 28 72 69 70 65 6e 65 73 73  ) ;;; ((ripeness
3330: 20 22 6f 76 65 72 72 69 70 65 22 29 20 28 74 65   "overripe") (te
3340: 6d 70 65 72 61 74 75 72 65 20 22 63 6f 6f 6c 22  mperature "cool"
3350: 29 20 28 73 65 61 73 6f 6e 20 22 73 75 6d 6d 65  ) (season "summe
3360: 72 22 29 29 0a 09 20 20 20 20 28 6c 65 74 2a 20  r"))..    (let* 
3370: 28 28 69 74 65 6d 2d 70 61 74 68 20 20 20 20 20  ((item-path     
3380: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
3390: 20 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 28 73   itemdat)) ;; (s
33a0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
33b0: 65 20 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d  e (map cadr item
33c0: 64 61 74 29 20 22 2f 22 29 29 0a 09 09 20 20 20  dat) "/"))...   
33d0: 28 6e 65 77 2d 74 65 73 74 2d 70 61 74 68 20 28  (new-test-path (
33e0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
33f0: 73 65 20 28 63 6f 6e 73 20 74 65 73 74 2d 70 61  se (cons test-pa
3400: 74 68 20 28 6d 61 70 20 63 61 64 72 20 69 74 65  th (map cadr ite
3410: 6d 64 61 74 29 29 20 22 2f 22 29 29 0a 09 09 20  mdat)) "/"))... 
3420: 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65    (new-test-name
3430: 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65   (if (equal? ite
3440: 6d 2d 70 61 74 68 20 22 22 29 20 74 65 73 74 2d  m-path "") test-
3450: 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 2d  name (conc test-
3460: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
3470: 74 68 29 29 29 20 3b 3b 20 6a 75 73 74 20 6e 65  th))) ;; just ne
3480: 65 64 20 69 74 20 74 6f 20 62 65 20 75 6e 69 71  ed it to be uniq
3490: 75 65 0a 09 09 20 20 20 28 74 65 73 74 2d 73 74  ue...   (test-st
34a0: 61 74 75 73 20 20 20 23 66 29 0a 09 09 20 20 20  atus   #f)...   
34b0: 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62  (num-running (db
34c0: 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73  :get-count-tests
34d0: 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 09  -running db))...
34e0: 20 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65     (max-concurre
34f0: 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d  nt-jobs (config-
3500: 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61  lookup *configda
3510: 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f  t* "setup" "max_
3520: 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22  concurrent_jobs"
3530: 29 29 29 0a 09 20 20 20 20 20 20 28 70 72 69 6e  )))..      (prin
3540: 74 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  t "max-concurren
3550: 74 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f  t-jobs: " max-co
3560: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c  ncurrent-jobs ",
3570: 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20   num-running: " 
3580: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 09 20 20  num-running)..  
3590: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6f 72      (if (not (or
35a0: 20 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75 72   (not max-concur
35b0: 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 09 20 20  rent-jobs)....  
35c0: 20 28 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72   (and max-concur
35d0: 72 65 6e 74 2d 6a 6f 62 73 0a 09 09 09 09 28 73  rent-jobs.....(s
35e0: 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61  tring->number ma
35f0: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
3600: 73 29 0a 09 09 09 09 28 6e 6f 74 20 28 3e 20 6e  s).....(not (> n
3610: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69  um-running (stri
3620: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
3630: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29  oncurrent-jobs))
3640: 29 29 29 29 0a 09 09 20 20 28 70 72 69 6e 74 20  ))))...  (print 
3650: 22 57 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75  "WARNING: Max ru
3660: 6e 6e 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65  nning jobs excee
3670: 64 65 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d  ded, current num
3680: 62 65 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e  ber running: " n
3690: 75 6d 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 20  um-running .... 
36a0: 22 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e  ", max_concurren
36b0: 74 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f  t_jobs: " max-co
36c0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09  ncurrent-jobs)..
36d0: 09 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20  .  (begin...    
36e0: 28 6c 65 74 20 6c 6f 6f 70 32 20 28 28 74 73 20  (let loop2 ((ts 
36f0: 23 66 29 0a 09 09 09 09 28 63 74 20 30 29 29 0a  #f).....(ct 0)).
3700: 09 09 20 20 20 20 20 20 28 69 66 20 28 61 6e 64  ..      (if (and
3710: 20 28 6e 6f 74 20 74 73 29 0a 09 09 09 20 20 20   (not ts)....   
3720: 20 20 20 20 28 3c 20 63 74 20 31 30 29 29 0a 09      (< ct 10))..
3730: 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20  ..  (begin....  
3740: 20 20 28 72 65 67 69 73 74 65 72 2d 74 65 73 74    (register-test
3750: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
3760: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a  name item-path).
3770: 09 09 09 20 20 20 20 28 64 62 3a 74 65 73 74 2d  ...    (db:test-
3780: 73 65 74 2d 63 6f 6d 6d 65 6e 74 20 64 62 20 72  set-comment db r
3790: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
37a0: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 0a 09 09  item-path "")...
37b0: 09 20 20 20 20 3b 3b 20 28 74 65 73 74 2d 73 65  .    ;; (test-se
37c0: 74 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e  t-status! db run
37d0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 22 4e  -id test-name "N
37e0: 4f 54 5f 53 54 41 52 54 45 44 22 20 22 6e 2f 61  OT_STARTED" "n/a
37f0: 22 20 69 74 65 6d 64 61 74 20 22 22 29 0a 09 09  " itemdat "")...
3800: 09 20 20 20 20 3b 3b 20 28 64 62 3a 73 65 74 2d  .    ;; (db:set-
3810: 63 6f 6d 6d 65 6e 74 2d 66 6f 72 2d 74 65 73 74  comment-for-test
3820: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
3830: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 20 22  name item-path "
3840: 22 29 0a 09 09 09 20 20 20 20 28 64 62 3a 64 65  ")....    (db:de
3850: 6c 65 74 65 2d 74 65 73 74 2d 73 74 65 70 2d 72  lete-test-step-r
3860: 65 63 6f 72 64 73 20 64 62 20 72 75 6e 2d 69 64  ecords db run-id
3870: 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 63   test-name) ;; c
3880: 6c 65 61 6e 20 6f 75 74 20 69 66 20 74 68 69 73  lean out if this
3890: 20 69 73 20 61 20 72 65 2d 72 75 6e 0a 09 09 09   is a re-run....
38a0: 20 20 20 20 28 6c 6f 6f 70 32 20 28 64 62 3a 67      (loop2 (db:g
38b0: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20  et-test-info db 
38c0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
38d0: 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 09   item-path).....
38e0: 20 20 20 28 2b 20 63 74 20 31 29 29 29 0a 09 09     (+ ct 1)))...
38f0: 09 20 20 28 69 66 20 74 73 0a 09 09 09 20 20 20  .  (if ts....   
3900: 20 20 20 28 73 65 74 21 20 74 65 73 74 2d 73 74     (set! test-st
3910: 61 74 75 73 20 74 73 29 0a 09 09 09 20 20 20 20  atus ts)....    
3920: 20 20 28 62 65 67 69 6e 0a 09 09 09 09 28 70 72    (begin.....(pr
3930: 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20 43 6f  int "WARNING: Co
3940: 75 6c 64 6e 27 74 20 72 65 67 69 73 74 65 72 20  uldn't register 
3950: 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65  test " test-name
3960: 20 22 20 77 69 74 68 20 69 74 65 6d 20 70 61 74   " with item pat
3970: 68 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 2c  h " item-path ",
3980: 20 73 6b 69 70 70 69 6e 67 22 29 0a 09 09 09 09   skipping").....
3990: 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  (if (not (null? 
39a0: 74 61 6c 29 29 0a 09 09 09 09 20 20 20 20 28 6c  tal)).....    (l
39b0: 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64  oop (car tal)(cd
39c0: 72 20 74 61 6c 29 29 29 29 29 29 29 0a 09 09 20  r tal)))))))... 
39d0: 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63     (change-direc
39e0: 74 6f 72 79 20 74 65 73 74 2d 70 61 74 68 29 0a  tory test-path).
39f0: 09 09 20 20 20 20 3b 3b 20 74 68 69 73 20 62 6c  ..    ;; this bl
3a00: 6f 63 6b 20 69 73 20 68 65 72 65 20 6f 6e 6c 79  ock is here only
3a10: 20 74 6f 20 69 6e 66 6f 72 6d 20 74 68 65 20 75   to inform the u
3a20: 73 65 72 20 65 61 72 6c 79 20 6f 6e 0a 09 09 20  ser early on... 
3a30: 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69     (if (file-exi
3a40: 73 74 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29  sts? runconfigf)
3a50: 0a 09 09 09 28 73 65 74 75 70 2d 65 6e 76 2d 64  ....(setup-env-d
3a60: 65 66 61 75 6c 74 73 20 64 62 20 72 75 6e 63 6f  efaults db runco
3a70: 6e 66 69 67 66 20 72 75 6e 2d 69 64 20 2a 61 6c  nfigf run-id *al
3a80: 72 65 61 64 79 2d 73 65 65 6e 2d 72 75 6e 63 6f  ready-seen-runco
3a90: 6e 66 69 67 2d 69 6e 66 6f 2a 29 0a 09 09 09 28  nfig-info*)....(
3aa0: 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20  print "WARNING: 
3ab0: 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20  You do not have 
3ac0: 61 20 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c  a run config fil
3ad0: 65 3a 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29  e: " runconfigf)
3ae0: 29 0a 09 09 20 20 20 20 3b 3b 20 28 70 72 69 6e  )...    ;; (prin
3af0: 74 20 22 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e  t "run-id: " run
3b00: 2d 69 64 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a  -id " test-name:
3b10: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69   " test-name " i
3b20: 74 65 6d 2d 70 61 74 68 3a 20 22 20 69 74 65 6d  tem-path: " item
3b30: 2d 70 61 74 68 20 22 20 74 65 73 74 2d 73 74 61  -path " test-sta
3b40: 74 75 73 3a 20 22 20 28 74 65 73 74 3a 67 65 74  tus: " (test:get
3b50: 2d 73 74 61 74 75 73 20 74 65 73 74 2d 73 74 61  -status test-sta
3b60: 74 75 73 29 20 22 20 74 65 73 74 2d 73 74 61 74  tus) " test-stat
3b70: 65 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  e: " (test:get-s
3b80: 74 61 74 65 20 74 65 73 74 2d 73 74 61 74 75 73  tate test-status
3b90: 29 29 0a 09 09 20 20 20 20 28 63 61 73 65 20 28  ))...    (case (
3ba0: 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  if (args:get-arg
3bb0: 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 20 20   "-force")....  
3bc0: 20 20 20 20 27 4e 4f 54 5f 53 54 41 52 54 45 44      'NOT_STARTED
3bd0: 0a 09 09 09 20 20 20 20 20 20 28 69 66 20 74 65  ....      (if te
3be0: 73 74 2d 73 74 61 74 75 73 0a 09 09 09 09 20 20  st-status.....  
3bf0: 28 73 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20  (string->symbol 
3c00: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
3c10: 74 65 73 74 2d 73 74 61 74 75 73 29 29 0a 09 09  test-status))...
3c20: 09 09 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d 69  ..  'failed-to-i
3c30: 6e 73 65 72 74 29 29 0a 09 09 20 20 20 20 20 20  nsert))...      
3c40: 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65  ((failed-to-inse
3c50: 72 74 29 0a 09 09 20 20 20 20 20 20 20 28 70 72  rt)...       (pr
3c60: 69 6e 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c  int "ERROR: Fail
3c70: 65 64 20 74 6f 20 69 6e 73 65 72 74 20 74 68 65  ed to insert the
3c80: 20 72 65 63 6f 72 64 20 69 6e 74 6f 20 74 68 65   record into the
3c90: 20 64 62 22 29 29 0a 09 09 20 20 20 20 20 20 28   db"))...      (
3ca0: 28 4e 4f 54 5f 53 54 41 52 54 45 44 20 43 4f 4d  (NOT_STARTED COM
3cb0: 50 4c 45 54 45 44 29 20 3b 3b 20 28 63 61 64 72  PLETED) ;; (cadr
3cc0: 20 73 74 61 74 75 73 20 69 73 20 74 68 65 20 72   status is the r
3cd0: 6f 77 20 69 64 20 66 6f 72 20 74 68 65 20 72 75  ow id for the ru
3ce0: 6e 20 72 65 63 6f 72 64 29 0a 09 09 20 20 20 20  n record)...    
3cf0: 20 20 20 28 69 66 20 28 61 6e 64 20 28 65 71 75     (if (and (equ
3d00: 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74  al? (test:get-st
3d10: 61 74 65 20 74 65 73 74 2d 73 74 61 74 75 73 29  ate test-status)
3d20: 20 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 0a 09    "COMPLETED")..
3d30: 09 09 09 28 6f 72 20 28 65 71 75 61 6c 3f 20 28  ...(or (equal? (
3d40: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
3d50: 74 65 73 74 2d 73 74 61 74 75 73 29 20 22 50 41  test-status) "PA
3d60: 53 53 22 29 0a 09 09 09 09 20 20 20 20 28 65 71  SS").....    (eq
3d70: 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73  ual? (test:get-s
3d80: 74 61 74 75 73 20 74 65 73 74 2d 73 74 61 74 75  tatus test-statu
3d90: 73 29 20 22 57 41 52 4e 22 29 0a 09 09 09 09 20  s) "WARN")..... 
3da0: 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74     (equal? (test
3db0: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
3dc0: 2d 73 74 61 74 75 73 29 20 22 43 48 45 43 4b 22  -status) "CHECK"
3dd0: 29 29 0a 09 09 09 09 28 6e 6f 74 20 28 61 72 67  )).....(not (arg
3de0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63  s:get-arg "-forc
3df0: 65 22 29 29 29 0a 09 09 09 20 20 20 28 70 72 69  e")))....   (pri
3e00: 6e 74 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73 74  nt "NOTE: Not st
3e10: 61 72 74 69 6e 67 20 74 65 73 74 20 22 20 6e 65  arting test " ne
3e20: 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 73  w-test-name " as
3e30: 20 69 74 20 69 73 20 73 74 61 74 65 20 5c 22 43   it is state \"C
3e40: 4f 4d 50 4c 45 54 45 44 5c 22 20 61 6e 64 20 73  OMPLETED\" and s
3e50: 74 61 74 75 73 20 5c 22 22 20 28 74 65 73 74 3a  tatus \"" (test:
3e60: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 2d  get-status test-
3e70: 73 74 61 74 75 73 29 20 22 5c 22 2c 20 75 73 65  status) "\", use
3e80: 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72 72   -force to overr
3e90: 69 64 65 22 29 0a 09 09 09 20 20 20 28 6c 65 74  ide")....   (let
3ea0: 2a 20 28 28 67 65 74 2d 70 72 65 72 65 71 73 2d  * ((get-prereqs-
3eb0: 63 6d 64 20 28 6c 61 6d 62 64 61 20 28 29 0a 09  cmd (lambda ()..
3ec0: 09 09 09 09 09 20 20 20 20 20 28 64 62 2d 67 65  .....     (db-ge
3ed0: 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  t-prereqs-not-me
3ee0: 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74  t db run-id wait
3ef0: 6f 6e 29 29 29 20 3b 3b 20 63 68 65 63 6b 20 62  on))) ;; check b
3f00: 65 66 6f 72 65 20 72 75 6e 6e 69 6e 67 20 2e 2e  efore running ..
3f10: 2e 2e 0a 09 09 09 09 20 20 28 6c 61 75 6e 63 68  .......  (launch
3f20: 2d 63 6d 64 20 20 20 20 20 20 28 6c 61 6d 62 64  -cmd      (lambd
3f30: 61 20 28 29 0a 09 09 09 09 09 09 20 20 20 20 20  a ().......     
3f40: 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62 20  (launch-test db 
3f50: 72 75 6e 2d 69 64 20 74 65 73 74 2d 63 6f 6e 66  run-id test-conf
3f60: 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d   keyvallst test-
3f70: 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68 20 69  name test-path i
3f80: 74 65 6d 64 61 74 29 29 29 0a 09 09 09 09 20 20  temdat))).....  
3f90: 28 74 65 73 74 72 75 6e 64 61 74 20 20 20 20 20  (testrundat     
3fa0: 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65 72 65   (list get-prere
3fb0: 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d 63 6d  qs-cmd launch-cm
3fc0: 64 29 29 29 0a 09 09 09 20 20 20 20 20 28 69 66  d)))....     (if
3fd0: 20 28 6f 72 20 28 61 72 67 73 3a 67 65 74 2d 61   (or (args:get-a
3fe0: 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09  rg "-force")....
3ff0: 09 20 20 20 20 20 28 6e 75 6c 6c 3f 20 28 28 63  .     (null? ((c
4000: 61 72 20 74 65 73 74 72 75 6e 64 61 74 29 29 29  ar testrundat)))
4010: 29 20 3b 3b 20 61 72 65 20 74 68 65 72 65 20 61  ) ;; are there a
4020: 6e 79 20 74 65 73 74 73 20 74 68 61 74 20 6d 75  ny tests that mu
4030: 73 74 20 62 65 20 72 75 6e 20 62 65 66 6f 72 65  st be run before
4040: 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09 09 09   this one.......
4050: 09 20 28 28 63 61 64 72 20 74 65 73 74 72 75 6e  . ((cadr testrun
4060: 64 61 74 29 29 20 3b 3b 20 74 68 69 73 20 69 73  dat)) ;; this is
4070: 20 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20 6c   the line that l
4080: 61 75 6e 63 68 65 73 20 74 68 65 20 74 65 73 74  aunches the test
4090: 20 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20 68   to the remote h
40a0: 6f 73 74 0a 09 09 09 09 20 28 68 61 73 68 2d 74  ost..... (hash-t
40b0: 61 62 6c 65 2d 73 65 74 21 20 2a 77 61 69 74 69  able-set! *waiti
40c0: 6e 67 2d 71 75 65 75 65 2a 20 6e 65 77 2d 74 65  ng-queue* new-te
40d0: 73 74 2d 6e 61 6d 65 20 74 65 73 74 72 75 6e 64  st-name testrund
40e0: 61 74 29 29 29 29 29 0a 09 09 20 20 20 20 20 20  at)))))...      
40f0: 28 28 4b 49 4c 4c 45 44 29 20 0a 09 09 20 20 20  ((KILLED) ...   
4100: 20 20 20 20 28 70 72 69 6e 74 20 22 4e 4f 54 45      (print "NOTE
4110: 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  : " new-test-nam
4120: 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72  e " is already r
4130: 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78  unning or was ex
4140: 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20  plictly killed, 
4150: 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61  use -force to la
4160: 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20 20  unch it."))...  
4170: 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20 52      ((LAUNCHED R
4180: 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52  EMOTEHOSTSTART R
4190: 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20 20  UNNING)  ...    
41a0: 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75     (if (> (- (cu
41b0: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b  rrent-seconds)(+
41c0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76   (db:test-get-ev
41d0: 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 2d 73 74  ent_time test-st
41e0: 61 74 75 73 29 0a 09 09 09 09 09 09 20 20 20 20  atus).......    
41f0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75   (db:test-get-ru
4200: 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65 73 74 2d  n_duration test-
4210: 73 74 61 74 75 73 29 29 29 0a 09 09 09 20 20 20  status)))....   
4220: 20 20 20 31 30 30 29 20 3b 3b 20 69 2e 65 2e 20     100) ;; i.e. 
4230: 6e 6f 20 75 70 64 61 74 65 20 66 6f 72 20 6d 6f  no update for mo
4240: 72 65 20 74 68 61 6e 20 31 30 30 20 73 65 63 6f  re than 100 seco
4250: 6e 64 73 0a 09 09 09 20 20 20 28 62 65 67 69 6e  nds....   (begin
4260: 0a 09 09 09 20 20 20 20 20 28 70 72 69 6e 74 20  ....     (print 
4270: 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22  "WARNING: Test "
4280: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70   test-name " app
4290: 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e  ears to be dead.
42a0: 22 29 0a 09 09 09 20 20 20 20 20 28 74 65 73 74  ")....     (test
42b0: 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62 20  -set-status! db 
42c0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
42d0: 20 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53   "INCOMPLETE" "S
42e0: 54 55 43 4b 2f 44 45 41 44 22 20 69 74 65 6d 64  TUCK/DEAD" itemd
42f0: 61 74 20 22 54 65 73 74 20 69 73 20 73 74 75 63  at "Test is stuc
4300: 6b 20 6f 72 20 64 65 61 64 22 29 29 0a 09 09 09  k or dead"))....
4310: 20 20 20 28 70 72 69 6e 74 20 22 4e 4f 54 45 3a     (print "NOTE:
4320: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69   " test-name " i
4330: 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e  s already runnin
4340: 67 22 29 29 29 0a 09 09 20 20 20 20 20 20 28 65  g")))...      (e
4350: 6c 73 65 20 20 20 20 20 20 20 28 70 72 69 6e 74  lse       (print
4360: 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20   "ERROR: Failed 
4370: 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22  to launch test "
4380: 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22   new-test-name "
4390: 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20 73  . Unrecognised s
43a0: 74 61 74 65 20 22 20 28 74 65 73 74 3a 67 65 74  tate " (test:get
43b0: 2d 73 74 61 74 65 20 74 65 73 74 2d 73 74 61 74  -state test-stat
43c0: 75 73 29 29 29 29 29 29 0a 09 20 20 20 20 20 20  us))))))..      
43d0: 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  (if (not (null? 
43e0: 74 61 6c 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20  tal))...  (loop 
43f0: 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61  (car tal)(cdr ta
4400: 6c 29 29 29 29 29 29 29 29 29 0a 0a 28 64 65 66  l)))))))))..(def
4410: 69 6e 65 20 28 72 75 6e 2d 77 61 69 74 69 6e 67  ine (run-waiting
4420: 2d 74 65 73 74 73 20 64 62 29 0a 20 20 28 6c 65  -tests db).  (le
4430: 74 20 28 28 6e 75 6d 74 72 69 65 73 20 20 20 20  t ((numtries    
4440: 20 20 20 20 20 20 20 30 29 0a 09 28 6c 61 73 74         0)..(last
4450: 2d 74 72 79 2d 74 69 6d 65 20 20 20 20 20 20 28  -try-time      (
4460: 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29  current-seconds)
4470: 29 0a 09 28 74 69 6d 65 73 20 20 20 20 20 20 20  )..(times       
4480: 20 20 20 20 20 20 20 28 6c 69 73 74 20 31 29 29         (list 1))
4490: 29 20 3b 3b 20 6d 69 6e 75 74 65 73 20 74 6f 20  ) ;; minutes to 
44a0: 77 61 69 74 20 62 65 66 6f 72 65 20 74 72 79 69  wait before tryi
44b0: 6e 67 20 61 67 61 69 6e 20 74 6f 20 6b 69 63 6b  ng again to kick
44c0: 20 6f 66 66 20 72 75 6e 73 0a 20 20 20 20 3b 3b   off runs.    ;;
44d0: 20 42 55 47 20 74 68 69 73 20 68 61 63 6b 20 6f   BUG this hack o
44e0: 66 20 62 72 75 74 65 20 66 6f 72 63 65 20 72 65  f brute force re
44f0: 74 72 79 69 6e 67 20 77 6f 72 6b 73 20 71 75 69  trying works qui
4500: 74 65 20 77 65 6c 6c 20 66 6f 72 20 6d 61 6e 79  te well for many
4510: 20 63 61 73 65 73 20 62 75 74 20 0a 20 20 20 20   cases but .    
4520: 3b 3b 20 20 20 20 20 77 68 61 74 20 69 73 20 6e  ;;     what is n
4530: 65 65 64 65 64 20 69 73 20 74 6f 20 63 68 65 63  eeded is to chec
4540: 6b 20 74 68 65 20 64 62 20 66 6f 72 20 74 65 73  k the db for tes
4550: 74 73 20 74 68 61 74 20 68 61 76 65 20 66 61 69  ts that have fai
4560: 6c 65 64 20 6c 65 73 73 20 74 68 61 6e 0a 20 20  led less than.  
4570: 20 20 3b 3b 20 20 20 20 20 4e 20 74 69 6d 65 73    ;;     N times
4580: 20 6f 72 20 6e 65 76 65 72 20 62 65 65 6e 20 73   or never been s
4590: 74 61 72 74 65 64 20 61 6e 64 20 6b 69 63 6b 20  tarted and kick 
45a0: 74 68 65 6d 20 6f 66 66 20 61 67 61 69 6e 0a 20  them off again. 
45b0: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 77     (let loop ((w
45c0: 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65  aiting-test-name
45d0: 73 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65  s (hash-table-ke
45e0: 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75  ys *waiting-queu
45f0: 65 2a 29 29 29 0a 20 20 20 20 20 20 28 63 6f 6e  e*))).      (con
4600: 64 0a 20 20 20 20 20 20 20 28 28 6e 75 6c 6c 3f  d.       ((null?
4610: 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61   waiting-test-na
4620: 6d 65 73 29 0a 09 28 70 72 69 6e 74 20 22 41 6c  mes)..(print "Al
4630: 6c 20 74 65 73 74 73 20 6c 61 75 6e 63 68 65 64  l tests launched
4640: 22 29 29 0a 20 20 20 20 20 20 20 28 28 3e 20 6e  ")).       ((> n
4650: 75 6d 74 72 69 65 73 20 34 29 0a 09 28 70 72 69  umtries 4)..(pri
4660: 6e 74 20 22 4e 4f 54 45 3a 20 54 72 69 65 64 20  nt "NOTE: Tried 
4670: 6c 61 75 6e 63 68 69 6e 67 20 66 6f 75 72 20 74  launching four t
4680: 69 6d 65 73 2c 20 70 65 72 68 61 70 73 20 72 75  imes, perhaps ru
4690: 6e 20 6d 65 67 61 74 65 73 74 20 61 67 61 69 6e  n megatest again
46a0: 20 69 6e 20 61 20 66 65 77 20 6d 69 6e 75 74 65   in a few minute
46b0: 73 22 29 29 0a 20 20 20 20 20 20 20 28 65 6c 73  s")).       (els
46c0: 65 0a 09 28 73 65 74 21 20 6e 75 6d 74 72 69 65  e..(set! numtrie
46d0: 73 20 28 2b 20 6e 75 6d 74 72 69 65 73 20 31 29  s (+ numtries 1)
46e0: 29 0a 09 28 66 6f 72 2d 65 61 63 68 20 28 6c 61  )..(for-each (la
46f0: 6d 62 64 61 20 28 74 65 73 74 6e 61 6d 65 29 0a  mbda (testname).
4700: 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65  ..    (let* ((te
4710: 73 74 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c  stdat (hash-tabl
4720: 65 2d 72 65 66 20 2a 77 61 69 74 69 6e 67 2d 71  e-ref *waiting-q
4730: 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29  ueue* testname))
4740: 0a 09 09 09 20 20 20 28 70 72 65 72 65 71 73 20  ....   (prereqs 
4750: 28 28 63 61 72 20 74 65 73 74 64 61 74 29 29 29  ((car testdat)))
4760: 0a 09 09 09 20 20 20 28 6c 64 62 20 20 20 20 20  ....   (ldb     
4770: 28 69 66 20 64 62 20 64 62 20 28 6f 70 65 6e 2d  (if db db (open-
4780: 64 62 29 29 29 29 0a 09 09 20 20 20 20 20 20 3b  db))))...      ;
4790: 3b 20 28 70 72 69 6e 74 20 22 70 72 65 72 65 71  ; (print "prereq
47a0: 73 20 72 65 6d 61 69 6e 69 6e 67 3a 20 22 20 70  s remaining: " p
47b0: 72 65 72 65 71 73 29 0a 09 09 20 20 20 20 20 20  rereqs)...      
47c0: 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65  (if (null? prere
47d0: 71 73 29 0a 09 09 09 20 20 28 62 65 67 69 6e 0a  qs)....  (begin.
47e0: 09 09 09 20 20 20 20 28 70 72 69 6e 74 20 22 50  ...    (print "P
47f0: 72 65 72 65 71 75 69 73 69 74 65 73 20 6d 65 74  rerequisites met
4800: 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22 20 74 65  , launching " te
4810: 73 74 6e 61 6d 65 29 0a 09 09 09 20 20 20 20 28  stname)....    (
4820: 28 63 61 64 72 20 74 65 73 74 64 61 74 29 29 0a  (cadr testdat)).
4830: 09 09 09 20 20 20 20 28 68 61 73 68 2d 74 61 62  ...    (hash-tab
4840: 6c 65 2d 64 65 6c 65 74 65 21 20 2a 77 61 69 74  le-delete! *wait
4850: 69 6e 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e  ing-queue* testn
4860: 61 6d 65 29 29 29 0a 09 09 20 20 20 20 20 20 28  ame)))...      (
4870: 69 66 20 28 6e 6f 74 20 64 62 29 0a 09 09 09 20  if (not db).... 
4880: 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69   (sqlite3:finali
4890: 7a 65 21 20 6c 64 62 29 29 29 29 0a 09 09 20 20  ze! ldb))))...  
48a0: 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d  waiting-test-nam
48b0: 65 73 29 0a 09 28 73 6c 65 65 70 20 31 30 29 20  es)..(sleep 10) 
48c0: 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e 20 72  ;; no point in r
48d0: 75 73 68 69 6e 67 20 74 68 69 6e 67 73 20 61 74  ushing things at
48e0: 20 74 68 69 73 20 73 74 61 67 65 3f 0a 09 28 6c   this stage?..(l
48f0: 6f 6f 70 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  oop (hash-table-
4900: 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75  keys *waiting-qu
4910: 65 75 65 2a 29 29 29 29 29 29 29 0a 0a 28 64 65  eue*)))))))..(de
4920: 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75 70  fine (get-dir-up
4930: 2d 6f 6e 65 20 64 69 72 29 20 0a 20 20 28 6c 65  -one dir) .  (le
4940: 74 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72  t ((dparts  (str
4950: 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22 2f  ing-split dir "/
4960: 22 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22  "))).    (conc "
4970: 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  /" (string-inter
4980: 73 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20  sperse ..       
4990: 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20  (take dparts (- 
49a0: 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20  (length dparts) 
49b0: 31 29 29 0a 09 20 20 20 20 20 20 20 22 2f 22 29  1))..       "/")
49c0: 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72 75  ))).;; Remove ru
49d0: 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72 65  ns.;; fields are
49e0: 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72 6f   passing in thro
49f0: 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28 72 75  ugh .(define (ru
4a00: 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20 64  ns:remove-runs d
4a10: 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74 65  b runnamepatt te
4a20: 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29  stpatt itempatt)
4a30: 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20  .  (let* ((keys 
4a40: 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b         (db-get-k
4a50: 65 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e 64  eys db)).. (rund
4a60: 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65  at      (runs:ge
4a70: 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64  t-runs-by-patt d
4a80: 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61  b keys runnamepa
4a90: 74 74 29 29 0a 09 20 28 68 65 61 64 65 72 20 20  tt)).. (header  
4aa0: 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20      (vector-ref 
4ab0: 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72 75  rundat 0)).. (ru
4ac0: 6e 73 20 20 20 20 20 20 20 20 28 76 65 63 74 6f  ns        (vecto
4ad0: 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29 29  r-ref rundat 1))
4ae0: 29 0a 20 20 20 20 28 70 72 69 6e 74 20 22 48 65  ).    (print "He
4af0: 61 64 65 72 3a 20 22 20 68 65 61 64 65 72 29 0a  ader: " header).
4b00: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20      (for-each.  
4b10: 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e 29     (lambda (run)
4b20: 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 72  .       (let ((r
4b30: 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69 6e  unkey (string-in
4b40: 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 28  tersperse (map (
4b50: 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09 09  lambda (k)......
4b60: 09 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62  .(db-get-value-b
4b70: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
4b80: 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66 20  der (vector-ref 
4b90: 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f 22  k 0))) keys) "/"
4ba0: 29 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 72 75  ))).. (let* ((ru
4bb0: 6e 2d 69 64 20 28 64 62 2d 67 65 74 2d 76 61 6c  n-id (db-get-val
4bc0: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
4bd0: 20 68 65 61 64 65 72 20 22 69 64 22 29 20 29 0a   header "id") ).
4be0: 09 09 28 74 65 73 74 73 20 20 28 64 62 2d 67 65  ..(tests  (db-ge
4bf0: 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20  t-tests-for-run 
4c00: 64 62 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 65  db (db-get-value
4c10: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
4c20: 65 61 64 65 72 20 22 69 64 22 29 20 74 65 73 74  eader "id") test
4c30: 70 61 74 74 20 69 74 65 6d 70 61 74 74 29 29 0a  patt itempatt)).
4c40: 09 09 28 6c 61 73 74 74 70 61 74 68 20 22 2f 64  ..(lasttpath "/d
4c50: 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f  oes/not/exist/I/
4c60: 68 6f 70 65 22 29 29 0a 09 20 20 20 28 69 66 20  hope"))..   (if 
4c70: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74  (not (null? test
4c80: 73 29 29 0a 09 20 20 20 20 20 20 20 28 62 65 67  s))..       (beg
4c90: 69 6e 0a 09 09 20 28 70 72 69 6e 74 20 22 52 65  in... (print "Re
4ca0: 6d 6f 76 69 6e 67 20 74 65 73 74 73 20 66 6f 72  moving tests for
4cb0: 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22   run: " runkey "
4cc0: 20 22 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 65   " (db-get-value
4cd0: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
4ce0: 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29  eader "runname")
4cf0: 29 0a 09 09 20 28 66 6f 72 2d 65 61 63 68 0a 09  )... (for-each..
4d00: 09 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74  .  (lambda (test
4d10: 29 0a 09 09 20 20 20 20 28 70 72 69 6e 74 20 22  )...    (print "
4d20: 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74    " (db:test-get
4d30: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 20  -testname test) 
4d40: 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73 74  " id: " (db:test
4d50: 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22 20  -get-id test) " 
4d60: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
4d70: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a  tem-path test)).
4d80: 09 09 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65  ..    (db:delete
4d90: 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62  -test-records db
4da0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
4db0: 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 28 69   test))...    (i
4dc0: 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e  f (> (string-len
4dd0: 67 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74  gth (db:test-get
4de0: 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29 20 35  -rundir test)) 5
4df0: 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74  ) ;; bad heurist
4e00: 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72  ic but should pr
4e10: 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65  event /tmp /home
4e20: 20 65 74 63 2e 0a 09 09 09 28 6c 65 74 20 28 28   etc.....(let ((
4e30: 66 75 6c 6c 70 61 74 68 20 28 64 62 3a 74 65 73  fullpath (db:tes
4e40: 74 2d 67 65 74 2d 72 75 6e 64 69 72 20 74 65 73  t-get-rundir tes
4e50: 74 29 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a  t))) ;; "/" (db:
4e60: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
4e70: 74 68 20 74 65 73 74 29 29 29 29 0a 09 09 09 20  th test)))).... 
4e80: 20 28 73 65 74 21 20 6c 61 73 74 74 70 61 74 68   (set! lasttpath
4e90: 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20   fullpath)....  
4ea0: 28 70 72 69 6e 74 20 22 72 6d 20 2d 72 66 20 22  (print "rm -rf "
4eb0: 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20   fullpath)....  
4ec0: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72  (system (conc "r
4ed0: 6d 20 2d 72 66 20 22 20 66 75 6c 6c 70 61 74 68  m -rf " fullpath
4ee0: 29 29 0a 09 09 09 20 20 28 6c 65 74 20 28 28 63  ))....  (let ((c
4ef0: 6d 64 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 20  md (conc "rmdir 
4f00: 2d 70 20 22 20 28 67 65 74 2d 64 69 72 2d 75 70  -p " (get-dir-up
4f10: 2d 6f 6e 65 20 66 75 6c 6c 70 61 74 68 29 29 29  -one fullpath)))
4f20: 29 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20  )....    (print 
4f30: 63 6d 64 29 0a 09 09 09 20 20 20 20 28 73 79 73  cmd)....    (sys
4f40: 74 65 6d 20 63 6d 64 29 29 0a 09 09 09 20 20 29  tem cmd))....  )
4f50: 29 29 0a 09 09 20 20 74 65 73 74 73 29 29 29 0a  ))...  tests))).
4f60: 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65  .   (let ((remte
4f70: 73 74 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74  sts (db-get-test
4f80: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62  s-for-run db (db
4f90: 2d 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  -get-value-by-he
4fa0: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
4fb0: 22 69 64 22 29 29 29 29 0a 09 20 20 20 20 20 28  "id"))))..     (
4fc0: 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73  if (null? remtes
4fd0: 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74  ts) ;; no more t
4fe0: 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09  ests remaining..
4ff0: 09 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73  . (let* ((dparts
5000: 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20    (string-split 
5010: 6c 61 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a  lasttpath "/")).
5020: 09 09 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e  ...(runpath (con
5030: 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e  c "/" (string-in
5040: 74 65 72 73 70 65 72 73 65 20 0a 09 09 09 09 09  tersperse ......
5050: 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73      (take dparts
5060: 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72   (- (length dpar
5070: 74 73 29 20 31 29 29 0a 09 09 09 09 09 20 20 20  ts) 1))......   
5080: 20 22 2f 22 29 29 29 29 0a 09 09 20 20 20 28 70   "/"))))...   (p
5090: 72 69 6e 74 20 22 52 65 6d 6f 76 69 6e 67 20 72  rint "Removing r
50a0: 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22  un: " runkey " "
50b0: 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62   (db-get-value-b
50c0: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
50d0: 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a  der "runname")).
50e0: 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  ..   (db:delete-
50f0: 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09  run db run-id)..
5100: 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66  .   ;; need to f
5110: 69 67 75 72 65 20 6f 75 74 20 74 68 65 20 70 61  igure out the pa
5120: 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69  th to the run di
5130: 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20  r and remove it 
5140: 69 66 20 65 6d 70 74 79 0a 09 09 3b 3b 20 20 20  if empty...;;   
5150: 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67 6c 6f   (if (null? (glo
5160: 62 20 28 63 6f 6e 63 20 72 75 6e 70 61 74 68 20  b (conc runpath 
5170: 22 2f 2a 22 29 29 29 0a 09 09 3b 3b 20 20 20 20  "/*")))...;;    
5180: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 3b 3b 20      (begin...;; 
5190: 09 20 28 70 72 69 6e 74 20 22 52 65 6d 6f 76 69  . (print "Removi
51a0: 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72 75 6e  ng run dir " run
51b0: 70 61 74 68 29 0a 09 09 3b 3b 20 09 20 28 73 79  path)...;; . (sy
51c0: 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 64 69  stem (conc "rmdi
51d0: 72 20 2d 70 20 22 20 72 75 6e 70 61 74 68 29 29  r -p " runpath))
51e0: 29 29 0a 09 09 20 20 20 29 29 29 0a 09 09 20 29  ))...   )))... )
51f0: 29 29 0a 20 20 20 20 20 72 75 6e 73 29 29 29 0a  )).     runs))).
5200: 0a                                               .