Megatest

Hex Artifact Content
Login

Artifact bfe43f14b25b42bb2c43b043e705d655194b9dab:


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 28 70 70 20 61 6c 6c 69 74 65 6d 73 29   ")(pp allitems)
3630: 0a 09 20 20 28 69 66 20 28 61 72 67 73 3a 67 65  ..  (if (args:ge
3640: 74 2d 61 72 67 20 22 2d 6d 22 29 0a 09 20 20 20  t-arg "-m")..   
3650: 20 20 20 28 64 62 3a 73 65 74 2d 63 6f 6d 6d 65     (db:set-comme
3660: 6e 74 2d 66 6f 72 2d 72 75 6e 20 64 62 20 72 75  nt-for-run db ru
3670: 6e 2d 69 64 20 28 61 72 67 73 3a 67 65 74 2d 61  n-id (args:get-a
3680: 72 67 20 22 2d 6d 22 29 29 29 0a 09 20 20 28 6c  rg "-m")))..  (l
3690: 65 74 20 6c 6f 6f 70 20 28 28 69 74 65 6d 64 61  et loop ((itemda
36a0: 74 20 28 63 61 72 20 61 6c 6c 69 74 65 6d 73 29  t (car allitems)
36b0: 29 0a 09 09 20 20 20 20 20 28 74 61 6c 20 20 20  )...     (tal   
36c0: 20 20 28 63 64 72 20 61 6c 6c 69 74 65 6d 73 29    (cdr allitems)
36d0: 29 29 0a 09 20 20 20 20 3b 3b 20 28 6c 61 6d 62  ))..    ;; (lamb
36e0: 64 61 20 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b  da (itemdat) ;;;
36f0: 20 28 28 72 69 70 65 6e 65 73 73 20 22 6f 76 65   ((ripeness "ove
3700: 72 72 69 70 65 22 29 20 28 74 65 6d 70 65 72 61  rripe") (tempera
3710: 74 75 72 65 20 22 63 6f 6f 6c 22 29 20 28 73 65  ture "cool") (se
3720: 61 73 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a  ason "summer")).
3730: 09 20 20 20 20 3b 3b 20 48 61 6e 64 6c 65 20 6c  .    ;; Handle l
3740: 69 73 74 73 20 6f 66 20 69 74 65 6d 73 0a 09 20  ists of items.. 
3750: 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d     (let* ((item-
3760: 70 61 74 68 20 20 20 20 20 28 69 74 65 6d 2d 6c  path     (item-l
3770: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
3780: 74 29 29 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69  t)) ;; (string-i
3790: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
37a0: 63 61 64 72 20 69 74 65 6d 64 61 74 29 20 22 2f  cadr itemdat) "/
37b0: 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65  "))...   (new-te
37c0: 73 74 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d  st-path (string-
37d0: 69 6e 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e  intersperse (con
37e0: 73 20 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70  s test-path (map
37f0: 20 63 61 64 72 20 69 74 65 6d 64 61 74 29 29 20   cadr itemdat)) 
3800: 22 2f 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d  "/"))...   (new-
3810: 74 65 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65  test-name (if (e
3820: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
3830: 22 22 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63  "") test-name (c
3840: 6f 6e 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f  onc test-name "/
3850: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b  " item-path))) ;
3860: 3b 20 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74  ; just need it t
3870: 6f 20 62 65 20 75 6e 69 71 75 65 0a 09 09 20 20  o be unique...  
3880: 20 28 74 65 73 74 64 61 74 20 20 20 23 66 29 0a   (testdat   #f).
3890: 09 09 20 20 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e  ..   (num-runnin
38a0: 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d  g (db:get-count-
38b0: 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62  tests-running db
38c0: 29 29 0a 09 09 20 20 20 28 6d 61 78 2d 63 6f 6e  ))...   (max-con
38d0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f  current-jobs (co
38e0: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e  nfig-lookup *con
38f0: 66 69 67 64 61 74 2a 20 22 73 65 74 75 70 22 20  figdat* "setup" 
3900: 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f  "max_concurrent_
3910: 6a 6f 62 73 22 29 29 0a 09 09 20 20 20 28 70 61  jobs"))...   (pa
3920: 72 65 6e 74 2d 74 65 73 74 20 28 61 6e 64 20 28  rent-test (and (
3930: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73  not (null? items
3940: 29 29 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70  ))(equal? item-p
3950: 61 74 68 20 22 22 29 29 29 0a 09 09 20 20 20 28  ath "")))...   (
3960: 73 69 6e 67 6c 65 2d 74 65 73 74 20 28 61 6e 64  single-test (and
3970: 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 20 28   (null? items) (
3980: 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68  equal? item-path
3990: 20 22 22 29 29 29 0a 09 09 20 20 20 28 69 74 65   "")))...   (ite
39a0: 6d 2d 74 65 73 74 20 20 20 28 6e 6f 74 20 28 65  m-test   (not (e
39b0: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
39c0: 22 22 29 29 29 29 0a 09 20 20 20 20 20 20 28 64  ""))))..      (d
39d0: 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22 6d 61  ebug:print 3 "ma
39e0: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
39f0: 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72  s: " max-concurr
3a00: 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d  ent-jobs ", num-
3a10: 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72  running: " num-r
3a20: 75 6e 6e 69 6e 67 29 0a 09 20 20 20 20 20 20 28  unning)..      (
3a30: 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e  if (runs:can-run
3a40: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a  -more-tests db).
3a50: 09 09 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20  ..  (begin...   
3a60: 20 28 6c 65 74 20 6c 6f 6f 70 32 20 28 28 74 73   (let loop2 ((ts
3a70: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
3a80: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
3a90: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
3aa0: 29 29 20 3b 3b 20 23 66 29 0a 09 09 09 09 28 63  )) ;; #f).....(c
3ab0: 74 20 30 29 29 0a 09 09 20 20 20 20 20 20 28 69  t 0))...      (i
3ac0: 66 20 28 61 6e 64 20 28 6e 6f 74 20 74 73 29 0a  f (and (not ts).
3ad0: 09 09 09 20 20 20 20 20 20 20 28 3c 20 63 74 20  ...       (< ct 
3ae0: 31 30 29 29 0a 09 09 09 20 20 28 62 65 67 69 6e  10))....  (begin
3af0: 0a 09 09 09 20 20 20 20 28 72 65 67 69 73 74 65  ....    (registe
3b00: 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64  r-test db run-id
3b10: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
3b20: 70 61 74 68 29 0a 09 09 09 20 20 20 20 28 64 62  path)....    (db
3b30: 3a 74 65 73 74 2d 73 65 74 2d 63 6f 6d 6d 65 6e  :test-set-commen
3b40: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
3b50: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 20  -name item-path 
3b60: 22 22 29 0a 09 09 09 20 20 20 20 28 6c 6f 6f 70  "")....    (loop
3b70: 32 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  2 (db:get-test-i
3b80: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
3b90: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
3ba0: 68 29 0a 09 09 09 09 20 20 20 28 2b 20 63 74 20  h).....   (+ ct 
3bb0: 31 29 29 29 0a 09 09 09 20 20 28 69 66 20 74 73  1)))....  (if ts
3bc0: 0a 09 09 09 20 20 20 20 20 20 28 73 65 74 21 20  ....      (set! 
3bd0: 74 65 73 74 64 61 74 20 74 73 29 0a 09 09 09 20  testdat ts).... 
3be0: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09       (begin.....
3bf0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
3c00: 57 41 52 4e 49 4e 47 3a 20 43 6f 75 6c 64 6e 27  WARNING: Couldn'
3c10: 74 20 72 65 67 69 73 74 65 72 20 74 65 73 74 20  t register test 
3c20: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 77 69  " test-name " wi
3c30: 74 68 20 69 74 65 6d 20 70 61 74 68 20 22 20 69  th item path " i
3c40: 74 65 6d 2d 70 61 74 68 20 22 2c 20 73 6b 69 70  tem-path ", skip
3c50: 70 69 6e 67 22 29 0a 09 09 09 09 28 69 66 20 28  ping").....(if (
3c60: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29  not (null? tal))
3c70: 0a 09 09 09 09 20 20 20 20 28 6c 6f 6f 70 20 28  .....    (loop (
3c80: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
3c90: 29 29 29 29 29 29 29 0a 09 09 20 20 20 20 28 63  )))))))...    (c
3ca0: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20  hange-directory 
3cb0: 74 65 73 74 2d 70 61 74 68 29 0a 09 09 20 20 20  test-path)...   
3cc0: 20 3b 3b 20 74 68 69 73 20 62 6c 6f 63 6b 20 69   ;; this block i
3cd0: 73 20 68 65 72 65 20 6f 6e 6c 79 20 74 6f 20 69  s here only to i
3ce0: 6e 66 6f 72 6d 20 74 68 65 20 75 73 65 72 20 65  nform the user e
3cf0: 61 72 6c 79 20 6f 6e 0a 09 09 20 20 20 20 28 69  arly on...    (i
3d00: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
3d10: 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09 09 28  runconfigf)....(
3d20: 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c  setup-env-defaul
3d30: 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69 67 66  ts db runconfigf
3d40: 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79   run-id *already
3d50: 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d  -seen-runconfig-
3d60: 69 6e 66 6f 2a 29 0a 09 09 09 28 64 65 62 75 67  info*)....(debug
3d70: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
3d80: 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61  G: You do not ha
3d90: 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 69 67 20  ve a run config 
3da0: 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f 6e 66 69  file: " runconfi
3db0: 67 66 29 29 0a 09 09 20 20 20 20 28 64 65 62 75  gf))...    (debu
3dc0: 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69  g:print 4 "run-i
3dd0: 64 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65  d: " run-id " te
3de0: 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d  st-name: " test-
3df0: 6e 61 6d 65 20 22 20 69 74 65 6d 2d 70 61 74 68  name " item-path
3e00: 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20  : " item-path " 
3e10: 74 65 73 74 64 61 74 3a 20 22 20 28 74 65 73 74  testdat: " (test
3e20: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
3e30: 64 61 74 29 20 22 20 74 65 73 74 2d 73 74 61 74  dat) " test-stat
3e40: 65 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  e: " (test:get-s
3e50: 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09  tate testdat))..
3e60: 09 20 20 20 20 28 63 61 73 65 20 28 69 66 20 28  .    (case (if (
3e70: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66  args:get-arg "-f
3e80: 6f 72 63 65 22 29 0a 09 09 09 20 20 20 20 20 20  orce")....      
3e90: 27 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 09  'NOT_STARTED....
3ea0: 20 20 20 20 20 20 28 69 66 20 74 65 73 74 64 61        (if testda
3eb0: 74 0a 09 09 09 09 20 20 28 73 74 72 69 6e 67 2d  t.....  (string-
3ec0: 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65  >symbol (test:ge
3ed0: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
3ee0: 29 0a 09 09 09 09 20 20 27 66 61 69 6c 65 64 2d  ).....  'failed-
3ef0: 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09 09 20 20  to-insert))...  
3f00: 20 20 20 20 28 28 66 61 69 6c 65 64 2d 74 6f 2d      ((failed-to-
3f10: 69 6e 73 65 72 74 29 0a 09 09 20 20 20 20 20 20  insert)...      
3f20: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
3f30: 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74  "ERROR: Failed t
3f40: 6f 20 69 6e 73 65 72 74 20 74 68 65 20 72 65 63  o insert the rec
3f50: 6f 72 64 20 69 6e 74 6f 20 74 68 65 20 64 62 22  ord into the db"
3f60: 29 29 0a 09 09 20 20 20 20 20 20 28 28 4e 4f 54  ))...      ((NOT
3f70: 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54  _STARTED COMPLET
3f80: 45 44 29 0a 09 09 20 20 20 20 20 20 20 28 64 65  ED)...       (de
3f90: 62 75 67 3a 70 72 69 6e 74 20 36 20 22 47 6f 74  bug:print 6 "Got
3fa0: 20 68 65 72 65 2c 20 22 20 28 74 65 73 74 3a 67   here, " (test:g
3fb0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
3fc0: 29 29 0a 09 09 20 20 20 20 20 20 20 28 6c 65 74  ))...       (let
3fd0: 20 28 28 72 75 6e 66 6c 61 67 20 23 66 29 29 0a   ((runflag #f)).
3fe0: 09 09 09 20 28 63 6f 6e 64 0a 09 09 09 20 20 3b  ... (cond....  ;
3ff0: 3b 20 69 2e 65 2e 20 74 68 69 73 20 69 73 20 74  ; i.e. this is t
4000: 68 65 20 70 61 72 65 6e 74 20 74 65 73 74 20 74  he parent test t
4010: 6f 20 61 20 73 75 69 74 65 20 6f 66 20 69 74 65  o a suite of ite
4020: 6d 73 2c 20 6e 65 76 65 72 20 22 72 75 6e 22 20  ms, never "run" 
4030: 69 74 0a 09 09 09 20 20 28 70 61 72 65 6e 74 2d  it....  (parent-
4040: 74 65 73 74 0a 09 09 09 20 20 20 28 73 65 74 21  test....   (set!
4050: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09   runflag #f))...
4060: 09 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75  .  ;; -force, ru
4070: 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74  n no matter what
4080: 0a 09 09 09 20 20 28 28 61 72 67 73 3a 67 65 74  ....  ((args:get
4090: 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29 28 73  -arg "-force")(s
40a0: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29  et! runflag #t))
40b0: 0a 09 09 09 20 20 3b 3b 20 4e 4f 54 5f 53 54 41  ....  ;; NOT_STA
40c0: 52 54 45 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74  RTED, run no mat
40d0: 74 65 72 20 77 68 61 74 0a 09 09 09 20 20 28 28  ter what....  ((
40e0: 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74  equal? (test:get
40f0: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20  -state testdat) 
4100: 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 29 28 73  "NOT_STARTED")(s
4110: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29  et! runflag #t))
4120: 0a 09 09 09 20 20 3b 3b 20 6e 6f 74 20 2d 72 65  ....  ;; not -re
4130: 72 75 6e 20 61 6e 64 20 50 41 53 53 2c 20 57 41  run and PASS, WA
4140: 52 4e 20 6f 72 20 43 48 45 43 4b 2c 20 64 6f 20  RN or CHECK, do 
4150: 6e 6f 20 72 75 6e 0a 09 09 09 20 20 28 28 61 6e  no run....  ((an
4160: 64 20 28 6f 72 20 28 6e 6f 74 20 28 61 72 67 73  d (or (not (args
4170: 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e  :get-arg "-rerun
4180: 22 29 29 0a 09 09 09 09 20 20 20 20 28 61 72 67  ")).....    (arg
4190: 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70  s:get-arg "-keep
41a0: 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 28 6d 65  going")).....(me
41b0: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
41c0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27  tatus testdat) '
41d0: 28 22 50 41 53 53 22 20 22 57 41 52 4e 22 20 22  ("PASS" "WARN" "
41e0: 43 48 45 43 4b 22 29 29 29 0a 09 09 09 20 20 20  CHECK")))....   
41f0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66  (set! runflag #f
4200: 29 29 0a 09 09 09 20 20 3b 3b 20 2d 72 65 72 75  ))....  ;; -reru
4210: 6e 20 61 6e 64 20 73 74 61 74 75 73 20 69 73 20  n and status is 
4220: 6f 6e 65 20 6f 66 20 74 68 65 20 73 70 65 63 69  one of the speci
4230: 66 65 64 2c 20 72 75 6e 20 69 74 0a 09 09 09 20  fed, run it.... 
4240: 20 28 28 61 6e 64 20 28 61 72 67 73 3a 67 65 74   ((and (args:get
4250: 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29 0a 09  -arg "-rerun")..
4260: 09 09 09 28 6c 65 74 20 28 28 72 65 72 75 6e 6c  ...(let ((rerunl
4270: 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  st (string-split
4280: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
4290: 2d 72 65 72 75 6e 22 29 20 22 2c 22 29 29 29 20  -rerun") ","))) 
42a0: 3b 3b 20 46 41 49 4c 2c 0a 09 09 09 09 20 20 28  ;; FAIL,.....  (
42b0: 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74  member (test:get
42c0: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
42d0: 20 72 65 72 75 6e 6c 73 74 29 29 29 0a 09 09 09   rerunlst)))....
42e0: 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67     (set! runflag
42f0: 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 2d 6b   #t))....  ;; -k
4300: 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74  eepgoing, do not
4310: 20 72 65 72 75 6e 20 46 41 49 4c 0a 09 09 09 20   rerun FAIL.... 
4320: 20 28 28 61 6e 64 20 28 61 72 67 73 3a 67 65 74   ((and (args:get
4330: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67  -arg "-keepgoing
4340: 22 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28  ").....(member (
4350: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
4360: 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c  testdat) '("FAIL
4370: 22 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21  ")))....   (set!
4380: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09   runflag #f))...
4390: 09 20 20 28 28 61 6e 64 20 28 6e 6f 74 20 28 61  .  ((and (not (a
43a0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
43b0: 72 75 6e 22 29 29 0a 09 09 09 09 28 6d 65 6d 62  run")).....(memb
43c0: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
43d0: 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22  tus testdat) '("
43e0: 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09  FAIL" "n/a")))..
43f0: 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c  ..   (set! runfl
4400: 61 67 20 23 74 29 29 0a 09 09 09 20 20 28 65 6c  ag #t))....  (el
4410: 73 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67  se (set! runflag
4420: 20 23 66 29 29 29 0a 09 09 09 20 28 64 65 62 75   #f))).... (debu
4430: 67 3a 70 72 69 6e 74 20 36 20 22 52 55 4e 4e 49  g:print 6 "RUNNI
4440: 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22  NG => runflag: "
4450: 20 72 75 6e 66 6c 61 67 20 22 20 53 54 41 54 45   runflag " STATE
4460: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  : " (test:get-st
4470: 61 74 65 20 74 65 73 74 64 61 74 29 20 22 20 53  ate testdat) " S
4480: 54 41 54 55 53 3a 20 22 20 28 74 65 73 74 3a 67  TATUS: " (test:g
4490: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
44a0: 74 29 29 0a 09 09 09 20 28 69 66 20 28 6e 6f 74  t)).... (if (not
44b0: 20 72 75 6e 66 6c 61 67 29 0a 09 09 09 20 20 20   runflag)....   
44c0: 20 20 28 69 66 20 28 6e 6f 74 20 70 61 72 65 6e    (if (not paren
44d0: 74 2d 74 65 73 74 29 0a 09 09 09 09 20 28 64 65  t-test)..... (de
44e0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54  bug:print 1 "NOT
44f0: 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e 67 20  E: Not starting 
4500: 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d  test " new-test-
4510: 6e 61 6d 65 20 22 20 61 73 20 69 74 20 69 73 20  name " as it is 
4520: 73 74 61 74 65 20 5c 22 43 4f 4d 50 4c 45 54 45  state \"COMPLETE
4530: 44 5c 22 20 61 6e 64 20 73 74 61 74 75 73 20 5c  D\" and status \
4540: 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  "" (test:get-sta
4550: 74 75 73 20 74 65 73 74 64 61 74 29 20 22 5c 22  tus testdat) "\"
4560: 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20  , use -force to 
4570: 6f 76 65 72 72 69 64 65 22 29 29 0a 09 09 09 20  override")).... 
4580: 20 20 20 20 28 6c 65 74 2a 20 28 28 67 65 74 2d      (let* ((get-
4590: 70 72 65 72 65 71 73 2d 63 6d 64 20 28 6c 61 6d  prereqs-cmd (lam
45a0: 62 64 61 20 28 29 0a 09 09 09 09 09 09 20 20 20  bda ().......   
45b0: 20 20 20 20 28 64 62 2d 67 65 74 2d 70 72 65 72      (db-get-prer
45c0: 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62 20 72  eqs-not-met db r
45d0: 75 6e 2d 69 64 20 77 61 69 74 6f 6e 29 29 29 20  un-id waiton))) 
45e0: 3b 3b 20 63 68 65 63 6b 20 62 65 66 6f 72 65 20  ;; check before 
45f0: 72 75 6e 6e 69 6e 67 20 2e 2e 2e 2e 0a 09 09 09  running ........
4600: 09 20 20 20 20 28 6c 61 75 6e 63 68 2d 63 6d 64  .    (launch-cmd
4610: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 29        (lambda ()
4620: 0a 09 09 09 09 09 09 20 20 20 20 20 20 20 28 6c  .......       (l
4630: 61 75 6e 63 68 2d 74 65 73 74 20 64 62 20 72 75  aunch-test db ru
4640: 6e 2d 69 64 20 74 65 73 74 2d 63 6f 6e 66 20 6b  n-id test-conf k
4650: 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d 6e 61  eyvallst test-na
4660: 6d 65 20 74 65 73 74 2d 70 61 74 68 20 69 74 65  me test-path ite
4670: 6d 64 61 74 29 29 29 0a 09 09 09 09 20 20 20 20  mdat))).....    
4680: 28 74 65 73 74 72 75 6e 64 61 74 20 20 20 20 20  (testrundat     
4690: 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65 72 65   (list get-prere
46a0: 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d 63 6d  qs-cmd launch-cm
46b0: 64 29 29 29 0a 09 09 09 20 20 20 20 20 20 20 28  d)))....       (
46c0: 69 66 20 28 6f 72 20 28 61 72 67 73 3a 67 65 74  if (or (args:get
46d0: 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09  -arg "-force")..
46e0: 09 09 09 20 20 20 20 20 20 20 28 6e 75 6c 6c 3f  ...       (null?
46f0: 20 28 28 63 61 72 20 74 65 73 74 72 75 6e 64 61   ((car testrunda
4700: 74 29 29 29 29 20 3b 3b 20 61 72 65 20 74 68 65  t)))) ;; are the
4710: 72 65 20 61 6e 79 20 74 65 73 74 73 20 74 68 61  re any tests tha
4720: 74 20 6d 75 73 74 20 62 65 20 72 75 6e 20 62 65  t must be run be
4730: 66 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e 2e  fore this one...
4740: 0a 09 09 09 09 20 20 20 28 28 63 61 64 72 20 74  .....   ((cadr t
4750: 65 73 74 72 75 6e 64 61 74 29 29 20 3b 3b 20 74  estrundat)) ;; t
4760: 68 69 73 20 69 73 20 74 68 65 20 6c 69 6e 65 20  his is the line 
4770: 74 68 61 74 20 6c 61 75 6e 63 68 65 73 20 74 68  that launches th
4780: 65 20 74 65 73 74 20 74 6f 20 74 68 65 20 72 65  e test to the re
4790: 6d 6f 74 65 20 68 6f 73 74 0a 09 09 09 09 20 20  mote host.....  
47a0: 20 28 69 66 20 28 6e 6f 74 20 28 61 72 67 73 3a   (if (not (args:
47b0: 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f  get-arg "-keepgo
47c0: 69 6e 67 22 29 29 0a 09 09 09 09 20 20 20 20 20  ing")).....     
47d0: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
47e0: 74 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75  t! *waiting-queu
47f0: 65 2a 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65  e* new-test-name
4800: 20 74 65 73 74 72 75 6e 64 61 74 29 29 29 29 29   testrundat)))))
4810: 29 29 0a 09 09 20 20 20 20 20 20 28 28 4b 49 4c  ))...      ((KIL
4820: 4c 45 44 29 20 0a 09 09 20 20 20 20 20 20 20 28  LED) ...       (
4830: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e  debug:print 1 "N
4840: 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d  OTE: " new-test-
4850: 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64  name " is alread
4860: 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73  y running or was
4870: 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65   explictly kille
4880: 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f  d, use -force to
4890: 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09   launch it."))..
48a0: 09 20 20 20 20 20 20 28 28 4c 41 55 4e 43 48 45  .      ((LAUNCHE
48b0: 44 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52  D REMOTEHOSTSTAR
48c0: 54 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20  T RUNNING)  ... 
48d0: 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 2d 20        (if (> (- 
48e0: 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73  (current-seconds
48f0: 29 28 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74  )(+ (db:test-get
4900: 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74  -event_time test
4910: 64 61 74 29 0a 09 09 09 09 09 09 20 20 20 20 20  dat).......     
4920: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e  (db:test-get-run
4930: 5f 64 75 72 61 74 69 6f 6e 20 74 65 73 74 64 61  _duration testda
4940: 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 31 30  t)))....      10
4950: 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70  0) ;; i.e. no up
4960: 64 61 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68  date for more th
4970: 61 6e 20 31 30 30 20 73 65 63 6f 6e 64 73 0a 09  an 100 seconds..
4980: 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20  ..   (begin.... 
4990: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
49a0: 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73   0 "WARNING: Tes
49b0: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  t " test-name " 
49c0: 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 64 65  appears to be de
49d0: 61 64 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74  ad. Forcing it t
49e0: 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45  o state INCOMPLE
49f0: 54 45 20 61 6e 64 20 73 74 61 74 75 73 20 53 54  TE and status ST
4a00: 55 43 4b 2f 44 45 41 44 22 29 0a 09 09 09 20 20  UCK/DEAD")....  
4a10: 20 20 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61     (test-set-sta
4a20: 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74  tus! db run-id t
4a30: 65 73 74 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50  est-name "INCOMP
4a40: 4c 45 54 45 22 20 22 53 54 55 43 4b 2f 44 45 41  LETE" "STUCK/DEA
4a50: 44 22 20 69 74 65 6d 64 61 74 20 22 54 65 73 74  D" itemdat "Test
4a60: 20 69 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61   is stuck or dea
4a70: 64 22 29 29 0a 09 09 09 20 20 20 28 64 65 62 75  d"))....   (debu
4a80: 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a  g:print 2 "NOTE:
4a90: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69   " test-name " i
4aa0: 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e  s already runnin
4ab0: 67 22 29 29 29 0a 09 09 20 20 20 20 20 20 28 65  g")))...      (e
4ac0: 6c 73 65 20 20 20 20 20 20 20 28 64 65 62 75 67  lse       (debug
4ad0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
4ae0: 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63   Failed to launc
4af0: 68 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73  h test " new-tes
4b00: 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f  t-name ". Unreco
4b10: 67 6e 69 73 65 64 20 73 74 61 74 65 20 22 20 28  gnised state " (
4b20: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
4b30: 65 73 74 64 61 74 29 29 29 29 29 29 0a 09 20 20  estdat))))))..  
4b40: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75      (if (not (nu
4b50: 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20 20 28 6c  ll? tal))...  (l
4b60: 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64  oop (car tal)(cd
4b70: 72 20 74 61 6c 29 29 29 29 29 29 29 29 29 0a 0a  r tal)))))))))..
4b80: 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 77 61 69  (define (run-wai
4b90: 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a 20  ting-tests db). 
4ba0: 20 28 6c 65 74 20 28 28 6e 75 6d 74 72 69 65 73   (let ((numtries
4bb0: 20 20 20 20 20 20 20 20 20 20 20 30 29 0a 09 28             0)..(
4bc0: 6c 61 73 74 2d 74 72 79 2d 74 69 6d 65 20 20 20  last-try-time   
4bd0: 20 20 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f     (current-seco
4be0: 6e 64 73 29 29 0a 09 28 74 69 6d 65 73 20 20 20  nds))..(times   
4bf0: 20 20 20 20 20 20 20 20 20 20 20 28 6c 69 73 74             (list
4c00: 20 31 29 29 29 20 3b 3b 20 6d 69 6e 75 74 65 73   1))) ;; minutes
4c10: 20 74 6f 20 77 61 69 74 20 62 65 66 6f 72 65 20   to wait before 
4c20: 74 72 79 69 6e 67 20 61 67 61 69 6e 20 74 6f 20  trying again to 
4c30: 6b 69 63 6b 20 6f 66 66 20 72 75 6e 73 0a 20 20  kick off runs.  
4c40: 20 20 3b 3b 20 42 55 47 20 74 68 69 73 20 68 61    ;; BUG this ha
4c50: 63 6b 20 6f 66 20 62 72 75 74 65 20 66 6f 72 63  ck of brute forc
4c60: 65 20 72 65 74 72 79 69 6e 67 20 77 6f 72 6b 73  e retrying works
4c70: 20 71 75 69 74 65 20 77 65 6c 6c 20 66 6f 72 20   quite well for 
4c80: 6d 61 6e 79 20 63 61 73 65 73 20 62 75 74 20 0a  many cases but .
4c90: 20 20 20 20 3b 3b 20 20 20 20 20 77 68 61 74 20      ;;     what 
4ca0: 69 73 20 6e 65 65 64 65 64 20 69 73 20 74 6f 20  is needed is to 
4cb0: 63 68 65 63 6b 20 74 68 65 20 64 62 20 66 6f 72  check the db for
4cc0: 20 74 65 73 74 73 20 74 68 61 74 20 68 61 76 65   tests that have
4cd0: 20 66 61 69 6c 65 64 20 6c 65 73 73 20 74 68 61   failed less tha
4ce0: 6e 0a 20 20 20 20 3b 3b 20 20 20 20 20 4e 20 74  n.    ;;     N t
4cf0: 69 6d 65 73 20 6f 72 20 6e 65 76 65 72 20 62 65  imes or never be
4d00: 65 6e 20 73 74 61 72 74 65 64 20 61 6e 64 20 6b  en started and k
4d10: 69 63 6b 20 74 68 65 6d 20 6f 66 66 20 61 67 61  ick them off aga
4d20: 69 6e 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70  in.    (let loop
4d30: 20 28 28 77 61 69 74 69 6e 67 2d 74 65 73 74 2d   ((waiting-test-
4d40: 6e 61 6d 65 73 20 28 68 61 73 68 2d 74 61 62 6c  names (hash-tabl
4d50: 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d  e-keys *waiting-
4d60: 71 75 65 75 65 2a 29 29 29 0a 20 20 20 20 20 20  queue*))).      
4d70: 28 63 6f 6e 64 0a 20 20 20 20 20 20 20 28 28 6e  (cond.       ((n
4d80: 6f 74 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e  ot (runs:can-run
4d90: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 29  -more-tests db))
4da0: 0a 09 28 73 6c 65 65 70 20 32 29 0a 09 28 6c 6f  ..(sleep 2)..(lo
4db0: 6f 70 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d  op waiting-test-
4dc0: 6e 61 6d 65 73 29 29 0a 20 20 20 20 20 20 20 28  names)).       (
4dd0: 28 6e 75 6c 6c 3f 20 77 61 69 74 69 6e 67 2d 74  (null? waiting-t
4de0: 65 73 74 2d 6e 61 6d 65 73 29 0a 09 28 64 65 62  est-names)..(deb
4df0: 75 67 3a 70 72 69 6e 74 20 31 20 22 41 6c 6c 20  ug:print 1 "All 
4e00: 74 65 73 74 73 20 6c 61 75 6e 63 68 65 64 22 29  tests launched")
4e10: 29 0a 20 20 20 20 20 20 20 28 65 6c 73 65 0a 09  ).       (else..
4e20: 28 73 65 74 21 20 6e 75 6d 74 72 69 65 73 20 28  (set! numtries (
4e30: 2b 20 6e 75 6d 74 72 69 65 73 20 31 29 29 0a 09  + numtries 1))..
4e40: 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64  (for-each (lambd
4e50: 61 20 28 74 65 73 74 6e 61 6d 65 29 0a 09 09 20  a (testname)... 
4e60: 20 20 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e     (if (runs:can
4e70: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20  -run-more-tests 
4e80: 64 62 29 0a 09 09 09 28 6c 65 74 2a 20 28 28 74  db)....(let* ((t
4e90: 65 73 74 64 61 74 20 28 68 61 73 68 2d 74 61 62  estdat (hash-tab
4ea0: 6c 65 2d 72 65 66 20 2a 77 61 69 74 69 6e 67 2d  le-ref *waiting-
4eb0: 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29  queue* testname)
4ec0: 29 0a 09 09 09 20 20 20 20 20 20 20 28 70 72 65  )....       (pre
4ed0: 72 65 71 73 20 28 28 63 61 72 20 74 65 73 74 64  reqs ((car testd
4ee0: 61 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 20  at)))....       
4ef0: 28 6c 64 62 20 20 20 20 20 28 69 66 20 64 62 20  (ldb     (if db 
4f00: 64 62 20 28 6f 70 65 6e 2d 64 62 29 29 29 29 0a  db (open-db)))).
4f10: 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ...  (debug:prin
4f20: 74 20 32 20 22 70 72 65 72 65 71 73 20 72 65 6d  t 2 "prereqs rem
4f30: 61 69 6e 69 6e 67 3a 20 22 20 70 72 65 72 65 71  aining: " prereq
4f40: 73 29 0a 09 09 09 20 20 28 69 66 20 28 6e 75 6c  s)....  (if (nul
4f50: 6c 3f 20 70 72 65 72 65 71 73 29 0a 09 09 09 20  l? prereqs).... 
4f60: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09       (begin.....
4f70: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
4f80: 50 72 65 72 65 71 75 69 73 69 74 65 73 20 6d 65  Prerequisites me
4f90: 74 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22 20 74  t, launching " t
4fa0: 65 73 74 6e 61 6d 65 29 0a 09 09 09 09 28 28 63  estname).....((c
4fb0: 61 64 72 20 74 65 73 74 64 61 74 29 29 0a 09 09  adr testdat))...
4fc0: 09 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 64 65  ..(hash-table-de
4fd0: 6c 65 74 65 21 20 2a 77 61 69 74 69 6e 67 2d 71  lete! *waiting-q
4fe0: 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29  ueue* testname))
4ff0: 29 0a 09 09 09 20 20 28 69 66 20 28 6e 6f 74 20  )....  (if (not 
5000: 64 62 29 0a 09 09 09 20 20 20 20 20 20 28 73 71  db)....      (sq
5010: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20  lite3:finalize! 
5020: 6c 64 62 29 29 29 29 29 0a 09 09 20 20 77 61 69  ldb)))))...  wai
5030: 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29  ting-test-names)
5040: 0a 09 3b 3b 20 28 73 6c 65 65 70 20 31 30 29 20  ..;; (sleep 10) 
5050: 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e 20 72  ;; no point in r
5060: 75 73 68 69 6e 67 20 74 68 69 6e 67 73 20 61 74  ushing things at
5070: 20 74 68 69 73 20 73 74 61 67 65 3f 0a 09 28 6c   this stage?..(l
5080: 6f 6f 70 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  oop (hash-table-
5090: 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75  keys *waiting-qu
50a0: 65 75 65 2a 29 29 29 29 29 29 29 0a 0a 28 64 65  eue*)))))))..(de
50b0: 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75 70  fine (get-dir-up
50c0: 2d 6f 6e 65 20 64 69 72 29 20 0a 20 20 28 6c 65  -one dir) .  (le
50d0: 74 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72  t ((dparts  (str
50e0: 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22 2f  ing-split dir "/
50f0: 22 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22  "))).    (conc "
5100: 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  /" (string-inter
5110: 73 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20  sperse ..       
5120: 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20  (take dparts (- 
5130: 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20  (length dparts) 
5140: 31 29 29 0a 09 20 20 20 20 20 20 20 22 2f 22 29  1))..       "/")
5150: 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72 75  ))).;; Remove ru
5160: 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72 65  ns.;; fields are
5170: 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72 6f   passing in thro
5180: 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28 72 75  ugh .(define (ru
5190: 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20 64  ns:remove-runs d
51a0: 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74 65  b runnamepatt te
51b0: 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29  stpatt itempatt)
51c0: 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20  .  (let* ((keys 
51d0: 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b         (db-get-k
51e0: 65 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e 64  eys db)).. (rund
51f0: 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65  at      (runs:ge
5200: 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64  t-runs-by-patt d
5210: 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61  b keys runnamepa
5220: 74 74 29 29 0a 09 20 28 68 65 61 64 65 72 20 20  tt)).. (header  
5230: 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20      (vector-ref 
5240: 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72 75  rundat 0)).. (ru
5250: 6e 73 20 20 20 20 20 20 20 20 28 76 65 63 74 6f  ns        (vecto
5260: 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29 29  r-ref rundat 1))
5270: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
5280: 6e 74 20 31 20 22 48 65 61 64 65 72 3a 20 22 20  nt 1 "Header: " 
5290: 68 65 61 64 65 72 29 0a 20 20 20 20 28 66 6f 72  header).    (for
52a0: 2d 65 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62  -each.     (lamb
52b0: 64 61 20 28 72 75 6e 29 0a 20 20 20 20 20 20 20  da (run).       
52c0: 28 6c 65 74 20 28 28 72 75 6e 6b 65 79 20 28 73  (let ((runkey (s
52d0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
52e0: 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28  e (map (lambda (
52f0: 6b 29 0a 09 09 09 09 09 09 28 64 62 3a 67 65 74  k).......(db:get
5300: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
5310: 20 72 75 6e 20 68 65 61 64 65 72 20 28 76 65 63   run header (vec
5320: 74 6f 72 2d 72 65 66 20 6b 20 30 29 29 29 20 6b  tor-ref k 0))) k
5330: 65 79 73 29 20 22 2f 22 29 29 29 0a 09 20 28 6c  eys) "/"))).. (l
5340: 65 74 2a 20 28 28 72 75 6e 2d 69 64 20 28 64 62  et* ((run-id (db
5350: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
5360: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
5370: 22 69 64 22 29 20 29 0a 09 09 28 74 65 73 74 73  "id") )...(tests
5380: 20 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d    (db-get-tests-
5390: 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67  for-run db (db:g
53a0: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
53b0: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69  er run header "i
53c0: 64 22 29 20 74 65 73 74 70 61 74 74 20 69 74 65  d") testpatt ite
53d0: 6d 70 61 74 74 29 29 0a 09 09 28 6c 61 73 74 74  mpatt))...(lastt
53e0: 70 61 74 68 20 22 2f 64 6f 65 73 2f 6e 6f 74 2f  path "/does/not/
53f0: 65 78 69 73 74 2f 49 2f 68 6f 70 65 22 29 29 0a  exist/I/hope")).
5400: 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75  .   (if (not (nu
5410: 6c 6c 3f 20 74 65 73 74 73 29 29 0a 09 20 20 20  ll? tests))..   
5420: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 20 28 64      (begin... (d
5430: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65  ebug:print 1 "Re
5440: 6d 6f 76 69 6e 67 20 74 65 73 74 73 20 66 6f 72  moving tests for
5450: 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22   run: " runkey "
5460: 20 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65   " (db:get-value
5470: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
5480: 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29  eader "runname")
5490: 29 0a 09 09 20 28 66 6f 72 2d 65 61 63 68 0a 09  )... (for-each..
54a0: 09 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74  .  (lambda (test
54b0: 29 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70  )...    (debug:p
54c0: 72 69 6e 74 20 31 20 22 20 20 22 20 28 64 62 3a  rint 1 "  " (db:
54d0: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
54e0: 65 20 74 65 73 74 29 20 22 20 69 64 3a 20 22 20  e test) " id: " 
54f0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
5500: 74 65 73 74 29 20 22 20 22 20 28 64 62 3a 74 65  test) " " (db:te
5510: 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68  st-get-item-path
5520: 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 28 64   test))...    (d
5530: 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65  b:delete-test-re
5540: 63 6f 72 64 73 20 64 62 20 28 64 62 3a 74 65 73  cords db (db:tes
5550: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a  t-get-id test)).
5560: 09 09 20 20 20 20 28 69 66 20 28 3e 20 28 73 74  ..    (if (> (st
5570: 72 69 6e 67 2d 6c 65 6e 67 74 68 20 28 64 62 3a  ring-length (db:
5580: 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20  test-get-rundir 
5590: 74 65 73 74 29 29 20 35 29 20 3b 3b 20 62 61 64  test)) 5) ;; bad
55a0: 20 68 65 75 72 69 73 74 69 63 20 62 75 74 20 73   heuristic but s
55b0: 68 6f 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74  hould prevent /t
55c0: 6d 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09  mp /home etc....
55d0: 09 28 6c 65 74 20 28 28 66 75 6c 6c 70 61 74 68  .(let ((fullpath
55e0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75   (db:test-get-ru
55f0: 6e 64 69 72 20 74 65 73 74 29 29 29 20 3b 3b 20  ndir test))) ;; 
5600: 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  "/" (db:test-get
5610: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29  -item-path test)
5620: 29 29 29 0a 09 09 09 20 20 28 73 65 74 21 20 6c  )))....  (set! l
5630: 61 73 74 74 70 61 74 68 20 66 75 6c 6c 70 61 74  asttpath fullpat
5640: 68 29 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70  h)....  (debug:p
5650: 72 69 6e 74 20 31 20 22 72 6d 20 2d 72 66 20 22  rint 1 "rm -rf "
5660: 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20   fullpath)....  
5670: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72  (system (conc "r
5680: 6d 20 2d 72 66 20 22 20 66 75 6c 6c 70 61 74 68  m -rf " fullpath
5690: 29 29 0a 09 09 09 20 20 28 6c 65 74 20 28 28 63  ))....  (let ((c
56a0: 6d 64 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 20  md (conc "rmdir 
56b0: 2d 70 20 22 20 28 67 65 74 2d 64 69 72 2d 75 70  -p " (get-dir-up
56c0: 2d 6f 6e 65 20 66 75 6c 6c 70 61 74 68 29 29 29  -one fullpath)))
56d0: 29 0a 09 09 09 20 20 20 20 28 64 65 62 75 67 3a  )....    (debug:
56e0: 70 72 69 6e 74 20 31 20 63 6d 64 29 0a 09 09 09  print 1 cmd)....
56f0: 20 20 20 20 28 73 79 73 74 65 6d 20 63 6d 64 29      (system cmd)
5700: 29 0a 09 09 09 20 20 29 29 29 0a 09 09 20 20 74  )....  )))...  t
5710: 65 73 74 73 29 29 29 0a 09 20 20 20 28 6c 65 74  ests)))..   (let
5720: 20 28 28 72 65 6d 74 65 73 74 73 20 28 64 62 2d   ((remtests (db-
5730: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75  get-tests-for-ru
5740: 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61 6c  n db (db:get-val
5750: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
5760: 20 68 65 61 64 65 72 20 22 69 64 22 29 29 29 29   header "id"))))
5770: 0a 09 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c  ..     (if (null
5780: 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e  ? remtests) ;; n
5790: 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d  o more tests rem
57a0: 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a 20  aining... (let* 
57b0: 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69 6e  ((dparts  (strin
57c0: 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70 61 74  g-split lasttpat
57d0: 68 20 22 2f 22 29 29 0a 09 09 09 28 72 75 6e 70  h "/"))....(runp
57e0: 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28 73  ath (conc "/" (s
57f0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
5800: 65 20 0a 09 09 09 09 09 20 20 20 20 28 74 61 6b  e ......    (tak
5810: 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e  e dparts (- (len
5820: 67 74 68 20 64 70 61 72 74 73 29 20 31 29 29 0a  gth dparts) 1)).
5830: 09 09 09 09 09 20 20 20 20 22 2f 22 29 29 29 29  .....    "/"))))
5840: 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69  ...   (debug:pri
5850: 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72  nt 1 "Removing r
5860: 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22  un: " runkey " "
5870: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
5880: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
5890: 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a  der "runname")).
58a0: 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  ..   (db:delete-
58b0: 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09  run db run-id)..
58c0: 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66  .   ;; need to f
58d0: 69 67 75 72 65 20 6f 75 74 20 74 68 65 20 70 61  igure out the pa
58e0: 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69  th to the run di
58f0: 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20  r and remove it 
5900: 69 66 20 65 6d 70 74 79 0a 09 09 3b 3b 20 20 20  if empty...;;   
5910: 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67 6c 6f   (if (null? (glo
5920: 62 20 28 63 6f 6e 63 20 72 75 6e 70 61 74 68 20  b (conc runpath 
5930: 22 2f 2a 22 29 29 29 0a 09 09 3b 3b 20 20 20 20  "/*")))...;;    
5940: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 3b 3b 20      (begin...;; 
5950: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31  . (debug:print 1
5960: 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20 64   "Removing run d
5970: 69 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09 09  ir " runpath)...
5980: 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 28 63 6f  ;; . (system (co
5990: 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 22 20 72  nc "rmdir -p " r
59a0: 75 6e 70 61 74 68 29 29 29 29 0a 09 09 20 20 20  unpath))))...   
59b0: 29 29 29 0a 09 09 20 29 29 29 0a 20 20 20 20 20  )))... ))).     
59c0: 72 75 6e 73 29 29 29 0a 0a                       runs)))..