Megatest

Hex Artifact Content
Login

Artifact 1c23033086d316e5b1b09f5e564dd262e7112eb5:


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 28 64 65 62 75 67 3a 70 72  )).    (debug:pr
0450: 69 6e 74 20 33 20 22 6b 65 79 73 3a 20 22 20 6b  int 3 "keys: " k
0460: 65 79 73 20 22 20 61 6c 6c 76 61 6c 73 3a 20 22  eys " allvals: "
0470: 20 61 6c 6c 76 61 6c 73 20 22 20 6b 65 79 76 61   allvals " keyva
0480: 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73  llst: " keyvalls
0490: 74 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  t).    (debug:pr
04a0: 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 75 73 69  int 2 "NOTE: usi
04b0: 6e 67 20 6b 65 79 20 22 20 28 73 74 72 69 6e 67  ng key " (string
04c0: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 6b 65 79  -intersperse key
04d0: 76 61 6c 6c 73 74 20 22 2f 22 29 20 22 20 66 6f  vallst "/") " fo
04e0: 72 20 74 68 69 73 20 72 75 6e 22 29 0a 20 20 20  r this run").   
04f0: 20 28 69 66 20 28 61 6e 64 20 72 75 6e 6e 61 6d   (if (and runnam
0500: 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c 74 65 72  e (null? (filter
0510: 20 28 6c 61 6d 62 64 61 20 28 78 29 28 6e 6f 74   (lambda (x)(not
0520: 20 78 29 29 20 6b 65 79 76 61 6c 6c 73 74 29 29   x)) keyvallst))
0530: 29 20 3b 3b 20 74 68 65 72 65 20 6d 75 73 74 20  ) ;; there must 
0540: 62 65 20 61 20 62 65 74 74 65 72 20 77 61 79 20  be a better way 
0550: 74 6f 20 22 61 70 70 6c 79 20 61 6e 64 22 0a 09  to "apply and"..
0560: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 0a  (let ((res #f)).
0570: 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65  .  (apply sqlite
0580: 33 3a 65 78 65 63 75 74 65 20 64 62 20 28 63 6f  3:execute db (co
0590: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 49 47  nc "INSERT OR IG
05a0: 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e 73 20 28  NORE INTO runs (
05b0: 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  runname,state,st
05c0: 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76 65 6e 74  atus,owner,event
05d0: 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20 6b 65 79  _time" comma key
05e0: 73 74 72 20 22 29 20 56 41 4c 55 45 53 20 28 3f  str ") VALUES (?
05f0: 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28  ,?,?,?,strftime(
0600: 27 25 73 27 2c 27 6e 6f 77 27 29 22 20 63 6f 6d  '%s','now')" com
0610: 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22 29 3b 22  ma valslots ");"
0620: 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29 0a 09 20  )... allvals).. 
0630: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a   (apply sqlite3:
0640: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09 20  for-each-row .. 
0650: 20 20 28 6c 61 6d 62 64 61 20 28 69 64 29 0a 09    (lambda (id)..
0660: 20 20 20 20 20 28 73 65 74 21 20 72 65 73 20 69       (set! res i
0670: 64 29 29 0a 09 20 20 20 64 62 0a 09 20 20 20 28  d))..   db..   (
0680: 6c 65 74 20 28 28 71 72 79 20 28 63 6f 6e 63 20  let ((qry (conc 
0690: 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f 4d 20  "SELECT id FROM 
06a0: 72 75 6e 73 20 57 48 45 52 45 20 28 72 75 6e 6e  runs WHERE (runn
06b0: 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74 72 20 6b  ame=? " andstr k
06c0: 65 79 3d 3f 73 74 72 20 22 29 3b 22 29 29 29 0a  ey=?str ");"))).
06d0: 09 20 20 20 20 20 3b 28 64 65 62 75 67 3a 70 72  .     ;(debug:pr
06e0: 69 6e 74 20 34 20 22 71 72 79 3a 20 22 20 71 72  int 4 "qry: " qr
06f0: 79 29 20 0a 09 20 20 20 20 20 71 72 79 29 0a 09  y) ..     qry)..
0700: 20 20 20 71 72 79 76 61 6c 73 29 0a 09 20 20 28     qryvals)..  (
0710: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
0720: 64 62 20 22 55 50 44 41 54 45 20 72 75 6e 73 20  db "UPDATE runs 
0730: 53 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 61 74  SET state=?,stat
0740: 75 73 3d 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b  us=? WHERE id=?;
0750: 22 20 73 74 61 74 65 20 73 74 61 74 75 73 20 72  " state status r
0760: 65 73 29 0a 09 20 20 72 65 73 29 20 0a 09 28 62  es)..  res) ..(b
0770: 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70  egin..  (debug:p
0780: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43  rint 0 "ERROR: C
0790: 61 6c 6c 65 64 20 77 69 74 68 6f 75 74 20 61 6c  alled without al
07a0: 6c 20 6e 65 63 65 73 73 61 72 79 20 6b 65 79 73  l necessary keys
07b0: 22 29 0a 09 20 20 23 66 29 29 29 29 0a 0a 3b 3b  ")..  #f))))..;;
07c0: 20 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62   runs:get-runs-b
07d0: 79 2d 70 61 74 74 0a 3b 3b 20 67 65 74 20 72 75  y-patt.;; get ru
07e0: 6e 73 20 62 79 20 6c 69 73 74 20 6f 66 20 63 72  ns by list of cr
07f0: 69 74 65 72 69 61 0a 3b 3b 20 72 65 67 69 73 74  iteria.;; regist
0800: 65 72 20 61 20 74 65 73 74 20 72 75 6e 20 77 69  er a test run wi
0810: 74 68 20 74 68 65 20 64 62 0a 3b 3b 0a 3b 3b 20  th the db.;;.;; 
0820: 55 73 65 3a 20 28 64 62 2d 67 65 74 2d 76 61 6c  Use: (db-get-val
0830: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 28 64 62  ue-by-header (db
0840: 3a 67 65 74 2d 68 65 61 64 65 72 20 72 75 6e 69  :get-header runi
0850: 6e 66 6f 29 28 64 62 3a 67 65 74 2d 72 6f 77 20  nfo)(db:get-row 
0860: 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b 20 20 74 6f  runinfo)).;;  to
0870: 20 65 78 74 72 61 63 74 20 69 6e 66 6f 20 66 72   extract info fr
0880: 6f 6d 20 74 68 65 20 73 74 72 75 63 74 75 72 65  om the structure
0890: 20 72 65 74 75 72 6e 65 64 0a 3b 3b 0a 28 64 65   returned.;;.(de
08a0: 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74 2d 72  fine (runs:get-r
08b0: 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20 6b  uns-by-patt db k
08c0: 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74 20  eys runnamepatt 
08d0: 2e 20 70 61 72 61 6d 73 29 20 3b 3b 20 74 65 73  . params) ;; tes
08e0: 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20  t-name).  (let* 
08f0: 28 28 6b 65 79 76 61 6c 6c 73 74 20 28 6b 65 79  ((keyvallst (key
0900: 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 29  s->vallist keys)
0910: 29 0a 09 20 28 74 6d 70 20 20 20 20 20 20 28 72  ).. (tmp      (r
0920: 75 6e 73 3a 67 65 74 2d 73 74 64 2d 72 75 6e 2d  uns:get-std-run-
0930: 66 69 65 6c 64 73 20 6b 65 79 73 20 27 28 22 69  fields keys '("i
0940: 64 22 20 22 72 75 6e 6e 61 6d 65 22 20 22 73 74  d" "runname" "st
0950: 61 74 65 22 20 22 73 74 61 74 75 73 22 20 22 6f  ate" "status" "o
0960: 77 6e 65 72 22 20 22 65 76 65 6e 74 5f 74 69 6d  wner" "event_tim
0970: 65 22 29 29 29 0a 09 20 28 6b 65 79 73 74 72 20  e"))).. (keystr 
0980: 20 20 28 63 61 72 20 74 6d 70 29 29 0a 09 20 28    (car tmp)).. (
0990: 68 65 61 64 65 72 20 20 20 28 63 61 64 72 20 74  header   (cadr t
09a0: 6d 70 29 29 0a 09 20 28 72 65 73 20 20 20 20 20  mp)).. (res     
09b0: 27 28 29 29 0a 09 20 28 6b 65 79 2d 70 61 74 74  '()).. (key-patt
09c0: 20 22 22 29 29 0a 20 20 20 20 28 66 6f 72 2d 65   "")).    (for-e
09d0: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b 65 79  ach (lambda (key
09e0: 76 61 6c 29 0a 09 09 28 6c 65 74 2a 20 28 28 6b  val)...(let* ((k
09f0: 65 79 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65  ey    (vector-re
0a00: 66 20 6b 65 79 76 61 6c 20 30 29 29 0a 09 09 20  f keyval 0))... 
0a10: 20 20 20 20 20 20 28 66 75 6c 6b 65 79 20 28 63        (fulkey (c
0a20: 6f 6e 63 20 22 3a 22 20 6b 65 79 29 29 0a 09 09  onc ":" key))...
0a30: 20 20 20 20 20 20 20 28 70 61 74 74 20 20 20 28         (patt   (
0a40: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 66 75 6c  args:get-arg ful
0a50: 6b 65 79 29 29 29 0a 09 09 20 20 28 69 66 20 70  key)))...  (if p
0a60: 61 74 74 0a 09 09 20 20 20 20 20 20 28 73 65 74  att...      (set
0a70: 21 20 6b 65 79 2d 70 61 74 74 20 28 63 6f 6e 63  ! key-patt (conc
0a80: 20 6b 65 79 2d 70 61 74 74 20 22 20 41 4e 44 20   key-patt " AND 
0a90: 22 20 6b 65 79 20 22 20 6c 69 6b 65 20 27 22 20  " key " like '" 
0aa0: 70 61 74 74 20 22 27 22 29 29 0a 09 09 20 20 20  patt "'"))...   
0ab0: 20 20 20 28 62 65 67 69 6e 0a 09 09 09 28 64 65     (begin....(de
0ac0: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
0ad0: 4f 52 3a 20 73 65 61 72 63 68 69 6e 67 20 66 6f  OR: searching fo
0ae0: 72 20 72 75 6e 73 20 77 69 74 68 20 6e 6f 20 70  r runs with no p
0af0: 61 74 74 65 72 6e 20 73 65 74 20 66 6f 72 20 22  attern set for "
0b00: 20 66 75 6c 6b 65 79 29 0a 09 09 09 28 65 78 69   fulkey)....(exi
0b10: 74 20 36 29 29 29 29 29 0a 09 20 20 20 20 20 20  t 6)))))..      
0b20: 6b 65 79 73 29 0a 20 20 20 20 28 73 71 6c 69 74  keys).    (sqlit
0b30: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20  e3:for-each-row 
0b40: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 61  .     (lambda (a
0b50: 20 2e 20 72 29 0a 20 20 20 20 20 20 20 28 73 65   . r).       (se
0b60: 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28 6c 69  t! res (cons (li
0b70: 73 74 2d 3e 76 65 63 74 6f 72 20 28 63 6f 6e 73  st->vector (cons
0b80: 20 61 20 72 29 29 20 72 65 73 29 29 29 0a 20 20   a r)) res))).  
0b90: 20 20 20 64 62 20 0a 20 20 20 20 20 28 63 6f 6e     db .     (con
0ba0: 63 20 22 53 45 4c 45 43 54 20 22 20 6b 65 79 73  c "SELECT " keys
0bb0: 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57  tr " FROM runs W
0bc0: 48 45 52 45 20 72 75 6e 6e 61 6d 65 20 6c 69 6b  HERE runname lik
0bd0: 65 20 3f 20 22 20 6b 65 79 2d 70 61 74 74 20 22  e ? " key-patt "
0be0: 3b 22 29 0a 20 20 20 20 20 72 75 6e 6e 61 6d 65  ;").     runname
0bf0: 70 61 74 74 29 0a 20 20 20 20 28 76 65 63 74 6f  patt).    (vecto
0c00: 72 20 68 65 61 64 65 72 20 72 65 73 29 29 29 0a  r header res))).
0c10: 0a 28 64 65 66 69 6e 65 20 28 72 65 67 69 73 74  .(define (regist
0c20: 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  er-test db run-i
0c30: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
0c40: 2d 70 61 74 68 29 0a 20 20 28 6c 65 74 20 28 28  -path).  (let ((
0c50: 69 74 65 6d 2d 70 61 74 68 73 20 28 69 66 20 28  item-paths (if (
0c60: 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68  equal? item-path
0c70: 20 22 22 29 0a 09 09 09 28 6c 69 73 74 20 69 74   "")....(list it
0c80: 65 6d 2d 70 61 74 68 29 0a 09 09 09 28 6c 69 73  em-path)....(lis
0c90: 74 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29  t item-path ""))
0ca0: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )).    (for-each
0cb0: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
0cc0: 70 74 68 29 0a 20 20 20 20 20 20 20 28 73 71 6c  pth).       (sql
0cd0: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
0ce0: 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52  "INSERT OR IGNOR
0cf0: 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72 75  E INTO tests (ru
0d00: 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 65 76  n_id,testname,ev
0d10: 65 6e 74 5f 74 69 6d 65 2c 69 74 65 6d 5f 70 61  ent_time,item_pa
0d20: 74 68 2c 73 74 61 74 65 2c 73 74 61 74 75 73 29  th,state,status)
0d30: 20 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 73 74 72   VALUES (?,?,str
0d40: 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27  ftime('%s','now'
0d50: 29 2c 3f 2c 27 4e 4f 54 5f 53 54 41 52 54 45 44  ),?,'NOT_STARTED
0d60: 27 2c 27 6e 2f 61 27 29 3b 22 20 72 75 6e 2d 69  ','n/a');" run-i
0d70: 64 20 74 65 73 74 2d 6e 61 6d 65 20 70 74 68 29  d test-name pth)
0d80: 29 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74 68  ).     item-path
0d90: 73 29 29 29 0a 0a 3b 3b 20 20 28 64 65 66 69 6e  s)))..;;  (defin
0da0: 65 20 64 62 20 28 6f 70 65 6e 2d 64 62 29 29 0a  e db (open-db)).
0db0: 3b 3b 20 20 28 74 65 73 74 2d 73 65 74 2d 73 74  ;;  (test-set-st
0dc0: 61 74 75 73 21 20 64 62 20 32 20 22 72 75 6e 66  atus! db 2 "runf
0dd0: 69 72 73 74 22 20 22 43 4f 4d 50 4c 45 54 45 44  irst" "COMPLETED
0de0: 22 20 22 50 41 53 53 22 20 22 73 75 6d 6d 65 72  " "PASS" "summer
0df0: 22 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ")..(define (tes
0e00: 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62  t-set-status! db
0e10: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
0e20: 65 20 73 74 61 74 65 20 73 74 61 74 75 73 20 69  e state status i
0e30: 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 20 2e  temdat-or-path .
0e40: 20 63 6f 6d 6d 65 6e 74 29 0a 20 20 28 6c 65 74   comment).  (let
0e50: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 66   ((item-path (if
0e60: 20 28 73 74 72 69 6e 67 3f 20 69 74 65 6d 64 61   (string? itemda
0e70: 74 2d 6f 72 2d 70 61 74 68 29 20 69 74 65 6d 64  t-or-path) itemd
0e80: 61 74 2d 6f 72 2d 70 61 74 68 20 28 69 74 65 6d  at-or-path (item
0e90: 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d  -list->path item
0ea0: 64 61 74 2d 6f 72 2d 70 61 74 68 29 29 29 29 0a  dat-or-path)))).
0eb0: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
0ec0: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
0ed0: 74 65 73 74 73 20 53 45 54 20 73 74 61 74 65 3d  tests SET state=
0ee0: 3f 2c 73 74 61 74 75 73 3d 3f 2c 65 76 65 6e 74  ?,status=?,event
0ef0: 5f 74 69 6d 65 3d 73 74 72 66 74 69 6d 65 28 27  _time=strftime('
0f00: 25 73 27 2c 27 6e 6f 77 27 29 20 57 48 45 52 45  %s','now') WHERE
0f10: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
0f20: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
0f30: 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 20 20  m_path=?;" ...  
0f40: 20 20 20 73 74 61 74 65 20 73 74 61 74 75 73 20     state status 
0f50: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
0f60: 20 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 20 20   item-path).    
0f70: 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65  (if (and (not (e
0f80: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
0f90: 22 22 29 29 20 3b 3b 20 6e 65 65 64 20 74 6f 20  "")) ;; need to 
0fa0: 75 70 64 61 74 65 20 74 68 65 20 74 6f 70 20 74  update the top t
0fb0: 65 73 74 20 72 65 63 6f 72 64 20 69 66 20 50 41  est record if PA
0fc0: 53 53 20 6f 72 20 46 41 49 4c 20 61 6e 64 20 74  SS or FAIL and t
0fd0: 68 69 73 20 69 73 20 61 20 73 75 62 74 65 73 74  his is a subtest
0fe0: 0a 09 20 20 20 20 20 28 6f 72 20 28 65 71 75 61  ..     (or (equa
0ff0: 6c 3f 20 73 74 61 74 75 73 20 22 50 41 53 53 22  l? status "PASS"
1000: 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 73 74 61  )... (equal? sta
1010: 74 75 73 20 22 57 41 52 4e 22 29 0a 09 09 20 28  tus "WARN")... (
1020: 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 46  equal? status "F
1030: 41 49 4c 22 29 29 29 0a 09 28 62 65 67 69 6e 0a  AIL")))..(begin.
1040: 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63  .  (sqlite3:exec
1050: 75 74 65 20 0a 09 20 20 20 64 62 0a 09 20 20 20  ute ..   db..   
1060: 22 55 50 44 41 54 45 20 74 65 73 74 73 20 0a 20  "UPDATE tests . 
1070: 20 20 20 20 20 20 20 20 20 20 20 20 53 45 54 20              SET 
1080: 66 61 69 6c 5f 63 6f 75 6e 74 3d 28 53 45 4c 45  fail_count=(SELE
1090: 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f  CT count(id) FRO
10a0: 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75  M tests WHERE ru
10b0: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
10c0: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
10d0: 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20 73 74  ath != '' AND st
10e0: 61 74 75 73 3d 27 46 41 49 4c 27 29 2c 0a 20 20  atus='FAIL'),.  
10f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70                 p
1100: 61 73 73 5f 63 6f 75 6e 74 3d 28 53 45 4c 45 43  ass_count=(SELEC
1110: 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d  T count(id) FROM
1120: 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e   tests WHERE run
1130: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
1140: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
1150: 74 68 20 21 3d 20 27 27 20 41 4e 44 20 28 73 74  th != '' AND (st
1160: 61 74 75 73 3d 27 50 41 53 53 27 20 4f 52 20 73  atus='PASS' OR s
1170: 74 61 74 75 73 3d 27 57 41 52 4e 27 29 29 0a 20  tatus='WARN')). 
1180: 20 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52              WHER
1190: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
11a0: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
11b0: 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20  em_path='';"..  
11c0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
11d0: 65 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  e run-id test-na
11e0: 6d 65 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  me run-id test-n
11f0: 61 6d 65 29 0a 09 20 20 28 73 71 6c 69 74 65 33  ame)..  (sqlite3
1200: 3a 65 78 65 63 75 74 65 0a 09 20 20 20 64 62 0a  :execute..   db.
1210: 09 20 20 20 22 55 50 44 41 54 45 20 74 65 73 74  .   "UPDATE test
1220: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53  s.             S
1230: 45 54 20 73 74 61 74 65 3d 27 43 4f 4d 50 4c 45  ET state='COMPLE
1240: 54 45 44 27 2c 0a 20 20 20 20 20 20 20 20 20 20  TED',.          
1250: 20 20 20 20 20 20 73 74 61 74 75 73 3d 43 41 53        status=CAS
1260: 45 20 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75 6e  E WHEN fail_coun
1270: 74 20 3e 20 30 20 54 48 45 4e 20 27 46 41 49 4c  t > 0 THEN 'FAIL
1280: 27 20 57 48 45 4e 20 70 61 73 73 5f 63 6f 75 6e  ' WHEN pass_coun
1290: 74 20 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f 63  t > 0 AND fail_c
12a0: 6f 75 6e 74 3d 30 20 54 48 45 4e 20 27 50 41 53  ount=0 THEN 'PAS
12b0: 53 27 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e  S' ELSE 'UNKNOWN
12c0: 27 20 45 4e 44 0a 20 20 20 20 20 20 20 20 20 20  ' END.          
12d0: 20 20 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d     WHERE run_id=
12e0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
12f0: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27   AND item_path='
1300: 27 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64 20 74  ';"..   run-id t
1310: 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20  est-name))).    
1320: 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e  (if (and (not (n
1330: 75 6c 6c 3f 20 63 6f 6d 6d 65 6e 74 29 29 0a 09  ull? comment))..
1340: 20 20 20 20 20 28 63 61 72 20 63 6f 6d 6d 65 6e       (car commen
1350: 74 29 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78  t))..(sqlite3:ex
1360: 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45  ecute db "UPDATE
1370: 20 74 65 73 74 73 20 53 45 54 20 63 6f 6d 6d 65   tests SET comme
1380: 6e 74 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69  nt=? WHERE run_i
1390: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
13a0: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
13b0: 3d 3f 3b 22 0a 09 09 09 20 28 63 61 72 20 63 6f  =?;".... (car co
13c0: 6d 6d 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65  mment) run-id te
13d0: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
13e0: 68 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  h))))..(define (
13f0: 74 65 73 74 2d 73 65 74 2d 6c 6f 67 21 20 64 62  test-set-log! db
1400: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1410: 65 20 69 74 65 6d 64 61 74 20 6c 6f 67 66 29 20  e itemdat logf) 
1420: 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70  .  (let ((item-p
1430: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
1440: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a  path itemdat))).
1450: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
1460: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
1470: 74 65 73 74 73 20 53 45 54 20 66 69 6e 61 6c 5f  tests SET final_
1480: 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20 72 75 6e  logf=? WHERE run
1490: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
14a0: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
14b0: 74 68 3d 3f 3b 22 20 0a 09 09 20 20 20 20 20 6c  th=?;" ...     l
14c0: 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 73 74 2d  ogf run-id test-
14d0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
14e0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
14f0: 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20  -set-toplog! db 
1500: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
1510: 20 6c 6f 67 66 29 20 0a 20 20 28 73 71 6c 69 74   logf) .  (sqlit
1520: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
1530: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
1540: 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45  final_logf=? WHE
1550: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
1560: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
1570: 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 20 0a 09  tem_path='';" ..
1580: 09 20 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20  .   logf run-id 
1590: 74 65 73 74 2d 6e 61 6d 65 29 29 0a 0a 3b 3b 20  test-name))..;; 
15a0: 3b 3b 20 54 4f 44 4f 3a 20 43 6f 6e 76 65 72 67  ;; TODO: Converg
15b0: 65 20 74 68 69 73 20 77 69 74 68 20 64 62 3a 67  e this with db:g
15c0: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 0a 3b 3b 20  et-test-info.;; 
15d0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65  (define (runs:ge
15e0: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72  t-test-info db r
15f0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
1600: 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20  item-path).;;   
1610: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 20  (let ((res #f)) 
1620: 3b 3b 20 28 76 65 63 74 6f 72 20 23 66 20 23 66  ;; (vector #f #f
1630: 20 23 66 20 23 66 20 23 66 20 23 66 29 29 29 0a   #f #f #f #f))).
1640: 3b 3b 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a  ;;     (sqlite3:
1650: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 3b 3b  for-each-row .;;
1660: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 69        (lambda (i
1670: 64 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  d run-id test-na
1680: 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73 29  me state status)
1690: 0a 3b 3b 20 20 20 20 20 20 20 20 28 73 65 74 21  .;;        (set!
16a0: 20 72 65 73 20 28 76 65 63 74 6f 72 20 69 64 20   res (vector id 
16b0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
16c0: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 69 74   state status it
16d0: 65 6d 2d 70 61 74 68 29 29 29 0a 3b 3b 20 20 20  em-path))).;;   
16e0: 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 69 64     db "SELECT id
16f0: 2c 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65  ,run_id,testname
1700: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 20 46 52  ,state,status FR
1710: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
1720: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
1730: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
1740: 70 61 74 68 3d 3f 3b 22 0a 3b 3b 20 20 20 20 20  path=?;".;;     
1750: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1760: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20  e item-path).;; 
1770: 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69      res))..(defi
1780: 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a  ne-inline (test:
1790: 67 65 74 2d 69 64 20 76 65 63 29 20 20 20 20 20  get-id vec)     
17a0: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65    (vector-ref ve
17b0: 63 20 30 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e  c 0)).(define-in
17c0: 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 72  line (test:get-r
17d0: 75 6e 5f 69 64 20 76 65 63 29 20 20 20 28 76 65  un_id vec)   (ve
17e0: 63 74 6f 72 2d 72 65 66 20 76 65 63 20 31 29 29  ctor-ref vec 1))
17f0: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20  .(define-inline 
1800: 28 74 65 73 74 3a 67 65 74 2d 74 65 73 74 2d 6e  (test:get-test-n
1810: 61 6d 65 20 76 65 63 29 28 76 65 63 74 6f 72 2d  ame vec)(vector-
1820: 72 65 66 20 76 65 63 20 32 29 29 0a 28 64 65 66  ref vec 2)).(def
1830: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74  ine-inline (test
1840: 3a 67 65 74 2d 73 74 61 74 65 20 76 65 63 29 20  :get-state vec) 
1850: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76     (vector-ref v
1860: 65 63 20 33 29 29 0a 28 64 65 66 69 6e 65 2d 69  ec 3)).(define-i
1870: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d  nline (test:get-
1880: 73 74 61 74 75 73 20 76 65 63 29 20 20 20 28 76  status vec)   (v
1890: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 34 29  ector-ref vec 4)
18a0: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ).(define-inline
18b0: 20 28 74 65 73 74 3a 67 65 74 2d 69 74 65 6d 2d   (test:get-item-
18c0: 70 61 74 68 20 76 65 63 29 28 76 65 63 74 6f 72  path vec)(vector
18d0: 2d 72 65 66 20 76 65 63 20 35 29 29 0a 0a 28 64  -ref vec 5))..(d
18e0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 74 65 73 74  efine (runs:test
18f0: 2d 67 65 74 2d 66 75 6c 6c 2d 70 61 74 68 20 74  -get-full-path t
1900: 65 73 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 74  est).  (let* ((t
1910: 65 73 74 6e 61 6d 65 20 28 64 62 3a 74 65 73 74  estname (db:test
1920: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20  -get-testname   
1930: 74 65 73 74 29 29 0a 09 20 28 69 74 65 6d 70 61  test)).. (itempa
1940: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
1950: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29  item-path test))
1960: 29 0a 20 20 20 20 28 63 6f 6e 63 20 74 65 73 74  ).    (conc test
1970: 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f  name (if (equal?
1980: 20 69 74 65 6d 70 61 74 68 20 22 22 29 20 22 22   itempath "") ""
1990: 20 28 63 6f 6e 63 20 22 28 22 20 69 74 65 6d 70   (conc "(" itemp
19a0: 61 74 68 20 22 29 22 29 29 29 29 29 0a 0a 28 64  ath ")")))))..(d
19b0: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65  efine-inline (te
19c0: 73 74 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c  st:test-get-full
19d0: 6e 61 6d 65 20 74 65 73 74 29 0a 20 20 20 28 63  name test).   (c
19e0: 6f 6e 63 20 28 64 62 3a 74 65 73 74 2d 67 65 74  onc (db:test-get
19f0: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 0a  -testname test).
1a00: 09 20 28 69 66 20 28 65 71 75 61 6c 3f 20 28 64  . (if (equal? (d
1a10: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
1a20: 70 61 74 68 20 74 65 73 74 29 20 22 22 29 0a 09  path test) "")..
1a30: 20 20 20 20 20 22 22 0a 09 20 20 20 20 20 28 63       ""..     (c
1a40: 6f 6e 63 20 22 28 22 20 28 64 62 3a 74 65 73 74  onc "(" (db:test
1a50: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
1a60: 65 73 74 29 20 22 29 22 29 29 29 29 0a 0a 28 64  est) ")"))))..(d
1a70: 65 66 69 6e 65 20 28 63 68 65 63 6b 2d 76 61 6c  efine (check-val
1a80: 69 64 2d 69 74 65 6d 73 20 63 6c 61 73 73 20 69  id-items class i
1a90: 74 65 6d 29 0a 20 20 28 6c 65 74 20 28 28 76 61  tem).  (let ((va
1aa0: 6c 69 64 2d 76 61 6c 75 65 73 20 28 6c 65 74 20  lid-values (let 
1ab0: 28 28 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  ((s (config-look
1ac0: 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22  up *configdat* "
1ad0: 76 61 6c 69 64 76 61 6c 75 65 73 22 20 63 6c 61  validvalues" cla
1ae0: 73 73 29 29 29 0a 09 09 09 28 69 66 20 73 20 28  ss)))....(if s (
1af0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 73 29 20  string-split s) 
1b00: 23 66 29 29 29 29 0a 20 20 20 20 28 69 66 20 76  #f)))).    (if v
1b10: 61 6c 69 64 2d 76 61 6c 75 65 73 0a 09 28 69 66  alid-values..(if
1b20: 20 28 6d 65 6d 62 65 72 20 69 74 65 6d 20 76 61   (member item va
1b30: 6c 69 64 2d 76 61 6c 75 65 73 29 0a 09 20 20 20  lid-values)..   
1b40: 20 69 74 65 6d 20 23 66 29 0a 09 69 74 65 6d 29   item #f)..item)
1b50: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
1b60: 74 73 74 65 70 2d 73 65 74 2d 73 74 61 74 75 73  tstep-set-status
1b70: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
1b80: 2d 6e 61 6d 65 20 74 65 73 74 73 74 65 70 2d 6e  -name teststep-n
1b90: 61 6d 65 20 73 74 61 74 65 2d 69 6e 20 73 74 61  ame state-in sta
1ba0: 74 75 73 2d 69 6e 20 69 74 65 6d 64 61 74 20 63  tus-in itemdat c
1bb0: 6f 6d 6d 65 6e 74 29 0a 20 20 28 64 65 62 75 67  omment).  (debug
1bc0: 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64  :print 4 "run-id
1bd0: 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73  : " run-id " tes
1be0: 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e  t-name: " test-n
1bf0: 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73  ame).  (let* ((s
1c00: 74 61 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d  tate     (check-
1c10: 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61  valid-items "sta
1c20: 74 65 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09  te" state-in))..
1c30: 20 28 73 74 61 74 75 73 20 20 20 20 28 63 68 65   (status    (che
1c40: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22  ck-valid-items "
1c50: 73 74 61 74 75 73 22 20 73 74 61 74 75 73 2d 69  status" status-i
1c60: 6e 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68  n)).. (item-path
1c70: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
1c80: 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74  h itemdat)).. (t
1c90: 65 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74  estdat   (db:get
1ca0: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
1cb0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
1cc0: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
1cd0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22  (debug:print 5 "
1ce0: 74 65 73 74 64 61 74 3a 20 22 20 74 65 73 74 64  testdat: " testd
1cf0: 61 74 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64  at).    (if (and
1d00: 20 74 65 73 74 64 61 74 20 3b 3b 20 69 66 20 74   testdat ;; if t
1d10: 68 65 20 73 65 63 74 69 6f 6e 20 65 78 69 73 74  he section exist
1d20: 73 20 74 68 65 6e 20 66 6f 72 63 65 20 73 70 65  s then force spe
1d30: 63 69 66 69 63 61 74 69 6f 6e 20 42 55 47 2c 20  cification BUG, 
1d40: 49 20 64 6f 6e 27 74 20 6c 69 6b 65 20 68 6f 77  I don't like how
1d50: 20 74 68 69 73 20 77 6f 72 6b 73 2e 0a 09 20 20   this works...  
1d60: 20 20 20 28 6f 72 20 28 6e 6f 74 20 73 74 61 74     (or (not stat
1d70: 65 29 28 6e 6f 74 20 73 74 61 74 75 73 29 29 29  e)(not status)))
1d80: 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
1d90: 20 22 57 41 52 4e 49 4e 47 3a 20 49 6e 76 61 6c   "WARNING: Inval
1da0: 69 64 20 22 20 28 69 66 20 73 74 61 74 75 73 20  id " (if status 
1db0: 22 73 74 61 74 75 73 22 20 22 73 74 61 74 65 22  "status" "state"
1dc0: 29 0a 09 20 20 20 20 20 20 20 22 20 76 61 6c 75  )..       " valu
1dd0: 65 20 5c 22 22 20 28 69 66 20 73 74 61 74 75 73  e \"" (if status
1de0: 20 73 74 61 74 75 73 2d 69 6e 20 73 74 61 74 65   status-in state
1df0: 2d 69 6e 29 20 22 5c 22 2c 20 75 70 64 61 74 65  -in) "\", update
1e00: 20 79 6f 75 72 20 76 61 6c 69 64 73 74 61 74 65   your validstate
1e10: 73 20 73 65 63 74 69 6f 6e 20 69 6e 20 6d 65 67  s section in meg
1e20: 61 74 65 73 74 2e 63 6f 6e 66 69 67 22 29 29 0a  atest.config")).
1e30: 20 20 20 20 28 69 66 20 74 65 73 74 64 61 74 0a      (if testdat.
1e40: 09 28 6c 65 74 20 28 28 74 65 73 74 2d 69 64 20  .(let ((test-id 
1e50: 28 74 65 73 74 3a 67 65 74 2d 69 64 20 74 65 73  (test:get-id tes
1e60: 74 64 61 74 29 29 29 0a 09 20 20 28 73 71 6c 69  tdat)))..  (sqli
1e70: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 0a  te3:execute db .
1e80: 09 09 09 22 49 4e 53 45 52 54 20 4f 52 20 52 45  ..."INSERT OR RE
1e90: 50 4c 41 43 45 20 69 6e 74 6f 20 74 65 73 74 5f  PLACE into test_
1ea0: 73 74 65 70 73 20 28 74 65 73 74 5f 69 64 2c 73  steps (test_id,s
1eb0: 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  tepname,state,st
1ec0: 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c  atus,event_time,
1ed0: 63 6f 6d 6d 65 6e 74 29 20 56 41 4c 55 45 53 28  comment) VALUES(
1ee0: 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65  ?,?,?,?,strftime
1ef0: 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 29 3b  ('%s','now'),?);
1f00: 22 0a 09 09 09 74 65 73 74 2d 69 64 20 74 65 73  "....test-id tes
1f10: 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65  tstep-name state
1f20: 20 73 74 61 74 75 73 20 28 69 66 20 63 6f 6d 6d   status (if comm
1f30: 65 6e 74 20 63 6f 6d 6d 65 6e 74 20 22 22 29 29  ent comment ""))
1f40: 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  )..(debug:print 
1f50: 30 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20  0 "ERROR: Can't 
1f60: 75 70 64 61 74 65 20 22 20 74 65 73 74 2d 6e 61  update " test-na
1f70: 6d 65 20 22 20 66 6f 72 20 72 75 6e 20 22 20 72  me " for run " r
1f80: 75 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 73 75  un-id " -> no su
1f90: 63 68 20 74 65 73 74 20 69 6e 20 64 62 22 29 29  ch test in db"))
1fa0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
1fb0: 74 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65  t-get-kill-reque
1fc0: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
1fd0: 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a  t-name itemdat).
1fe0: 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70    (let* ((item-p
1ff0: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
2000: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09  path itemdat))..
2010: 20 28 74 65 73 74 64 61 74 20 20 20 28 64 62 3a   (testdat   (db:
2020: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
2030: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2040: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20  e item-path))). 
2050: 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74     (equal? (test
2060: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
2070: 61 74 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 29  at) "KILLREQ")))
2080: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d  ..(define (test-
2090: 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62  set-meta-info db
20a0: 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65   run-id testname
20b0: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74   itemdat).  (let
20c0: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74   ((item-path (it
20d0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
20e0: 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f 61  emdat))..(cpuloa
20f0: 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64  d  (get-cpu-load
2100: 29 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20 28 67  ))..(hostname (g
2110: 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 0a 09  et-host-name))..
2120: 28 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64  (diskfree (get-d
2130: 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63  f (current-direc
2140: 74 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d 65 20  tory)))..(uname 
2150: 20 20 20 28 67 65 74 2d 75 6e 61 6d 65 20 22 2d     (get-uname "-
2160: 73 72 76 70 69 6f 22 29 29 0a 09 28 72 75 6e 70  srvpio"))..(runp
2170: 61 74 68 20 20 28 63 75 72 72 65 6e 74 2d 64 69  ath  (current-di
2180: 72 65 63 74 6f 72 79 29 29 29 0a 20 20 20 20 28  rectory))).    (
2190: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
21a0: 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73  db "UPDATE tests
21b0: 20 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70 75 6c   SET host=?,cpul
21c0: 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f  oad=?,diskfree=?
21d0: 2c 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d  ,uname=?,rundir=
21e0: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ? WHERE run_id=?
21f0: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2200: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b  AND item_path=?;
2210: 22 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65 0a 09  "...  hostname..
2220: 09 20 20 63 70 75 6c 6f 61 64 0a 09 09 20 20 64  .  cpuload...  d
2230: 69 73 6b 66 72 65 65 0a 09 09 20 20 75 6e 61 6d  iskfree...  unam
2240: 65 0a 09 09 20 20 72 75 6e 70 61 74 68 0a 09 09  e...  runpath...
2250: 20 20 72 75 6e 2d 69 64 0a 09 09 20 20 74 65 73    run-id...  tes
2260: 74 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d 2d 70  tname...  item-p
2270: 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  ath)))..(define 
2280: 28 74 65 73 74 2d 75 70 64 61 74 65 2d 6d 65 74  (test-update-met
2290: 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  a-info db run-id
22a0: 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61   testname itemda
22b0: 74 20 6d 69 6e 75 74 65 73 29 0a 20 20 28 6c 65  t minutes).  (le
22c0: 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69  t ((item-path (i
22d0: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
22e0: 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f  temdat))..(cpulo
22f0: 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61  ad  (get-cpu-loa
2300: 64 29 29 0a 09 28 64 69 73 6b 66 72 65 65 20 28  d))..(diskfree (
2310: 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e 74 2d  get-df (current-
2320: 64 69 72 65 63 74 6f 72 79 29 29 29 29 0a 20 20  directory)))).  
2330: 20 20 28 69 66 20 28 6e 6f 74 20 63 70 75 6c 6f    (if (not cpulo
2340: 61 64 29 20 20 28 62 65 67 69 6e 20 28 64 65 62  ad)  (begin (deb
2350: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
2360: 49 4e 47 3a 20 43 50 55 4c 4f 41 44 20 6e 6f 74  ING: CPULOAD not
2370: 20 66 6f 75 6e 64 2e 22 29 20 20 28 73 65 74 21   found.")  (set!
2380: 20 63 70 75 6c 6f 61 64 20 22 6e 2f 61 22 29 29   cpuload "n/a"))
2390: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 64  ).    (if (not d
23a0: 69 73 6b 66 72 65 65 29 20 28 62 65 67 69 6e 20  iskfree) (begin 
23b0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
23c0: 57 41 52 4e 49 4e 47 3a 20 44 49 53 4b 46 52 45  WARNING: DISKFRE
23d0: 45 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 20 28  E not found.") (
23e0: 73 65 74 21 20 64 69 73 6b 66 72 65 65 20 22 6e  set! diskfree "n
23f0: 2f 61 22 29 29 29 0a 20 20 20 20 28 69 66 20 28  /a"))).    (if (
2400: 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29 28 62  not item-path)(b
2410: 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72 69 6e  egin (debug:prin
2420: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 49 54  t 0 "WARNING: IT
2430: 45 4d 50 41 54 48 20 6e 6f 74 20 73 65 74 2e 22  EMPATH not set."
2440: 29 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70  )   (set! item-p
2450: 61 74 68 20 22 22 29 29 29 0a 20 20 20 20 3b 3b  ath ""))).    ;;
2460: 20 28 6c 65 74 20 28 28 74 65 73 74 69 6e 66 6f   (let ((testinfo
2470: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
2480: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
2490: 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  tname item-path)
24a0: 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69 66 20  )).    ;;   (if 
24b0: 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75 61 6c  (and (not (equal
24c0: 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73  ? (db:test-get-s
24d0: 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20  tatus testinfo) 
24e0: 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a 20 20  "COMPLETED")).  
24f0: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 20 20 20    ;;            
2500: 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62  (not (equal? (db
2510: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73  :test-get-status
2520: 20 74 65 73 74 69 6e 66 6f 29 20 22 4b 49 4c 4c   testinfo) "KILL
2530: 52 45 51 22 29 29 0a 20 20 20 20 28 73 71 6c 69  REQ")).    (sqli
2540: 74 65 33 3a 65 78 65 63 75 74 65 0a 20 20 20 20  te3:execute.    
2550: 20 64 62 0a 20 20 20 20 20 22 55 50 44 41 54 45   db.     "UPDATE
2560: 20 74 65 73 74 73 20 53 45 54 20 63 70 75 6c 6f   tests SET cpulo
2570: 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c  ad=?,diskfree=?,
2580: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f 2c 73  run_duration=?,s
2590: 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47 27 20 57  tate='RUNNING' W
25a0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
25b0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
25c0: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20 41 4e 44   item_path=? AND
25d0: 20 73 74 61 74 65 20 4e 4f 54 20 49 4e 20 28 27   state NOT IN ('
25e0: 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b 49 4c 4c  COMPLETED','KILL
25f0: 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27 29 3b 22  REQ','KILLED');"
2600: 0a 20 20 20 20 20 63 70 75 6c 6f 61 64 0a 20 20  .     cpuload.  
2610: 20 20 20 64 69 73 6b 66 72 65 65 0a 20 20 20 20     diskfree.    
2620: 20 6d 69 6e 75 74 65 73 0a 20 20 20 20 20 72 75   minutes.     ru
2630: 6e 2d 69 64 0a 20 20 20 20 20 74 65 73 74 6e 61  n-id.     testna
2640: 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74  me.     item-pat
2650: 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73  h)))..(define (s
2660: 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d  et-megatest-env-
2670: 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a  vars db run-id).
2680: 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20 28 64    (let ((keys (d
2690: 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29  b-get-keys db)))
26a0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28  .    (for-each (
26b0: 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28  lambda (key)...(
26c0: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
26d0: 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20  -row... (lambda 
26e0: 28 76 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75  (val)...   (debu
26f0: 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e  g:print 2 "seten
2700: 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65  v " (key:get-fie
2710: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20  ldname key) " " 
2720: 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e  val)...   (seten
2730: 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  v (key:get-field
2740: 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a  name key) val)).
2750: 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20  .. db ... (conc 
2760: 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67  "SELECT " (key:g
2770: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
2780: 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48  ) " FROM runs WH
2790: 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72  ERE id=?;")... r
27a0: 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b  un-id))..      k
27b0: 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  eys)))..(define 
27c0: 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61  (set-item-env-va
27d0: 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66  rs itemdat).  (f
27e0: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
27f0: 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64  (item)..      (d
2800: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65  ebug:print 2 "se
2810: 74 65 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d  tenv " (car item
2820: 29 20 22 20 22 20 28 63 61 64 72 20 69 74 65 6d  ) " " (cadr item
2830: 29 29 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e  ))..      (seten
2840: 76 20 28 63 61 72 20 69 74 65 6d 29 20 28 63 61  v (car item) (ca
2850: 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20  dr item)))..    
2860: 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69  itemdat))..(defi
2870: 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61  ne (get-all-lega
2880: 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c 65 74 2a  l-tests).  (let*
2890: 20 28 28 74 65 73 74 73 20 20 28 67 6c 6f 62 20   ((tests  (glob 
28a0: 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20  (conc *toppath* 
28b0: 22 2f 74 65 73 74 73 2f 2a 22 29 29 29 0a 09 20  "/tests/*"))).. 
28c0: 28 72 65 73 20 20 20 20 27 28 29 29 29 0a 20 20  (res    '())).  
28d0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34    (debug:print 4
28e0: 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20   "INFO: Looking 
28f0: 61 74 20 74 65 73 74 73 20 22 20 28 73 74 72 69  at tests " (stri
2900: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 74  ng-intersperse t
2910: 65 73 74 73 20 22 2c 22 29 29 0a 20 20 20 20 28  ests ",")).    (
2920: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
2930: 20 28 74 65 73 74 70 61 74 68 29 0a 09 09 28 69   (testpath)...(i
2940: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
2950: 28 63 6f 6e 63 20 74 65 73 74 70 61 74 68 20 22  (conc testpath "
2960: 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09  /testconfig"))..
2970: 09 20 20 20 20 28 73 65 74 21 20 72 65 73 20 28  .    (set! res (
2980: 63 6f 6e 73 20 28 6c 61 73 74 20 28 73 74 72 69  cons (last (stri
2990: 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70 61 74  ng-split testpat
29a0: 68 20 22 2f 22 29 29 20 72 65 73 29 29 29 29 0a  h "/")) res)))).
29b0: 09 20 20 20 20 20 20 74 65 73 74 73 29 0a 20 20  .      tests).  
29c0: 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65    res))..(define
29d0: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
29e0: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 20 20  ore-tests db).  
29f0: 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e 69  (let ((num-runni
2a00: 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74  ng (db:get-count
2a10: 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64  -tests-running d
2a20: 62 29 29 0a 09 28 6d 61 78 2d 63 6f 6e 63 75 72  b))..(max-concur
2a30: 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69  rent-jobs (confi
2a40: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
2a50: 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61  dat* "setup" "ma
2a60: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
2a70: 73 22 29 29 29 0a 20 20 20 20 28 64 65 62 75 67  s"))).    (debug
2a80: 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f  :print 2 "max-co
2a90: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22  ncurrent-jobs: "
2aa0: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
2ab0: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e  jobs ", num-runn
2ac0: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
2ad0: 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20  ng).    (if (or 
2ae0: 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75 72 72  (not max-concurr
2af0: 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20 20 28  ent-jobs)..    (
2b00: 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  and max-concurre
2b10: 6e 74 2d 6a 6f 62 73 0a 09 09 20 28 73 74 72 69  nt-jobs... (stri
2b20: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
2b30: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a  oncurrent-jobs).
2b40: 09 09 20 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d  .. (not (>= num-
2b50: 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d  running (string-
2b60: 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63  >number max-conc
2b70: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29  urrent-jobs)))))
2b80: 0a 09 23 74 0a 09 28 62 65 67 69 6e 20 0a 09 20  ..#t..(begin .. 
2b90: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
2ba0: 22 57 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75  "WARNING: Max ru
2bb0: 6e 6e 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65  nning jobs excee
2bc0: 64 65 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d  ded, current num
2bd0: 62 65 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e  ber running: " n
2be0: 75 6d 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 20  um-running .... 
2bf0: 22 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e  ", max_concurren
2c00: 74 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f  t_jobs: " max-co
2c10: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09  ncurrent-jobs)..
2c20: 20 20 23 66 29 29 29 29 0a 20 20 0a 28 64 65 66    #f)))).  .(def
2c30: 69 6e 65 20 28 72 75 6e 2d 74 65 73 74 73 20 64  ine (run-tests d
2c40: 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 20 20  b test-names).  
2c50: 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20  (let* ((keys    
2c60: 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73      (db-get-keys
2c70: 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c   db)).. (keyvall
2c80: 73 74 20 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c  st   (keys->vall
2c90: 69 73 74 20 6b 65 79 73 20 23 74 29 29 0a 09 20  ist keys #t)).. 
2ca0: 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72 65  (run-id      (re
2cb0: 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65  gister-run db ke
2cc0: 79 73 29 29 29 20 3b 3b 20 20 74 65 73 74 2d 6e  ys))) ;;  test-n
2cd0: 61 6d 65 29 29 29 0a 20 20 20 20 3b 3b 20 6f 6e  ame))).    ;; on
2ce0: 20 74 68 65 20 66 69 72 73 74 20 70 61 73 73 20   the first pass 
2cf0: 6f 72 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74  or call to run-t
2d00: 65 73 74 73 20 73 65 74 20 46 41 49 4c 53 20 74  ests set FAILS t
2d10: 6f 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66  o NOT_STARTED if
2d20: 0a 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69  .    ;; -keepgoi
2d30: 6e 67 20 69 73 20 73 70 65 63 69 66 69 65 64 0a  ng is specified.
2d40: 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 65 71      (if (and (eq
2d50: 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09  ? *passnum* 0)..
2d60: 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61       (args:get-a
2d70: 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29  rg "-keepgoing")
2d80: 29 0a 09 28 64 62 3a 73 65 74 2d 74 65 73 74 73  )..(db:set-tests
2d90: 2d 73 74 61 74 65 2d 73 74 61 74 75 73 20 64 62  -state-status db
2da0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2db0: 65 73 20 23 66 20 22 46 41 49 4c 22 20 22 4e 4f  es #f "FAIL" "NO
2dc0: 54 5f 53 54 41 52 54 45 44 22 20 22 46 41 49 4c  T_STARTED" "FAIL
2dd0: 22 29 29 0a 20 20 20 20 28 73 65 74 21 20 2a 70  ")).    (set! *p
2de0: 61 73 73 6e 75 6d 2a 20 28 2b 20 2a 70 61 73 73  assnum* (+ *pass
2df0: 6e 75 6d 2a 20 31 29 29 0a 20 20 20 20 28 6c 65  num* 1)).    (le
2e00: 74 20 6c 6f 6f 70 20 28 28 6e 75 6d 74 69 6d 65  t loop ((numtime
2e10: 73 20 30 29 29 0a 20 20 20 20 20 20 28 66 6f 72  s 0)).      (for
2e20: 2d 65 61 63 68 20 0a 20 20 20 20 20 20 20 28 6c  -each .       (l
2e30: 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65  ambda (test-name
2e40: 29 0a 09 20 28 69 66 20 28 72 75 6e 73 3a 63 61  ).. (if (runs:ca
2e50: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73  n-run-more-tests
2e60: 20 64 62 29 0a 09 20 20 20 20 20 28 72 75 6e 2d   db)..     (run-
2e70: 6f 6e 65 2d 74 65 73 74 20 64 62 20 72 75 6e 2d  one-test db run-
2e80: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6b 65 79  id test-name key
2e90: 76 61 6c 6c 73 74 29 0a 09 20 20 20 20 20 3b 3b  vallst)..     ;;
2ea0: 20 61 64 64 20 73 6f 6d 65 20 64 65 6c 61 79 20   add some delay 
2eb0: 0a 09 20 20 20 20 20 28 73 6c 65 65 70 20 32 29  ..     (sleep 2)
2ec0: 29 29 0a 20 20 20 20 20 20 20 74 65 73 74 2d 6e  )).       test-n
2ed0: 61 6d 65 73 29 0a 20 20 20 20 20 20 3b 3b 20 28  ames).      ;; (
2ee0: 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74  run-waiting-test
2ef0: 73 20 64 62 29 0a 20 20 20 20 20 20 28 69 66 20  s db).      (if 
2f00: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
2f10: 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09 20 20 28  keepgoing")..  (
2f20: 6c 65 74 20 28 28 65 73 74 72 65 6d 20 28 64 62  let ((estrem (db
2f30: 3a 65 73 74 69 6d 61 74 65 64 2d 74 65 73 74 73  :estimated-tests
2f40: 2d 72 65 6d 61 69 6e 69 6e 67 20 64 62 20 72 75  -remaining db ru
2f50: 6e 2d 69 64 29 29 29 0a 09 20 20 20 20 28 69 66  n-id)))..    (if
2f60: 20 28 3e 20 65 73 74 72 65 6d 20 30 29 0a 09 09   (> estrem 0)...
2f70: 28 62 65 67 69 6e 0a 09 09 20 20 28 64 65 62 75  (begin...  (debu
2f80: 67 3a 70 72 69 6e 74 20 31 20 22 4b 65 65 70 20  g:print 1 "Keep 
2f90: 67 6f 69 6e 67 2c 20 65 73 74 69 6d 61 74 65 64  going, estimated
2fa0: 20 22 20 65 73 74 72 65 6d 20 22 20 74 65 73 74   " estrem " test
2fb0: 73 20 72 65 6d 61 69 6e 69 6e 67 20 74 6f 20 72  s remaining to r
2fc0: 75 6e 2c 20 77 69 6c 6c 20 63 6f 6e 74 69 6e 75  un, will continu
2fd0: 65 20 69 6e 20 33 20 73 65 63 6f 6e 64 73 20 2e  e in 3 seconds .
2fe0: 2e 2e 22 29 0a 09 09 20 20 28 73 6c 65 65 70 20  ..")...  (sleep 
2ff0: 33 29 0a 09 09 20 20 28 72 75 6e 2d 77 61 69 74  3)...  (run-wait
3000: 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a 09 09  ing-tests db)...
3010: 20 20 28 6c 6f 6f 70 20 28 2b 20 6e 75 6d 74 69    (loop (+ numti
3020: 6d 65 73 20 31 29 29 29 29 29 29 29 29 29 0a 09  mes 1)))))))))..
3030: 20 20 20 0a 3b 3b 20 56 45 52 59 20 49 4e 45 46     .;; VERY INEF
3040: 46 49 43 49 45 4e 54 21 20 4d 6f 76 65 20 73 74  FICIENT! Move st
3050: 75 66 66 20 74 68 61 74 20 73 68 6f 75 6c 64 20  uff that should 
3060: 62 65 20 64 6f 6e 65 20 6f 6e 63 65 20 75 70 20  be done once up 
3070: 74 6f 20 63 61 6c 6c 69 6e 67 20 70 72 6f 63 0a  to calling proc.
3080: 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 6f 6e 65  (define (run-one
3090: 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20  -test db run-id 
30a0: 74 65 73 74 2d 6e 61 6d 65 20 6b 65 79 76 61 6c  test-name keyval
30b0: 6c 73 74 29 0a 20 20 28 64 65 62 75 67 3a 70 72  lst).  (debug:pr
30c0: 69 6e 74 20 31 20 22 4c 61 75 6e 63 68 69 6e 67  int 1 "Launching
30d0: 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d   test " test-nam
30e0: 65 29 0a 20 20 3b 3b 20 41 6c 6c 20 74 68 65 73  e).  ;; All thes
30f0: 65 20 76 61 72 73 20 6d 69 67 68 74 20 62 65 20  e vars might be 
3100: 72 65 66 65 72 65 6e 63 65 64 20 62 79 20 74 68  referenced by th
3110: 65 20 74 65 73 74 63 6f 6e 66 69 67 20 66 69 6c  e testconfig fil
3120: 65 20 72 65 61 64 65 72 0a 20 20 28 73 65 74 65  e reader.  (sete
3130: 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45  nv "MT_TEST_NAME
3140: 22 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20  " test-name) ;; 
3150: 0a 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52  .  (setenv "MT_R
3160: 55 4e 4e 41 4d 45 22 20 20 20 28 61 72 67 73 3a  UNNAME"   (args:
3170: 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d  get-arg ":runnam
3180: 65 22 29 29 0a 20 20 28 73 65 74 2d 6d 65 67 61  e")).  (set-mega
3190: 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62  test-env-vars db
31a0: 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73   run-id) ;; thes
31b0: 65 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20  e may be needed 
31c0: 62 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67  by the launching
31d0: 20 70 72 6f 63 65 73 73 0a 20 20 28 63 68 61 6e   process.  (chan
31e0: 67 65 2d 64 69 72 65 63 74 6f 72 79 20 2a 74 6f  ge-directory *to
31f0: 70 70 61 74 68 2a 29 0a 20 20 28 6c 65 74 2a 20  ppath*).  (let* 
3200: 28 28 74 65 73 74 2d 70 61 74 68 20 20 20 20 28  ((test-path    (
3210: 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22  conc *toppath* "
3220: 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61  /tests/" test-na
3230: 6d 65 29 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e  me)).. (test-con
3240: 66 69 67 66 20 28 63 6f 6e 63 20 74 65 73 74 2d  figf (conc test-
3250: 70 61 74 68 20 22 2f 74 65 73 74 63 6f 6e 66 69  path "/testconfi
3260: 67 22 29 29 0a 09 20 28 74 65 73 74 65 78 69 73  g")).. (testexis
3270: 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d  ts   (and (file-
3280: 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e  exists? test-con
3290: 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d  figf)(file-read-
32a0: 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e  access? test-con
32b0: 66 69 67 66 29 29 29 0a 09 20 28 74 65 73 74 2d  figf))).. (test-
32c0: 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65 73 74  conf    (if test
32d0: 65 78 69 73 74 73 20 28 72 65 61 64 2d 63 6f 6e  exists (read-con
32e0: 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69 67 66  fig test-configf
32f0: 29 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62  ) (make-hash-tab
3300: 6c 65 29 29 29 0a 09 20 28 77 61 69 74 6f 6e 20  le))).. (waiton 
3310: 20 20 20 20 20 20 28 6c 65 74 20 28 28 77 20 28        (let ((w (
3320: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65  config-lookup te
3330: 73 74 2d 63 6f 6e 66 20 22 72 65 71 75 69 72 65  st-conf "require
3340: 6d 65 6e 74 73 22 20 22 77 61 69 74 6f 6e 22 29  ments" "waiton")
3350: 29 29 0a 09 09 09 20 28 69 66 20 28 73 74 72 69  )).... (if (stri
3360: 6e 67 3f 20 77 29 28 73 74 72 69 6e 67 2d 73 70  ng? w)(string-sp
3370: 6c 69 74 20 77 29 27 28 29 29 29 29 29 0a 20 20  lit w)'())))).  
3380: 20 20 28 69 66 20 28 6e 6f 74 20 74 65 73 74 65    (if (not teste
3390: 78 69 73 74 73 29 0a 09 28 62 65 67 69 6e 0a 09  xists)..(begin..
33a0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
33b0: 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 66   "ERROR: Can't f
33c0: 69 6e 64 20 63 6f 6e 66 69 67 20 66 69 6c 65 20  ind config file 
33d0: 22 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 0a  " test-configf).
33e0: 09 20 20 28 65 78 69 74 20 32 29 29 0a 09 3b 3b  .  (exit 2))..;;
33f0: 20 70 75 74 20 74 6f 70 20 76 61 72 73 20 69 6e   put top vars in
3400: 74 6f 20 63 6f 6e 76 65 6e 69 65 6e 74 20 76 61  to convenient va
3410: 72 69 61 62 6c 65 73 20 61 6e 64 20 6f 70 65 6e  riables and open
3420: 20 74 68 65 20 64 62 0a 09 28 6c 65 74 2a 20 28   the db..(let* (
3430: 3b 3b 20 64 62 20 69 73 20 61 6c 77 61 79 73 20  ;; db is always 
3440: 61 74 20 2a 74 6f 70 70 61 74 68 2a 2f 64 62 2f  at *toppath*/db/
3450: 6d 65 67 61 74 65 73 74 2e 64 62 0a 09 20 20 20  megatest.db..   
3460: 20 20 20 20 28 69 74 65 6d 73 20 20 20 20 20 20      (items      
3470: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
3480: 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f  /default test-co
3490: 6e 66 20 22 69 74 65 6d 73 22 20 27 28 29 29 29  nf "items" '()))
34a0: 0a 09 20 20 20 20 20 20 20 28 69 74 65 6d 73 74  ..       (itemst
34b0: 61 62 6c 65 20 20 28 68 61 73 68 2d 74 61 62 6c  able  (hash-tabl
34c0: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74 65  e-ref/default te
34d0: 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d 73 74 61  st-conf "itemsta
34e0: 62 6c 65 22 20 27 28 29 29 29 0a 09 20 20 20 20  ble" '()))..    
34f0: 20 20 20 28 61 6c 6c 69 74 65 6d 73 20 20 20 20     (allitems    
3500: 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 28 6e 75  (if (or (not (nu
3510: 6c 6c 3f 20 69 74 65 6d 73 29 29 28 6e 6f 74 20  ll? items))(not 
3520: 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 74 61 62 6c  (null? itemstabl
3530: 65 29 29 29 0a 09 09 09 09 28 61 70 70 65 6e 64  e))).....(append
3540: 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74   (item-assoc->it
3550: 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29 0a 09  em-list items)..
3560: 09 09 09 09 28 69 74 65 6d 2d 74 61 62 6c 65 2d  ....(item-table-
3570: 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73  >item-list items
3580: 74 61 62 6c 65 29 29 0a 09 09 09 09 27 28 28 29  table)).....'(()
3590: 29 29 29 20 3b 3b 20 61 20 6c 69 73 74 20 77 69  ))) ;; a list wi
35a0: 74 68 20 6f 6e 65 20 6e 75 6c 6c 20 6c 69 73 74  th one null list
35b0: 20 69 73 20 61 20 74 65 73 74 20 77 69 74 68 20   is a test with 
35c0: 6e 6f 20 69 74 65 6d 73 0a 09 20 20 20 20 20 20  no items..      
35d0: 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20 28 63   (runconfigf  (c
35e0: 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20 22  onc  *toppath* "
35f0: 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66  /runconfigs.conf
3600: 69 67 22 29 29 29 0a 09 20 20 28 64 65 62 75 67  ig")))..  (debug
3610: 3a 70 72 69 6e 74 20 31 20 22 69 74 65 6d 73 3a  :print 1 "items:
3620: 20 22 29 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a   ")..  (if (>= *
3630: 76 65 72 62 6f 73 69 74 79 2a 20 31 29 28 70 70  verbosity* 1)(pp
3640: 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 20 20 28   allitems))..  (
3650: 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74  if (>= *verbosit
3660: 79 2a 20 35 29 0a 09 20 20 20 20 20 20 28 62 65  y* 5)..      (be
3670: 67 69 6e 0a 09 09 28 70 72 69 6e 74 20 22 69 74  gin...(print "it
3680: 65 6d 73 3a 20 22 29 28 70 70 20 28 69 74 65 6d  ems: ")(pp (item
3690: 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73  -assoc->item-lis
36a0: 74 20 69 74 65 6d 73 29 29 0a 09 09 28 70 72 69  t items))...(pri
36b0: 6e 74 20 22 69 74 65 73 74 61 62 6c 65 3a 20 22  nt "itestable: "
36c0: 29 28 70 70 20 28 69 74 65 6d 2d 74 61 62 6c 65  )(pp (item-table
36d0: 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d  ->item-list item
36e0: 73 74 61 62 6c 65 29 29 29 29 0a 09 20 20 28 69  stable))))..  (i
36f0: 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  f (args:get-arg 
3700: 22 2d 6d 22 29 0a 09 20 20 20 20 20 20 28 64 62  "-m")..      (db
3710: 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d 66 6f 72  :set-comment-for
3720: 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 20 28  -run db run-id (
3730: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d  args:get-arg "-m
3740: 22 29 29 29 0a 09 20 20 3b 3b 20 62 72 61 69 6e  ")))..  ;; brain
3750: 64 65 61 64 20 77 6f 72 6b 2d 61 72 6f 75 6e 64  dead work-around
3760: 20 66 6f 72 20 70 6f 6f 72 6c 79 20 73 70 65 63   for poorly spec
3770: 69 66 69 65 64 20 61 6c 6c 69 74 65 6d 73 20 6c  ified allitems l
3780: 69 73 74 20 42 55 47 21 21 21 20 46 49 58 4d 45  ist BUG!!! FIXME
3790: 0a 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 61  ..  (if (null? a
37a0: 6c 6c 69 74 65 6d 73 29 28 73 65 74 21 20 61 6c  llitems)(set! al
37b0: 6c 69 74 65 6d 73 20 27 28 28 29 29 29 29 0a 09  litems '(())))..
37c0: 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 69 74    (let loop ((it
37d0: 65 6d 64 61 74 20 28 63 61 72 20 61 6c 6c 69 74  emdat (car allit
37e0: 65 6d 73 29 29 0a 09 09 20 20 20 20 20 28 74 61  ems))...     (ta
37f0: 6c 20 20 20 20 20 28 63 64 72 20 61 6c 6c 69 74  l     (cdr allit
3800: 65 6d 73 29 29 29 0a 09 20 20 20 20 3b 3b 20 28  ems)))..    ;; (
3810: 6c 61 6d 62 64 61 20 28 69 74 65 6d 64 61 74 29  lambda (itemdat)
3820: 20 3b 3b 3b 20 28 28 72 69 70 65 6e 65 73 73 20   ;;; ((ripeness 
3830: 22 6f 76 65 72 72 69 70 65 22 29 20 28 74 65 6d  "overripe") (tem
3840: 70 65 72 61 74 75 72 65 20 22 63 6f 6f 6c 22 29  perature "cool")
3850: 20 28 73 65 61 73 6f 6e 20 22 73 75 6d 6d 65 72   (season "summer
3860: 22 29 29 0a 09 20 20 20 20 3b 3b 20 48 61 6e 64  "))..    ;; Hand
3870: 6c 65 20 6c 69 73 74 73 20 6f 66 20 69 74 65 6d  le lists of item
3880: 73 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69  s..    (let* ((i
3890: 74 65 6d 2d 70 61 74 68 20 20 20 20 20 28 69 74  tem-path     (it
38a0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
38b0: 65 6d 64 61 74 29 29 20 3b 3b 20 28 73 74 72 69  emdat)) ;; (stri
38c0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28  ng-intersperse (
38d0: 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64 61 74  map cadr itemdat
38e0: 29 20 22 2f 22 29 29 0a 09 09 20 20 20 28 6e 65  ) "/"))...   (ne
38f0: 77 2d 74 65 73 74 2d 70 61 74 68 20 28 73 74 72  w-test-path (str
3900: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
3910: 28 63 6f 6e 73 20 74 65 73 74 2d 70 61 74 68 20  (cons test-path 
3920: 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64 61  (map cadr itemda
3930: 74 29 29 20 22 2f 22 29 29 0a 09 09 20 20 20 28  t)) "/"))...   (
3940: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 28 69  new-test-name (i
3950: 66 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70  f (equal? item-p
3960: 61 74 68 20 22 22 29 20 74 65 73 74 2d 6e 61 6d  ath "") test-nam
3970: 65 20 28 63 6f 6e 63 20 74 65 73 74 2d 6e 61 6d  e (conc test-nam
3980: 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29  e "/" item-path)
3990: 29 29 20 3b 3b 20 6a 75 73 74 20 6e 65 65 64 20  )) ;; just need 
39a0: 69 74 20 74 6f 20 62 65 20 75 6e 69 71 75 65 0a  it to be unique.
39b0: 09 09 20 20 20 28 74 65 73 74 64 61 74 20 20 20  ..   (testdat   
39c0: 23 66 29 0a 09 09 20 20 20 28 6e 75 6d 2d 72 75  #f)...   (num-ru
39d0: 6e 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f  nning (db:get-co
39e0: 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e  unt-tests-runnin
39f0: 67 20 64 62 29 29 0a 09 09 20 20 20 28 6d 61 78  g db))...   (max
3a00: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
3a10: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
3a20: 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74  *configdat* "set
3a30: 75 70 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72  up" "max_concurr
3a40: 65 6e 74 5f 6a 6f 62 73 22 29 29 0a 09 09 20 20  ent_jobs"))...  
3a50: 20 28 70 61 72 65 6e 74 2d 74 65 73 74 20 28 61   (parent-test (a
3a60: 6e 64 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69  nd (not (null? i
3a70: 74 65 6d 73 29 29 28 65 71 75 61 6c 3f 20 69 74  tems))(equal? it
3a80: 65 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 09 09  em-path "")))...
3a90: 20 20 20 28 73 69 6e 67 6c 65 2d 74 65 73 74 20     (single-test 
3aa0: 28 61 6e 64 20 28 6e 75 6c 6c 3f 20 69 74 65 6d  (and (null? item
3ab0: 73 29 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d  s) (equal? item-
3ac0: 70 61 74 68 20 22 22 29 29 29 0a 09 09 20 20 20  path "")))...   
3ad0: 28 69 74 65 6d 2d 74 65 73 74 20 20 20 28 6e 6f  (item-test   (no
3ae0: 74 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70  t (equal? item-p
3af0: 61 74 68 20 22 22 29 29 29 29 0a 09 20 20 20 20  ath ""))))..    
3b00: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 33    (debug:print 3
3b10: 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74   "max-concurrent
3b20: 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e  -jobs: " max-con
3b30: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20  current-jobs ", 
3b40: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e  num-running: " n
3b50: 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 09 20 20 20  um-running)..   
3b60: 20 20 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e     (if (runs:can
3b70: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20  -run-more-tests 
3b80: 64 62 29 0a 09 09 20 20 28 62 65 67 69 6e 0a 09  db)...  (begin..
3b90: 09 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 32 20  .    (let loop2 
3ba0: 28 28 74 73 20 28 64 62 3a 67 65 74 2d 74 65 73  ((ts (db:get-tes
3bb0: 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  t-info db run-id
3bc0: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
3bd0: 70 61 74 68 29 29 20 3b 3b 20 23 66 29 0a 09 09  path)) ;; #f)...
3be0: 09 09 28 63 74 20 30 29 29 0a 09 09 20 20 20 20  ..(ct 0))...    
3bf0: 20 20 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20    (if (and (not 
3c00: 74 73 29 0a 09 09 09 20 20 20 20 20 20 20 28 3c  ts)....       (<
3c10: 20 63 74 20 31 30 29 29 0a 09 09 09 20 20 28 62   ct 10))....  (b
3c20: 65 67 69 6e 0a 09 09 09 20 20 20 20 28 72 65 67  egin....    (reg
3c30: 69 73 74 65 72 2d 74 65 73 74 20 64 62 20 72 75  ister-test db ru
3c40: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
3c50: 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 20 20 20  tem-path)....   
3c60: 20 28 64 62 3a 74 65 73 74 2d 73 65 74 2d 63 6f   (db:test-set-co
3c70: 6d 6d 65 6e 74 20 64 62 20 72 75 6e 2d 69 64 20  mment db run-id 
3c80: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
3c90: 61 74 68 20 22 22 29 0a 09 09 09 20 20 20 20 28  ath "")....    (
3ca0: 6c 6f 6f 70 32 20 28 64 62 3a 67 65 74 2d 74 65  loop2 (db:get-te
3cb0: 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69  st-info db run-i
3cc0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
3cd0: 2d 70 61 74 68 29 0a 09 09 09 09 20 20 20 28 2b  -path).....   (+
3ce0: 20 63 74 20 31 29 29 29 0a 09 09 09 20 20 28 69   ct 1)))....  (i
3cf0: 66 20 74 73 0a 09 09 09 20 20 20 20 20 20 28 73  f ts....      (s
3d00: 65 74 21 20 74 65 73 74 64 61 74 20 74 73 29 0a  et! testdat ts).
3d10: 09 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a  ...      (begin.
3d20: 09 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74  ....(debug:print
3d30: 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 43 6f 75   0 "WARNING: Cou
3d40: 6c 64 6e 27 74 20 72 65 67 69 73 74 65 72 20 74  ldn't register t
3d50: 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  est " test-name 
3d60: 22 20 77 69 74 68 20 69 74 65 6d 20 70 61 74 68  " with item path
3d70: 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 2c 20   " item-path ", 
3d80: 73 6b 69 70 70 69 6e 67 22 29 0a 09 09 09 09 28  skipping").....(
3d90: 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74  if (not (null? t
3da0: 61 6c 29 29 0a 09 09 09 09 20 20 20 20 28 6c 6f  al)).....    (lo
3db0: 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72  op (car tal)(cdr
3dc0: 20 74 61 6c 29 29 29 29 29 29 29 0a 09 09 20 20   tal)))))))...  
3dd0: 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74    (change-direct
3de0: 6f 72 79 20 74 65 73 74 2d 70 61 74 68 29 0a 09  ory test-path)..
3df0: 09 20 20 20 20 3b 3b 20 74 68 69 73 20 62 6c 6f  .    ;; this blo
3e00: 63 6b 20 69 73 20 68 65 72 65 20 6f 6e 6c 79 20  ck is here only 
3e10: 74 6f 20 69 6e 66 6f 72 6d 20 74 68 65 20 75 73  to inform the us
3e20: 65 72 20 65 61 72 6c 79 20 6f 6e 0a 09 09 20 20  er early on...  
3e30: 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73    (if (file-exis
3e40: 74 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a  ts? runconfigf).
3e50: 09 09 09 28 73 65 74 75 70 2d 65 6e 76 2d 64 65  ...(setup-env-de
3e60: 66 61 75 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e  faults db runcon
3e70: 66 69 67 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72  figf run-id *alr
3e80: 65 61 64 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e  eady-seen-runcon
3e90: 66 69 67 2d 69 6e 66 6f 2a 29 0a 09 09 09 28 64  fig-info*)....(d
3ea0: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
3eb0: 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e 6f  RNING: You do no
3ec0: 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f 6e  t have a run con
3ed0: 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e 63  fig file: " runc
3ee0: 6f 6e 66 69 67 66 29 29 0a 09 09 20 20 20 20 28  onfigf))...    (
3ef0: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72  debug:print 4 "r
3f00: 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 20  un-id: " run-id 
3f10: 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 74  " test-name: " t
3f20: 65 73 74 2d 6e 61 6d 65 20 22 20 69 74 65 6d 2d  est-name " item-
3f30: 70 61 74 68 3a 20 22 20 69 74 65 6d 2d 70 61 74  path: " item-pat
3f40: 68 20 22 20 74 65 73 74 64 61 74 3a 20 22 20 28  h " testdat: " (
3f50: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
3f60: 74 65 73 74 64 61 74 29 20 22 20 74 65 73 74 2d  testdat) " test-
3f70: 73 74 61 74 65 3a 20 22 20 28 74 65 73 74 3a 67  state: " (test:g
3f80: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
3f90: 29 29 0a 09 09 20 20 20 20 28 63 61 73 65 20 28  ))...    (case (
3fa0: 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  if (args:get-arg
3fb0: 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 20 20   "-force")....  
3fc0: 20 20 20 20 27 4e 4f 54 5f 53 54 41 52 54 45 44      'NOT_STARTED
3fd0: 0a 09 09 09 20 20 20 20 20 20 28 69 66 20 74 65  ....      (if te
3fe0: 73 74 64 61 74 0a 09 09 09 09 20 20 28 73 74 72  stdat.....  (str
3ff0: 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73  ing->symbol (tes
4000: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
4010: 64 61 74 29 29 0a 09 09 09 09 20 20 27 66 61 69  dat)).....  'fai
4020: 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a  led-to-insert)).
4030: 09 09 20 20 20 20 20 20 28 28 66 61 69 6c 65 64  ..      ((failed
4040: 2d 74 6f 2d 69 6e 73 65 72 74 29 0a 09 09 20 20  -to-insert)...  
4050: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
4060: 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c  t 0 "ERROR: Fail
4070: 65 64 20 74 6f 20 69 6e 73 65 72 74 20 74 68 65  ed to insert the
4080: 20 72 65 63 6f 72 64 20 69 6e 74 6f 20 74 68 65   record into the
4090: 20 64 62 22 29 29 0a 09 09 20 20 20 20 20 20 28   db"))...      (
40a0: 28 4e 4f 54 5f 53 54 41 52 54 45 44 20 43 4f 4d  (NOT_STARTED COM
40b0: 50 4c 45 54 45 44 29 0a 09 09 20 20 20 20 20 20  PLETED)...      
40c0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20   (debug:print 6 
40d0: 22 47 6f 74 20 68 65 72 65 2c 20 22 20 28 74 65  "Got here, " (te
40e0: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
40f0: 74 64 61 74 29 29 0a 09 09 20 20 20 20 20 20 20  tdat))...       
4100: 28 6c 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23  (let ((runflag #
4110: 66 29 29 0a 09 09 09 20 28 63 6f 6e 64 0a 09 09  f)).... (cond...
4120: 09 20 20 3b 3b 20 69 2e 65 2e 20 74 68 69 73 20  .  ;; i.e. this 
4130: 69 73 20 74 68 65 20 70 61 72 65 6e 74 20 74 65  is the parent te
4140: 73 74 20 74 6f 20 61 20 73 75 69 74 65 20 6f 66  st to a suite of
4150: 20 69 74 65 6d 73 2c 20 6e 65 76 65 72 20 22 72   items, never "r
4160: 75 6e 22 20 69 74 0a 09 09 09 20 20 28 70 61 72  un" it....  (par
4170: 65 6e 74 2d 74 65 73 74 0a 09 09 09 20 20 20 28  ent-test....   (
4180: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29  set! runflag #f)
4190: 29 0a 09 09 09 20 20 3b 3b 20 2d 66 6f 72 63 65  )....  ;; -force
41a0: 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20  , run no matter 
41b0: 77 68 61 74 0a 09 09 09 20 20 28 28 61 72 67 73  what....  ((args
41c0: 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65  :get-arg "-force
41d0: 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20  ")(set! runflag 
41e0: 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 4e 4f 54  #t))....  ;; NOT
41f0: 5f 53 54 41 52 54 45 44 2c 20 72 75 6e 20 6e 6f  _STARTED, run no
4200: 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09 09   matter what....
4210: 20 20 28 28 65 71 75 61 6c 3f 20 28 74 65 73 74    ((equal? (test
4220: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
4230: 61 74 29 20 22 4e 4f 54 5f 53 54 41 52 54 45 44  at) "NOT_STARTED
4240: 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20  ")(set! runflag 
4250: 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 6e 6f 74  #t))....  ;; not
4260: 20 2d 72 65 72 75 6e 20 61 6e 64 20 50 41 53 53   -rerun and PASS
4270: 2c 20 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 2c  , WARN or CHECK,
4280: 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 09 09 20 20   do no run....  
4290: 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20 28  ((and (or (not (
42a0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
42b0: 65 72 75 6e 22 29 29 0a 09 09 09 09 20 20 20 20  erun")).....    
42c0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
42d0: 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 09  keepgoing"))....
42e0: 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67  .(member (test:g
42f0: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
4300: 74 29 20 27 28 22 50 41 53 53 22 20 22 57 41 52  t) '("PASS" "WAR
4310: 4e 22 20 22 43 48 45 43 4b 22 29 29 29 0a 09 09  N" "CHECK")))...
4320: 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61  .   (set! runfla
4330: 67 20 23 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d  g #f))....  ;; -
4340: 72 65 72 75 6e 20 61 6e 64 20 73 74 61 74 75 73  rerun and status
4350: 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 73   is one of the s
4360: 70 65 63 69 66 65 64 2c 20 72 75 6e 20 69 74 0a  pecifed, run it.
4370: 09 09 09 20 20 28 28 61 6e 64 20 28 61 72 67 73  ...  ((and (args
4380: 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e  :get-arg "-rerun
4390: 22 29 0a 09 09 09 09 28 6c 65 74 20 28 28 72 65  ").....(let ((re
43a0: 72 75 6e 6c 73 74 20 28 73 74 72 69 6e 67 2d 73  runlst (string-s
43b0: 70 6c 69 74 20 28 61 72 67 73 3a 67 65 74 2d 61  plit (args:get-a
43c0: 72 67 20 22 2d 72 65 72 75 6e 22 29 20 22 2c 22  rg "-rerun") ","
43d0: 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 09  ))) ;; FAIL,....
43e0: 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74  .  (member (test
43f0: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
4400: 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29 29  dat) rerunlst)))
4410: 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e  ....   (set! run
4420: 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 3b  flag #t))....  ;
4430: 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f  ; -keepgoing, do
4440: 20 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a   not rerun FAIL.
4450: 09 09 09 20 20 28 28 61 6e 64 20 28 61 72 67 73  ...  ((and (args
4460: 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67  :get-arg "-keepg
4470: 6f 69 6e 67 22 29 0a 09 09 09 09 28 6d 65 6d 62  oing").....(memb
4480: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
4490: 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22  tus testdat) '("
44a0: 46 41 49 4c 22 29 29 29 0a 09 09 09 20 20 20 28  FAIL")))....   (
44b0: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29  set! runflag #f)
44c0: 29 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6e 6f  )....  ((and (no
44d0: 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  t (args:get-arg 
44e0: 22 2d 72 65 72 75 6e 22 29 29 0a 09 09 09 09 28  "-rerun")).....(
44f0: 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74  member (test:get
4500: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
4510: 20 27 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 29   '("FAIL" "n/a")
4520: 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72  ))....   (set! r
4530: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20  unflag #t)).... 
4540: 20 28 65 6c 73 65 20 28 73 65 74 21 20 72 75 6e   (else (set! run
4550: 66 6c 61 67 20 23 66 29 29 29 0a 09 09 09 20 28  flag #f))).... (
4560: 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22 52  debug:print 6 "R
4570: 55 4e 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c 61  UNNING => runfla
4580: 67 3a 20 22 20 72 75 6e 66 6c 61 67 20 22 20 53  g: " runflag " S
4590: 54 41 54 45 3a 20 22 20 28 74 65 73 74 3a 67 65  TATE: " (test:ge
45a0: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
45b0: 20 22 20 53 54 41 54 55 53 3a 20 22 20 28 74 65   " STATUS: " (te
45c0: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
45d0: 73 74 64 61 74 29 29 0a 09 09 09 20 28 69 66 20  stdat)).... (if 
45e0: 28 6e 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09 09  (not runflag)...
45f0: 09 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 70  .     (if (not p
4600: 61 72 65 6e 74 2d 74 65 73 74 29 0a 09 09 09 09  arent-test).....
4610: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
4620: 22 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72 74  "NOTE: Not start
4630: 69 6e 67 20 74 65 73 74 20 22 20 6e 65 77 2d 74  ing test " new-t
4640: 65 73 74 2d 6e 61 6d 65 20 22 20 61 73 20 69 74  est-name " as it
4650: 20 69 73 20 73 74 61 74 65 20 5c 22 43 4f 4d 50   is state \"COMP
4660: 4c 45 54 45 44 5c 22 20 61 6e 64 20 73 74 61 74  LETED\" and stat
4670: 75 73 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74  us \"" (test:get
4680: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
4690: 20 22 5c 22 2c 20 75 73 65 20 2d 66 6f 72 63 65   "\", use -force
46a0: 20 74 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a   to override")).
46b0: 09 09 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28  ...     (let* ((
46c0: 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d 64 20  get-prereqs-cmd 
46d0: 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09  (lambda ()......
46e0: 09 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d  .       (db-get-
46f0: 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20  prereqs-not-met 
4700: 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e  db run-id waiton
4710: 29 29 29 20 3b 3b 20 63 68 65 63 6b 20 62 65 66  ))) ;; check bef
4720: 6f 72 65 20 72 75 6e 6e 69 6e 67 20 2e 2e 2e 2e  ore running ....
4730: 0a 09 09 09 09 20 20 20 20 28 6c 61 75 6e 63 68  .....    (launch
4740: 2d 63 6d 64 20 20 20 20 20 20 28 6c 61 6d 62 64  -cmd      (lambd
4750: 61 20 28 29 0a 09 09 09 09 09 09 20 20 20 20 20  a ().......     
4760: 20 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64    (launch-test d
4770: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 63 6f  b run-id test-co
4780: 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73  nf keyvallst tes
4790: 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68  t-name test-path
47a0: 20 69 74 65 6d 64 61 74 29 29 29 0a 09 09 09 09   itemdat))).....
47b0: 20 20 20 20 28 74 65 73 74 72 75 6e 64 61 74 20      (testrundat 
47c0: 20 20 20 20 20 28 6c 69 73 74 20 67 65 74 2d 70       (list get-p
47d0: 72 65 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e 63  rereqs-cmd launc
47e0: 68 2d 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20  h-cmd)))....    
47f0: 20 20 20 28 69 66 20 28 6f 72 20 28 61 72 67 73     (if (or (args
4800: 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65  :get-arg "-force
4810: 22 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 6e  ").....       (n
4820: 75 6c 6c 3f 20 28 28 63 61 72 20 74 65 73 74 72  ull? ((car testr
4830: 75 6e 64 61 74 29 29 29 29 20 3b 3b 20 61 72 65  undat)))) ;; are
4840: 20 74 68 65 72 65 20 61 6e 79 20 74 65 73 74 73   there any tests
4850: 20 74 68 61 74 20 6d 75 73 74 20 62 65 20 72 75   that must be ru
4860: 6e 20 62 65 66 6f 72 65 20 74 68 69 73 20 6f 6e  n before this on
4870: 65 2e 2e 2e 0a 09 09 09 09 20 20 20 28 28 63 61  e........   ((ca
4880: 64 72 20 74 65 73 74 72 75 6e 64 61 74 29 29 20  dr testrundat)) 
4890: 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65 20 6c  ;; this is the l
48a0: 69 6e 65 20 74 68 61 74 20 6c 61 75 6e 63 68 65  ine that launche
48b0: 73 20 74 68 65 20 74 65 73 74 20 74 6f 20 74 68  s the test to th
48c0: 65 20 72 65 6d 6f 74 65 20 68 6f 73 74 0a 09 09  e remote host...
48d0: 09 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 61  ..   (if (not (a
48e0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65  rgs:get-arg "-ke
48f0: 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 20  epgoing"))..... 
4900: 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c        (hash-tabl
4910: 65 2d 73 65 74 21 20 2a 77 61 69 74 69 6e 67 2d  e-set! *waiting-
4920: 71 75 65 75 65 2a 20 6e 65 77 2d 74 65 73 74 2d  queue* new-test-
4930: 6e 61 6d 65 20 74 65 73 74 72 75 6e 64 61 74 29  name testrundat)
4940: 29 29 29 29 29 29 0a 09 09 20 20 20 20 20 20 28  ))))))...      (
4950: 28 4b 49 4c 4c 45 44 29 20 0a 09 09 20 20 20 20  (KILLED) ...    
4960: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
4970: 31 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74  1 "NOTE: " new-t
4980: 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c  est-name " is al
4990: 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72  ready running or
49a0: 20 77 61 73 20 65 78 70 6c 69 63 74 6c 79 20 6b   was explictly k
49b0: 69 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 63  illed, use -forc
49c0: 65 20 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22  e to launch it."
49d0: 29 29 0a 09 09 20 20 20 20 20 20 28 28 4c 41 55  ))...      ((LAU
49e0: 4e 43 48 45 44 20 52 45 4d 4f 54 45 48 4f 53 54  NCHED REMOTEHOST
49f0: 53 54 41 52 54 20 52 55 4e 4e 49 4e 47 29 20 20  START RUNNING)  
4a00: 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28 3e  ...       (if (>
4a10: 20 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 63   (- (current-sec
4a20: 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73 74  onds)(+ (db:test
4a30: 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20  -get-event_time 
4a40: 74 65 73 74 64 61 74 29 0a 09 09 09 09 09 09 20  testdat)....... 
4a50: 20 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74      (db:test-get
4a60: 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65  -run_duration te
4a70: 73 74 64 61 74 29 29 29 0a 09 09 09 20 20 20 20  stdat)))....    
4a80: 20 20 31 30 30 29 20 3b 3b 20 69 2e 65 2e 20 6e    100) ;; i.e. n
4a90: 6f 20 75 70 64 61 74 65 20 66 6f 72 20 6d 6f 72  o update for mor
4aa0: 65 20 74 68 61 6e 20 31 30 30 20 73 65 63 6f 6e  e than 100 secon
4ab0: 64 73 0a 09 09 09 20 20 20 28 62 65 67 69 6e 0a  ds....   (begin.
4ac0: 09 09 09 20 20 20 20 20 28 64 65 62 75 67 3a 70  ...     (debug:p
4ad0: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
4ae0: 20 54 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d   Test " test-nam
4af0: 65 20 22 20 61 70 70 65 61 72 73 20 74 6f 20 62  e " appears to b
4b00: 65 20 64 65 61 64 2e 20 46 6f 72 63 69 6e 67 20  e dead. Forcing 
4b10: 69 74 20 74 6f 20 73 74 61 74 65 20 49 4e 43 4f  it to state INCO
4b20: 4d 50 4c 45 54 45 20 61 6e 64 20 73 74 61 74 75  MPLETE and statu
4b30: 73 20 53 54 55 43 4b 2f 44 45 41 44 22 29 0a 09  s STUCK/DEAD")..
4b40: 09 09 20 20 20 20 20 28 74 65 73 74 2d 73 65 74  ..     (test-set
4b50: 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d  -status! db run-
4b60: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 22 49 4e  id test-name "IN
4b70: 43 4f 4d 50 4c 45 54 45 22 20 22 53 54 55 43 4b  COMPLETE" "STUCK
4b80: 2f 44 45 41 44 22 20 69 74 65 6d 64 61 74 20 22  /DEAD" itemdat "
4b90: 54 65 73 74 20 69 73 20 73 74 75 63 6b 20 6f 72  Test is stuck or
4ba0: 20 64 65 61 64 22 29 29 0a 09 09 09 20 20 20 28   dead"))....   (
4bb0: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e  debug:print 2 "N
4bc0: 4f 54 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65  OTE: " test-name
4bd0: 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75   " is already ru
4be0: 6e 6e 69 6e 67 22 29 29 29 0a 09 09 20 20 20 20  nning")))...    
4bf0: 20 20 28 65 6c 73 65 20 20 20 20 20 20 20 28 64    (else       (d
4c00: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
4c10: 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c  ROR: Failed to l
4c20: 61 75 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77  aunch test " new
4c30: 2d 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e  -test-name ". Un
4c40: 72 65 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65  recognised state
4c50: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
4c60: 74 65 20 74 65 73 74 64 61 74 29 29 29 29 29 29  te testdat))))))
4c70: 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74  ..      (if (not
4c80: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09   (null? tal))...
4c90: 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c    (loop (car tal
4ca0: 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29  )(cdr tal)))))))
4cb0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ))..(define (run
4cc0: 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64  -waiting-tests d
4cd0: 62 29 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 74  b).  (let ((numt
4ce0: 72 69 65 73 20 20 20 20 20 20 20 20 20 20 20 30  ries           0
4cf0: 29 0a 09 28 6c 61 73 74 2d 74 72 79 2d 74 69 6d  )..(last-try-tim
4d00: 65 20 20 20 20 20 20 28 63 75 72 72 65 6e 74 2d  e      (current-
4d10: 73 65 63 6f 6e 64 73 29 29 0a 09 28 74 69 6d 65  seconds))..(time
4d20: 73 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28  s              (
4d30: 6c 69 73 74 20 31 29 29 29 20 3b 3b 20 6d 69 6e  list 1))) ;; min
4d40: 75 74 65 73 20 74 6f 20 77 61 69 74 20 62 65 66  utes to wait bef
4d50: 6f 72 65 20 74 72 79 69 6e 67 20 61 67 61 69 6e  ore trying again
4d60: 20 74 6f 20 6b 69 63 6b 20 6f 66 66 20 72 75 6e   to kick off run
4d70: 73 0a 20 20 20 20 3b 3b 20 42 55 47 20 74 68 69  s.    ;; BUG thi
4d80: 73 20 68 61 63 6b 20 6f 66 20 62 72 75 74 65 20  s hack of brute 
4d90: 66 6f 72 63 65 20 72 65 74 72 79 69 6e 67 20 77  force retrying w
4da0: 6f 72 6b 73 20 71 75 69 74 65 20 77 65 6c 6c 20  orks quite well 
4db0: 66 6f 72 20 6d 61 6e 79 20 63 61 73 65 73 20 62  for many cases b
4dc0: 75 74 20 0a 20 20 20 20 3b 3b 20 20 20 20 20 77  ut .    ;;     w
4dd0: 68 61 74 20 69 73 20 6e 65 65 64 65 64 20 69 73  hat is needed is
4de0: 20 74 6f 20 63 68 65 63 6b 20 74 68 65 20 64 62   to check the db
4df0: 20 66 6f 72 20 74 65 73 74 73 20 74 68 61 74 20   for tests that 
4e00: 68 61 76 65 20 66 61 69 6c 65 64 20 6c 65 73 73  have failed less
4e10: 20 74 68 61 6e 0a 20 20 20 20 3b 3b 20 20 20 20   than.    ;;    
4e20: 20 4e 20 74 69 6d 65 73 20 6f 72 20 6e 65 76 65   N times or neve
4e30: 72 20 62 65 65 6e 20 73 74 61 72 74 65 64 20 61  r been started a
4e40: 6e 64 20 6b 69 63 6b 20 74 68 65 6d 20 6f 66 66  nd kick them off
4e50: 20 61 67 61 69 6e 0a 20 20 20 20 28 6c 65 74 20   again.    (let 
4e60: 6c 6f 6f 70 20 28 28 77 61 69 74 69 6e 67 2d 74  loop ((waiting-t
4e70: 65 73 74 2d 6e 61 6d 65 73 20 28 68 61 73 68 2d  est-names (hash-
4e80: 74 61 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74  table-keys *wait
4e90: 69 6e 67 2d 71 75 65 75 65 2a 29 29 29 0a 20 20  ing-queue*))).  
4ea0: 20 20 20 20 28 63 6f 6e 64 0a 20 20 20 20 20 20      (cond.      
4eb0: 20 28 28 6e 6f 74 20 28 72 75 6e 73 3a 63 61 6e   ((not (runs:can
4ec0: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20  -run-more-tests 
4ed0: 64 62 29 29 0a 09 28 73 6c 65 65 70 20 32 29 0a  db))..(sleep 2).
4ee0: 09 28 6c 6f 6f 70 20 77 61 69 74 69 6e 67 2d 74  .(loop waiting-t
4ef0: 65 73 74 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20  est-names)).    
4f00: 20 20 20 28 28 6e 75 6c 6c 3f 20 77 61 69 74 69     ((null? waiti
4f10: 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09  ng-test-names)..
4f20: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
4f30: 41 6c 6c 20 74 65 73 74 73 20 6c 61 75 6e 63 68  All tests launch
4f40: 65 64 22 29 29 0a 20 20 20 20 20 20 20 28 65 6c  ed")).       (el
4f50: 73 65 0a 09 28 73 65 74 21 20 6e 75 6d 74 72 69  se..(set! numtri
4f60: 65 73 20 28 2b 20 6e 75 6d 74 72 69 65 73 20 31  es (+ numtries 1
4f70: 29 29 0a 09 28 66 6f 72 2d 65 61 63 68 20 28 6c  ))..(for-each (l
4f80: 61 6d 62 64 61 20 28 74 65 73 74 6e 61 6d 65 29  ambda (testname)
4f90: 0a 09 09 20 20 20 20 28 69 66 20 28 72 75 6e 73  ...    (if (runs
4fa0: 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65  :can-run-more-te
4fb0: 73 74 73 20 64 62 29 0a 09 09 09 28 6c 65 74 2a  sts db)....(let*
4fc0: 20 28 28 74 65 73 74 64 61 74 20 28 68 61 73 68   ((testdat (hash
4fd0: 2d 74 61 62 6c 65 2d 72 65 66 20 2a 77 61 69 74  -table-ref *wait
4fe0: 69 6e 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e  ing-queue* testn
4ff0: 61 6d 65 29 29 0a 09 09 09 20 20 20 20 20 20 20  ame))....       
5000: 28 70 72 65 72 65 71 73 20 28 28 63 61 72 20 74  (prereqs ((car t
5010: 65 73 74 64 61 74 29 29 29 0a 09 09 09 20 20 20  estdat)))....   
5020: 20 20 20 20 28 6c 64 62 20 20 20 20 20 28 69 66      (ldb     (if
5030: 20 64 62 20 64 62 20 28 6f 70 65 6e 2d 64 62 29   db db (open-db)
5040: 29 29 29 0a 09 09 09 20 20 28 64 65 62 75 67 3a  )))....  (debug:
5050: 70 72 69 6e 74 20 32 20 22 70 72 65 72 65 71 73  print 2 "prereqs
5060: 20 72 65 6d 61 69 6e 69 6e 67 3a 20 22 20 70 72   remaining: " pr
5070: 65 72 65 71 73 29 0a 09 09 09 20 20 28 69 66 20  ereqs)....  (if 
5080: 28 6e 75 6c 6c 3f 20 70 72 65 72 65 71 73 29 0a  (null? prereqs).
5090: 09 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a  ...      (begin.
50a0: 09 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74  ....(debug:print
50b0: 20 32 20 22 50 72 65 72 65 71 75 69 73 69 74 65   2 "Prerequisite
50c0: 73 20 6d 65 74 2c 20 6c 61 75 6e 63 68 69 6e 67  s met, launching
50d0: 20 22 20 74 65 73 74 6e 61 6d 65 29 0a 09 09 09   " testname)....
50e0: 09 28 28 63 61 64 72 20 74 65 73 74 64 61 74 29  .((cadr testdat)
50f0: 29 0a 09 09 09 09 28 68 61 73 68 2d 74 61 62 6c  ).....(hash-tabl
5100: 65 2d 64 65 6c 65 74 65 21 20 2a 77 61 69 74 69  e-delete! *waiti
5110: 6e 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e 61  ng-queue* testna
5120: 6d 65 29 29 29 0a 09 09 09 20 20 28 69 66 20 28  me)))....  (if (
5130: 6e 6f 74 20 64 62 29 0a 09 09 09 20 20 20 20 20  not db)....     
5140: 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69   (sqlite3:finali
5150: 7a 65 21 20 6c 64 62 29 29 29 29 29 0a 09 09 20  ze! ldb)))))... 
5160: 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61   waiting-test-na
5170: 6d 65 73 29 0a 09 3b 3b 20 28 73 6c 65 65 70 20  mes)..;; (sleep 
5180: 31 30 29 20 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20  10) ;; no point 
5190: 69 6e 20 72 75 73 68 69 6e 67 20 74 68 69 6e 67  in rushing thing
51a0: 73 20 61 74 20 74 68 69 73 20 73 74 61 67 65 3f  s at this stage?
51b0: 0a 09 28 6c 6f 6f 70 20 28 68 61 73 68 2d 74 61  ..(loop (hash-ta
51c0: 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e  ble-keys *waitin
51d0: 67 2d 71 75 65 75 65 2a 29 29 29 29 29 29 29 0a  g-queue*))))))).
51e0: 0a 28 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69  .(define (get-di
51f0: 72 2d 75 70 2d 6f 6e 65 20 64 69 72 29 20 0a 20  r-up-one dir) . 
5200: 20 28 6c 65 74 20 28 28 64 70 61 72 74 73 20 20   (let ((dparts  
5210: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69  (string-split di
5220: 72 20 22 2f 22 29 29 29 0a 20 20 20 20 28 63 6f  r "/"))).    (co
5230: 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69  nc "/" (string-i
5240: 6e 74 65 72 73 70 65 72 73 65 20 0a 09 20 20 20  ntersperse ..   
5250: 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73      (take dparts
5260: 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72   (- (length dpar
5270: 74 73 29 20 31 29 29 0a 09 20 20 20 20 20 20 20  ts) 1))..       
5280: 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76  "/")))).;; Remov
5290: 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73  e runs.;; fields
52a0: 20 61 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20   are passing in 
52b0: 74 68 72 6f 75 67 68 20 0a 28 64 65 66 69 6e 65  through .(define
52c0: 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75   (runs:remove-ru
52d0: 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65 70 61 74  ns db runnamepat
52e0: 74 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70  t testpatt itemp
52f0: 61 74 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b  att).  (let* ((k
5300: 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d 67  eys        (db-g
5310: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28  et-keys db)).. (
5320: 72 75 6e 64 61 74 20 20 20 20 20 20 28 72 75 6e  rundat      (run
5330: 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61  s:get-runs-by-pa
5340: 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61  tt db keys runna
5350: 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65 61 64  mepatt)).. (head
5360: 65 72 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d  er      (vector-
5370: 72 65 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09  ref rundat 0))..
5380: 20 28 72 75 6e 73 20 20 20 20 20 20 20 20 28 76   (runs        (v
5390: 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74  ector-ref rundat
53a0: 20 31 29 29 29 0a 20 20 20 20 28 64 65 62 75 67   1))).    (debug
53b0: 3a 70 72 69 6e 74 20 31 20 22 48 65 61 64 65 72  :print 1 "Header
53c0: 3a 20 22 20 68 65 61 64 65 72 29 0a 20 20 20 20  : " header).    
53d0: 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28  (for-each.     (
53e0: 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20 20 20  lambda (run).   
53f0: 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e 6b 65      (let ((runke
5400: 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  y (string-inters
5410: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62  perse (map (lamb
5420: 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28 64 62  da (k).......(db
5430: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
5440: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
5450: 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20 30 29  (vector-ref k 0)
5460: 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29 29 0a  )) keys) "/"))).
5470: 09 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64  . (let* ((run-id
5480: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
5490: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
54a0: 64 65 72 20 22 69 64 22 29 20 29 0a 09 09 28 74  der "id") )...(t
54b0: 65 73 74 73 20 20 28 64 62 2d 67 65 74 2d 74 65  ests  (db-get-te
54c0: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28  sts-for-run db (
54d0: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
54e0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
54f0: 72 20 22 69 64 22 29 20 74 65 73 74 70 61 74 74  r "id") testpatt
5500: 20 69 74 65 6d 70 61 74 74 29 29 0a 09 09 28 6c   itempatt))...(l
5510: 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73 2f  asttpath "/does/
5520: 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70 65  not/exist/I/hope
5530: 22 29 29 0a 09 20 20 20 28 69 66 20 28 6e 6f 74  "))..   (if (not
5540: 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29 29 0a   (null? tests)).
5550: 09 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  .       (begin..
5560: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31  . (debug:print 1
5570: 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73 74 73   "Removing tests
5580: 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b   for run: " runk
5590: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
55a0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
55b0: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
55c0: 6d 65 22 29 29 0a 09 09 20 28 66 6f 72 2d 65 61  me"))... (for-ea
55d0: 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61 20 28  ch...  (lambda (
55e0: 74 65 73 74 29 0a 09 09 20 20 20 20 28 64 65 62  test)...    (deb
55f0: 75 67 3a 70 72 69 6e 74 20 31 20 22 20 20 22 20  ug:print 1 "  " 
5600: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73  (db:test-get-tes
5610: 74 6e 61 6d 65 20 74 65 73 74 29 20 22 20 69 64  tname test) " id
5620: 3a 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  : " (db:test-get
5630: 2d 69 64 20 74 65 73 74 29 20 22 20 22 20 28 64  -id test) " " (d
5640: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
5650: 70 61 74 68 20 74 65 73 74 29 29 0a 09 09 20 20  path test))...  
5660: 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73    (db:delete-tes
5670: 74 2d 72 65 63 6f 72 64 73 20 64 62 20 28 64 62  t-records db (db
5680: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
5690: 74 29 29 0a 09 09 20 20 20 20 28 69 66 20 28 3e  t))...    (if (>
56a0: 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20   (string-length 
56b0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e  (db:test-get-run
56c0: 64 69 72 20 74 65 73 74 29 29 20 35 29 20 3b 3b  dir test)) 5) ;;
56d0: 20 62 61 64 20 68 65 75 72 69 73 74 69 63 20 62   bad heuristic b
56e0: 75 74 20 73 68 6f 75 6c 64 20 70 72 65 76 65 6e  ut should preven
56f0: 74 20 2f 74 6d 70 20 2f 68 6f 6d 65 20 65 74 63  t /tmp /home etc
5700: 2e 0a 09 09 09 28 6c 65 74 20 28 28 66 75 6c 6c  .....(let ((full
5710: 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65  path (db:test-ge
5720: 74 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29 29  t-rundir test)))
5730: 20 3b 3b 20 22 2f 22 20 28 64 62 3a 74 65 73 74   ;; "/" (db:test
5740: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
5750: 65 73 74 29 29 29 29 0a 09 09 09 20 20 28 73 65  est))))....  (se
5760: 74 21 20 6c 61 73 74 74 70 61 74 68 20 66 75 6c  t! lasttpath ful
5770: 6c 70 61 74 68 29 0a 09 09 09 20 20 28 64 65 62  lpath)....  (deb
5780: 75 67 3a 70 72 69 6e 74 20 31 20 22 72 6d 20 2d  ug:print 1 "rm -
5790: 72 66 20 22 20 66 75 6c 6c 70 61 74 68 29 0a 09  rf " fullpath)..
57a0: 09 09 20 20 28 73 79 73 74 65 6d 20 28 63 6f 6e  ..  (system (con
57b0: 63 20 22 72 6d 20 2d 72 66 20 22 20 66 75 6c 6c  c "rm -rf " full
57c0: 70 61 74 68 29 29 0a 09 09 09 20 20 28 6c 65 74  path))....  (let
57d0: 20 28 28 63 6d 64 20 28 63 6f 6e 63 20 22 72 6d   ((cmd (conc "rm
57e0: 64 69 72 20 2d 70 20 22 20 28 67 65 74 2d 64 69  dir -p " (get-di
57f0: 72 2d 75 70 2d 6f 6e 65 20 66 75 6c 6c 70 61 74  r-up-one fullpat
5800: 68 29 29 29 29 0a 09 09 09 20 20 20 20 28 64 65  h))))....    (de
5810: 62 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29  bug:print 1 cmd)
5820: 0a 09 09 09 20 20 20 20 28 73 79 73 74 65 6d 20  ....    (system 
5830: 63 6d 64 29 29 0a 09 09 09 20 20 29 29 29 0a 09  cmd))....  )))..
5840: 09 20 20 74 65 73 74 73 29 29 29 0a 09 20 20 20  .  tests)))..   
5850: 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73 20  (let ((remtests 
5860: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
5870: 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74  r-run db (db:get
5880: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
5890: 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22   run header "id"
58a0: 29 29 29 29 0a 09 20 20 20 20 20 28 69 66 20 28  ))))..     (if (
58b0: 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 20  null? remtests) 
58c0: 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73  ;; no more tests
58d0: 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20 28 6c   remaining... (l
58e0: 65 74 2a 20 28 28 64 70 61 72 74 73 20 20 28 73  et* ((dparts  (s
58f0: 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74  tring-split last
5900: 74 70 61 74 68 20 22 2f 22 29 29 0a 09 09 09 28  tpath "/"))....(
5910: 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 20 22 2f  runpath (conc "/
5920: 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  " (string-inters
5930: 70 65 72 73 65 20 0a 09 09 09 09 09 20 20 20 20  perse ......    
5940: 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20  (take dparts (- 
5950: 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20  (length dparts) 
5960: 31 29 29 0a 09 09 09 09 09 20 20 20 20 22 2f 22  1))......    "/"
5970: 29 29 29 29 0a 09 09 20 20 20 28 64 65 62 75 67  ))))...   (debug
5980: 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69  :print 1 "Removi
5990: 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79  ng run: " runkey
59a0: 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76 61 6c   " " (db:get-val
59b0: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
59c0: 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65   header "runname
59d0: 22 29 29 0a 09 09 20 20 20 28 64 62 3a 64 65 6c  "))...   (db:del
59e0: 65 74 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69  ete-run db run-i
59f0: 64 29 0a 09 09 20 20 20 3b 3b 20 6e 65 65 64 20  d)...   ;; need 
5a00: 74 6f 20 66 69 67 75 72 65 20 6f 75 74 20 74 68  to figure out th
5a10: 65 20 70 61 74 68 20 74 6f 20 74 68 65 20 72 75  e path to the ru
5a20: 6e 20 64 69 72 20 61 6e 64 20 72 65 6d 6f 76 65  n dir and remove
5a30: 20 69 74 20 69 66 20 65 6d 70 74 79 0a 09 09 3b   it if empty...;
5a40: 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  ;    (if (null? 
5a50: 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70  (glob (conc runp
5a60: 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 3b 3b  ath "/*")))...;;
5a70: 20 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09          (begin..
5a80: 09 3b 3b 20 09 20 28 64 65 62 75 67 3a 70 72 69  .;; . (debug:pri
5a90: 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72  nt 1 "Removing r
5aa0: 75 6e 20 64 69 72 20 22 20 72 75 6e 70 61 74 68  un dir " runpath
5ab0: 29 0a 09 09 3b 3b 20 09 20 28 73 79 73 74 65 6d  )...;; . (system
5ac0: 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70   (conc "rmdir -p
5ad0: 20 22 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09   " runpath))))..
5ae0: 09 20 20 20 29 29 29 0a 09 09 20 29 29 29 0a 20  .   )))... ))). 
5af0: 20 20 20 20 72 75 6e 73 29 29 29 0a 0a               runs)))..