Megatest

Hex Artifact Content
Login

Artifact d8685b31e4153dbc40def8454bc2d6ccb559db6f:


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 20 74 61 67 73 29 0a 20 20 28 6c  -path tags).  (l
0c50: 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 73 20  et ((item-paths 
0c60: 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65 6d  (if (equal? item
0c70: 2d 70 61 74 68 20 22 22 29 0a 09 09 09 28 6c 69  -path "")....(li
0c80: 73 74 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09  st item-path)...
0c90: 09 28 6c 69 73 74 20 69 74 65 6d 2d 70 61 74 68  .(list item-path
0ca0: 20 22 22 29 29 29 29 0a 20 20 20 20 28 66 6f 72   "")))).    (for
0cb0: 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d  -each .     (lam
0cc0: 62 64 61 20 28 70 74 68 29 0a 20 20 20 20 20 20  bda (pth).      
0cd0: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74   (sqlite3:execut
0ce0: 65 20 64 62 20 22 49 4e 53 45 52 54 20 4f 52 20  e db "INSERT OR 
0cf0: 49 47 4e 4f 52 45 20 49 4e 54 4f 20 74 65 73 74  IGNORE INTO test
0d00: 73 20 28 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61  s (run_id,testna
0d10: 6d 65 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 69 74  me,event_time,it
0d20: 65 6d 5f 70 61 74 68 2c 73 74 61 74 65 2c 73 74  em_path,state,st
0d30: 61 74 75 73 2c 74 61 67 73 29 20 56 41 4c 55 45  atus,tags) VALUE
0d40: 53 20 28 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28  S (?,?,strftime(
0d50: 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 2c 27 4e  '%s','now'),?,'N
0d60: 4f 54 5f 53 54 41 52 54 45 44 27 2c 27 6e 2f 61  OT_STARTED','n/a
0d70: 27 2c 3f 29 3b 22 20 0a 09 09 09 72 75 6e 2d 69  ',?);" ....run-i
0d80: 64 20 0a 09 09 09 74 65 73 74 2d 6e 61 6d 65 0a  d ....test-name.
0d90: 09 09 09 70 74 68 20 0a 09 09 09 28 63 6f 6e 63  ...pth ....(conc
0da0: 20 22 2c 22 20 28 73 74 72 69 6e 67 2d 69 6e 74   "," (string-int
0db0: 65 72 73 70 65 72 73 65 20 74 61 67 73 20 22 2c  ersperse tags ",
0dc0: 22 29 20 22 2c 22 29 29 29 0a 20 20 20 20 20 69  ") ","))).     i
0dd0: 74 65 6d 2d 70 61 74 68 73 20 29 29 29 0a 0a 3b  tem-paths )))..;
0de0: 3b 20 20 28 64 65 66 69 6e 65 20 64 62 20 28 6f  ;  (define db (o
0df0: 70 65 6e 2d 64 62 29 29 0a 3b 3b 20 20 28 74 65  pen-db)).;;  (te
0e00: 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64  st-set-status! d
0e10: 62 20 32 20 22 72 75 6e 66 69 72 73 74 22 20 22  b 2 "runfirst" "
0e20: 43 4f 4d 50 4c 45 54 45 44 22 20 22 50 41 53 53  COMPLETED" "PASS
0e30: 22 20 22 73 75 6d 6d 65 72 22 29 0a 0a 28 64 65  " "summer")..(de
0e40: 66 69 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 73  fine (test-set-s
0e50: 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64  tatus! db run-id
0e60: 20 74 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65   test-name state
0e70: 20 73 74 61 74 75 73 20 69 74 65 6d 64 61 74 2d   status itemdat-
0e80: 6f 72 2d 70 61 74 68 20 2e 20 63 6f 6d 6d 65 6e  or-path . commen
0e90: 74 29 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d  t).  (let ((item
0ea0: 2d 70 61 74 68 20 28 69 66 20 28 73 74 72 69 6e  -path (if (strin
0eb0: 67 3f 20 69 74 65 6d 64 61 74 2d 6f 72 2d 70 61  g? itemdat-or-pa
0ec0: 74 68 29 20 69 74 65 6d 64 61 74 2d 6f 72 2d 70  th) itemdat-or-p
0ed0: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
0ee0: 70 61 74 68 20 69 74 65 6d 64 61 74 2d 6f 72 2d  path itemdat-or-
0ef0: 70 61 74 68 29 29 29 29 0a 20 20 20 20 28 73 71  path)))).    (sq
0f00: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
0f10: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53   "UPDATE tests S
0f20: 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 61 74 75  ET state=?,statu
0f30: 73 3d 3f 2c 65 76 65 6e 74 5f 74 69 6d 65 3d 73  s=?,event_time=s
0f40: 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f  trftime('%s','no
0f50: 77 27 29 20 57 48 45 52 45 20 72 75 6e 5f 69 64  w') WHERE run_id
0f60: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
0f70: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
0f80: 3f 3b 22 20 0a 09 09 20 20 20 20 20 73 74 61 74  ?;" ...     stat
0f90: 65 20 73 74 61 74 75 73 20 72 75 6e 2d 69 64 20  e status run-id 
0fa0: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
0fb0: 61 74 68 29 0a 20 20 20 20 28 69 66 20 28 61 6e  ath).    (if (an
0fc0: 64 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 69  d (not (equal? i
0fd0: 74 65 6d 2d 70 61 74 68 20 22 22 29 29 20 3b 3b  tem-path "")) ;;
0fe0: 20 6e 65 65 64 20 74 6f 20 75 70 64 61 74 65 20   need to update 
0ff0: 74 68 65 20 74 6f 70 20 74 65 73 74 20 72 65 63  the top test rec
1000: 6f 72 64 20 69 66 20 50 41 53 53 20 6f 72 20 46  ord if PASS or F
1010: 41 49 4c 20 61 6e 64 20 74 68 69 73 20 69 73 20  AIL and this is 
1020: 61 20 73 75 62 74 65 73 74 0a 09 20 20 20 20 20  a subtest..     
1030: 28 6f 72 20 28 65 71 75 61 6c 3f 20 73 74 61 74  (or (equal? stat
1040: 75 73 20 22 50 41 53 53 22 29 0a 09 09 20 28 65  us "PASS")... (e
1050: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 57 41  qual? status "WA
1060: 52 4e 22 29 0a 09 09 20 28 65 71 75 61 6c 3f 20  RN")... (equal? 
1070: 73 74 61 74 75 73 20 22 46 41 49 4c 22 29 29 29  status "FAIL")))
1080: 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 73 71 6c  ..(begin..  (sql
1090: 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20  ite3:execute .. 
10a0: 20 20 64 62 0a 09 20 20 20 22 55 50 44 41 54 45    db..   "UPDATE
10b0: 20 74 65 73 74 73 20 0a 20 20 20 20 20 20 20 20   tests .        
10c0: 20 20 20 20 20 53 45 54 20 66 61 69 6c 5f 63 6f       SET fail_co
10d0: 75 6e 74 3d 28 53 45 4c 45 43 54 20 63 6f 75 6e  unt=(SELECT coun
10e0: 74 28 69 64 29 20 46 52 4f 4d 20 74 65 73 74 73  t(id) FROM tests
10f0: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
1100: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
1110: 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 21 3d 20  ND item_path != 
1120: 27 27 20 41 4e 44 20 73 74 61 74 75 73 3d 27 46  '' AND status='F
1130: 41 49 4c 27 29 2c 0a 20 20 20 20 20 20 20 20 20  AIL'),.         
1140: 20 20 20 20 20 20 20 20 70 61 73 73 5f 63 6f 75          pass_cou
1150: 6e 74 3d 28 53 45 4c 45 43 54 20 63 6f 75 6e 74  nt=(SELECT count
1160: 28 69 64 29 20 46 52 4f 4d 20 74 65 73 74 73 20  (id) FROM tests 
1170: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
1180: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
1190: 44 20 69 74 65 6d 5f 70 61 74 68 20 21 3d 20 27  D item_path != '
11a0: 27 20 41 4e 44 20 28 73 74 61 74 75 73 3d 27 50  ' AND (status='P
11b0: 41 53 53 27 20 4f 52 20 73 74 61 74 75 73 3d 27  ASS' OR status='
11c0: 57 41 52 4e 27 29 29 0a 20 20 20 20 20 20 20 20  WARN')).        
11d0: 20 20 20 20 20 57 48 45 52 45 20 72 75 6e 5f 69       WHERE run_i
11e0: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
11f0: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
1200: 3d 27 27 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64  ='';"..   run-id
1210: 20 74 65 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69   test-name run-i
1220: 64 20 74 65 73 74 2d 6e 61 6d 65 20 72 75 6e 2d  d test-name run-
1230: 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20  id test-name).. 
1240: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74   (sqlite3:execut
1250: 65 0a 09 20 20 20 64 62 0a 09 20 20 20 22 55 50  e..   db..   "UP
1260: 44 41 54 45 20 74 65 73 74 73 0a 20 20 20 20 20  DATE tests.     
1270: 20 20 20 20 20 20 20 20 53 45 54 20 73 74 61 74          SET stat
1280: 65 3d 43 41 53 45 20 57 48 45 4e 20 28 53 45 4c  e=CASE WHEN (SEL
1290: 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52  ECT count(id) FR
12a0: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
12b0: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
12c0: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
12d0: 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20 73  path != '' AND s
12e0: 74 61 74 65 20 69 6e 20 28 27 52 55 4e 4e 49 4e  tate in ('RUNNIN
12f0: 47 27 2c 27 4e 4f 54 5f 53 54 41 52 54 45 44 27  G','NOT_STARTED'
1300: 29 29 20 3e 20 30 20 54 48 45 4e 20 0a 20 20 20  )) > 0 THEN .   
1310: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1320: 20 20 20 20 20 20 20 27 52 55 4e 4e 49 4e 47 27         'RUNNING'
1330: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
1340: 20 20 20 20 20 20 20 20 45 4c 53 45 20 27 43 4f          ELSE 'CO
1350: 4d 50 4c 45 54 45 44 27 20 45 4e 44 2c 0a 20 20  MPLETED' END,.  
1360: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74                st
1370: 61 74 75 73 3d 43 41 53 45 20 57 48 45 4e 20 66  atus=CASE WHEN f
1380: 61 69 6c 5f 63 6f 75 6e 74 20 3e 20 30 20 54 48  ail_count > 0 TH
1390: 45 4e 20 27 46 41 49 4c 27 20 57 48 45 4e 20 70  EN 'FAIL' WHEN p
13a0: 61 73 73 5f 63 6f 75 6e 74 20 3e 20 30 20 41 4e  ass_count > 0 AN
13b0: 44 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 30 20 54  D fail_count=0 T
13c0: 48 45 4e 20 27 50 41 53 53 27 20 45 4c 53 45 20  HEN 'PASS' ELSE 
13d0: 27 55 4e 4b 4e 4f 57 4e 27 20 45 4e 44 0a 20 20  'UNKNOWN' END.  
13e0: 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52 45             WHERE
13f0: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
1400: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
1410: 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20 20  m_path='';"..   
1420: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
1430: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1440: 65 29 29 29 0a 20 20 20 20 28 69 66 20 28 61 6e  e))).    (if (an
1450: 64 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 63 6f  d (not (null? co
1460: 6d 6d 65 6e 74 29 29 0a 09 20 20 20 20 20 28 63  mment))..     (c
1470: 61 72 20 63 6f 6d 6d 65 6e 74 29 29 0a 09 28 73  ar comment))..(s
1480: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64  qlite3:execute d
1490: 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20  b "UPDATE tests 
14a0: 53 45 54 20 63 6f 6d 6d 65 6e 74 3d 3f 20 57 48  SET comment=? WH
14b0: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44  ERE run_id=? AND
14c0: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20   testname=? AND 
14d0: 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 09 09  item_path=?;"...
14e0: 09 20 28 63 61 72 20 63 6f 6d 6d 65 6e 74 29 20  . (car comment) 
14f0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
1500: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 29 0a 0a   item-path))))..
1510: 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65  (define (test-se
1520: 74 2d 6c 6f 67 21 20 64 62 20 72 75 6e 2d 69 64  t-log! db run-id
1530: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 64   test-name itemd
1540: 61 74 20 6c 6f 67 66 29 20 0a 20 20 28 6c 65 74  at logf) .  (let
1550: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74   ((item-path (it
1560: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
1570: 65 6d 64 61 74 29 29 29 0a 20 20 20 20 28 73 71  emdat))).    (sq
1580: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
1590: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53   "UPDATE tests S
15a0: 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20  ET final_logf=? 
15b0: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
15c0: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
15d0: 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 20  D item_path=?;" 
15e0: 0a 09 09 20 20 20 20 20 6c 6f 67 66 20 72 75 6e  ...     logf run
15f0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
1600: 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28 64 65 66  em-path)))..(def
1610: 69 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 74 6f  ine (test-set-to
1620: 70 6c 6f 67 21 20 64 62 20 72 75 6e 2d 69 64 20  plog! db run-id 
1630: 74 65 73 74 2d 6e 61 6d 65 20 6c 6f 67 66 29 20  test-name logf) 
1640: 0a 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63  .  (sqlite3:exec
1650: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74  ute db "UPDATE t
1660: 65 73 74 73 20 53 45 54 20 66 69 6e 61 6c 5f 6c  ests SET final_l
1670: 6f 67 66 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f  ogf=? WHERE run_
1680: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
1690: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
16a0: 68 3d 27 27 3b 22 20 0a 09 09 20 20 20 6c 6f 67  h='';" ...   log
16b0: 66 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  f run-id test-na
16c0: 6d 65 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74  me))..(define (t
16d0: 65 73 74 73 3a 73 75 6d 6d 61 72 69 7a 65 2d 69  ests:summarize-i
16e0: 74 65 6d 73 20 64 62 20 72 75 6e 2d 69 64 20 74  tems db run-id t
16f0: 65 73 74 2d 6e 61 6d 65 20 66 6f 72 63 65 29 0a  est-name force).
1700: 20 20 3b 3b 20 69 66 20 6e 6f 74 20 66 6f 72 63    ;; if not forc
1710: 65 20 74 68 65 6e 20 6f 6e 6c 79 20 75 70 64 61  e then only upda
1720: 74 65 20 74 68 65 20 72 65 63 6f 72 64 20 69 66  te the record if
1730: 20 6f 6e 65 20 6f 66 20 74 68 65 73 65 20 69 73   one of these is
1740: 20 74 72 75 65 3a 0a 20 20 3b 3b 20 20 20 31 2e   true:.  ;;   1.
1750: 20 6c 6f 67 66 20 69 73 20 22 6c 6f 67 2f 66 69   logf is "log/fi
1760: 6e 61 6c 2e 6c 6f 67 0a 20 20 3b 3b 20 20 20 32  nal.log.  ;;   2
1770: 2e 20 6c 6f 67 66 20 69 73 20 73 61 6d 65 20 61  . logf is same a
1780: 73 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65  s outputfilename
1790: 0a 20 20 28 6c 65 74 20 28 28 6f 75 74 70 75 74  .  (let ((output
17a0: 66 69 6c 65 6e 61 6d 65 20 28 63 6f 6e 63 20 22  filename (conc "
17b0: 6d 65 67 61 74 65 73 74 2d 72 6f 6c 6c 75 70 2d  megatest-rollup-
17c0: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 2e 68 74  " test-name ".ht
17d0: 6d 6c 22 29 29 0a 09 28 6f 72 69 67 2d 64 69 72  ml"))..(orig-dir
17e0: 20 20 20 20 20 20 20 28 63 75 72 72 65 6e 74 2d         (current-
17f0: 64 69 72 65 63 74 6f 72 79 29 29 0a 09 28 6c 6f  directory))..(lo
1800: 67 66 20 20 20 20 20 20 20 20 20 20 20 23 66 29  gf           #f)
1810: 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66  ).    (sqlite3:f
1820: 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 20 20 20  or-each-row .   
1830: 20 20 28 6c 61 6d 62 64 61 20 28 70 61 74 68 20    (lambda (path 
1840: 66 69 6e 61 6c 5f 6c 6f 67 66 29 0a 20 20 20 20  final_logf).    
1850: 20 20 20 28 73 65 74 21 20 6c 6f 67 66 20 66 69     (set! logf fi
1860: 6e 61 6c 5f 6c 6f 67 66 29 0a 20 20 20 20 20 20  nal_logf).      
1870: 20 28 69 66 20 28 64 69 72 65 63 74 6f 72 79 3f   (if (directory?
1880: 20 70 61 74 68 29 0a 09 20 20 20 28 62 65 67 69   path)..   (begi
1890: 6e 0a 09 20 20 20 20 20 28 70 72 69 6e 74 20 22  n..     (print "
18a0: 46 6f 75 6e 64 20 70 61 74 68 3a 20 22 20 70 61  Found path: " pa
18b0: 74 68 29 0a 09 20 20 20 20 20 28 63 68 61 6e 67  th)..     (chang
18c0: 65 2d 64 69 72 65 63 74 6f 72 79 20 70 61 74 68  e-directory path
18d0: 29 29 0a 09 20 20 20 20 20 3b 3b 20 28 73 65 74  ))..     ;; (set
18e0: 21 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65  ! outputfilename
18f0: 20 28 63 6f 6e 63 20 70 61 74 68 20 22 2f 22 20   (conc path "/" 
1900: 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 29  outputfilename))
1910: 29 0a 09 20 20 20 28 70 72 69 6e 74 20 22 4e 6f  )..   (print "No
1920: 20 73 75 63 68 20 70 61 74 68 3a 20 22 20 70 61   such path: " pa
1930: 74 68 29 29 29 0a 20 20 20 20 20 64 62 20 0a 20  th))).     db . 
1940: 20 20 20 20 22 53 45 4c 45 43 54 20 72 75 6e 64      "SELECT rund
1950: 69 72 2c 66 69 6e 61 6c 5f 6c 6f 67 66 20 46 52  ir,final_logf FR
1960: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
1970: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
1980: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
1990: 70 61 74 68 3d 27 27 3b 22 0a 20 20 20 20 20 72  path='';".     r
19a0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29  un-id test-name)
19b0: 0a 20 20 20 20 28 70 72 69 6e 74 20 22 73 75 6d  .    (print "sum
19c0: 6d 61 72 69 7a 65 2d 69 74 65 6d 73 20 77 69 74  marize-items wit
19d0: 68 20 6c 6f 67 66 20 22 20 6c 6f 67 66 29 0a 20  h logf " logf). 
19e0: 20 20 20 28 69 66 20 28 6f 72 20 28 65 71 75 61     (if (or (equa
19f0: 6c 3f 20 6c 6f 67 66 20 22 6c 6f 67 73 2f 66 69  l? logf "logs/fi
1a00: 6e 61 6c 2e 6c 6f 67 22 29 0a 09 20 20 20 20 28  nal.log")..    (
1a10: 65 71 75 61 6c 3f 20 6c 6f 67 66 20 6f 75 74 70  equal? logf outp
1a20: 75 74 66 69 6c 65 6e 61 6d 65 29 0a 09 20 20 20  utfilename)..   
1a30: 20 66 6f 72 63 65 29 0a 09 28 62 65 67 69 6e 0a   force)..(begin.
1a40: 09 20 20 28 69 66 20 28 6f 62 74 61 69 6e 2d 64  .  (if (obtain-d
1a50: 6f 74 2d 6c 6f 63 6b 20 6f 75 74 70 75 74 66 69  ot-lock outputfi
1a60: 6c 65 6e 61 6d 65 20 31 20 32 30 20 33 30 29 20  lename 1 20 30) 
1a70: 3b 3b 20 72 65 74 72 79 20 65 76 65 72 79 20 73  ;; retry every s
1a80: 65 63 6f 6e 64 20 66 6f 72 20 32 30 20 73 65 63  econd for 20 sec
1a90: 6f 6e 64 73 2c 20 63 61 6c 6c 20 69 74 20 64 65  onds, call it de
1aa0: 61 64 20 61 66 74 65 72 20 33 30 20 73 65 63 6f  ad after 30 seco
1ab0: 6e 64 73 20 61 6e 64 20 73 74 65 61 6c 20 74 68  nds and steal th
1ac0: 65 20 6c 6f 63 6b 0a 09 20 20 20 20 20 20 28 70  e lock..      (p
1ad0: 72 69 6e 74 20 22 4f 62 74 61 69 6e 65 64 20 6c  rint "Obtained l
1ae0: 6f 63 6b 20 66 6f 72 20 22 20 6f 75 74 70 75 74  ock for " output
1af0: 66 69 6c 65 6e 61 6d 65 29 0a 09 20 20 20 20 20  filename)..     
1b00: 20 28 70 72 69 6e 74 20 22 46 61 69 6c 65 64 20   (print "Failed 
1b10: 74 6f 20 6f 62 74 61 69 6e 20 6c 6f 63 6b 20 66  to obtain lock f
1b20: 6f 72 20 22 20 6f 75 74 70 75 74 66 69 6c 65 6e  or " outputfilen
1b30: 61 6d 65 29 29 0a 09 20 20 28 6c 65 74 20 28 28  ame))..  (let ((
1b40: 6f 75 70 20 20 20 20 28 6f 70 65 6e 2d 6f 75 74  oup    (open-out
1b50: 70 75 74 2d 66 69 6c 65 20 6f 75 74 70 75 74 66  put-file outputf
1b60: 69 6c 65 6e 61 6d 65 29 29 0a 09 09 28 63 6f 75  ilename))...(cou
1b70: 6e 74 73 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74  nts (make-hash-t
1b80: 61 62 6c 65 29 29 0a 09 09 28 73 74 61 74 65 63  able))...(statec
1b90: 6f 75 6e 74 73 20 28 6d 61 6b 65 2d 68 61 73 68  ounts (make-hash
1ba0: 2d 74 61 62 6c 65 29 29 0a 09 09 28 6f 75 74 74  -table))...(outt
1bb0: 78 74 20 22 22 29 0a 09 09 28 74 6f 74 20 20 20  xt "")...(tot   
1bc0: 20 30 29 29 0a 09 20 20 20 20 28 77 69 74 68 2d   0))..    (with-
1bd0: 6f 75 74 70 75 74 2d 74 6f 2d 70 6f 72 74 0a 09  output-to-port..
1be0: 09 6f 75 70 0a 09 20 20 20 20 20 20 28 6c 61 6d  .oup..      (lam
1bf0: 62 64 61 20 28 29 0a 09 09 28 73 65 74 21 20 6f  bda ()...(set! o
1c00: 75 74 74 78 74 20 28 63 6f 6e 63 20 6f 75 74 74  uttxt (conc outt
1c10: 78 74 20 22 3c 68 74 6d 6c 3e 3c 74 69 74 6c 65  xt "<html><title
1c20: 3e 53 75 6d 6d 61 72 79 3a 20 22 20 74 65 73 74  >Summary: " test
1c30: 2d 6e 61 6d 65 20 0a 09 09 09 09 20 20 20 22 3c  -name .....   "<
1c40: 2f 74 69 74 6c 65 3e 3c 62 6f 64 79 3e 3c 68 32  /title><body><h2
1c50: 3e 53 75 6d 6d 61 72 79 20 66 6f 72 20 22 20 74  >Summary for " t
1c60: 65 73 74 2d 6e 61 6d 65 20 22 3c 2f 68 32 3e 22  est-name "</h2>"
1c70: 29 29 0a 09 09 28 73 71 6c 69 74 65 33 3a 66 6f  ))...(sqlite3:fo
1c80: 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09 09 20 28  r-each-row ... (
1c90: 6c 61 6d 62 64 61 20 28 69 64 20 69 74 65 6d 70  lambda (id itemp
1ca0: 61 74 68 20 73 74 61 74 65 20 73 74 61 74 75 73  ath state status
1cb0: 20 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 6c 6f   run_duration lo
1cc0: 67 66 20 63 6f 6d 6d 65 6e 74 29 0a 09 09 20 20  gf comment)...  
1cd0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
1ce0: 21 20 63 6f 75 6e 74 73 20 73 74 61 74 75 73 20  ! counts status 
1cf0: 28 2b 20 31 20 28 68 61 73 68 2d 74 61 62 6c 65  (+ 1 (hash-table
1d00: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 63 6f 75  -ref/default cou
1d10: 6e 74 73 20 73 74 61 74 75 73 20 30 29 29 29 0a  nts status 0))).
1d20: 09 09 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  ..   (hash-table
1d30: 2d 73 65 74 21 20 73 74 61 74 65 63 6f 75 6e 74  -set! statecount
1d40: 73 20 73 74 61 74 65 20 28 2b 20 31 20 28 68 61  s state (+ 1 (ha
1d50: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
1d60: 61 75 6c 74 20 73 74 61 74 65 63 6f 75 6e 74 73  ault statecounts
1d70: 20 73 74 61 74 65 20 30 29 29 29 0a 09 09 20 20   state 0)))...  
1d80: 20 28 73 65 74 21 20 6f 75 74 74 78 74 20 28 63   (set! outtxt (c
1d90: 6f 6e 63 20 6f 75 74 74 78 74 20 22 3c 74 72 3e  onc outtxt "<tr>
1da0: 22 0a 09 09 09 09 20 20 20 20 20 20 22 3c 74 64  ".....      "<td
1db0: 3e 3c 61 20 68 72 65 66 3d 5c 22 22 20 69 74 65  ><a href=\"" ite
1dc0: 6d 70 61 74 68 20 22 2f 22 20 6c 6f 67 66 20 22  mpath "/" logf "
1dd0: 5c 22 3e 20 22 20 69 74 65 6d 70 61 74 68 20 22  \"> " itempath "
1de0: 3c 2f 61 3e 3c 2f 74 64 3e 22 20 0a 09 09 09 09  </a></td>" .....
1df0: 20 20 20 20 20 20 22 3c 74 64 3e 22 20 73 74 61        "<td>" sta
1e00: 74 65 20 20 20 20 22 3c 2f 74 64 3e 22 20 0a 09  te    "</td>" ..
1e10: 09 09 09 20 20 20 20 20 20 22 3c 74 64 3e 3c 66  ...      "<td><f
1e20: 6f 6e 74 20 63 6f 6c 6f 72 3d 22 20 28 63 6f 6e  ont color=" (con
1e30: 64 0a 09 09 09 09 09 09 09 20 20 28 28 65 71 75  d........  ((equ
1e40: 61 6c 3f 20 73 74 61 74 75 73 20 22 50 41 53 53  al? status "PASS
1e50: 22 29 20 22 67 72 65 65 6e 22 29 0a 09 09 09 09  ") "green").....
1e60: 09 09 09 20 20 28 28 65 71 75 61 6c 3f 20 73 74  ...  ((equal? st
1e70: 61 74 75 73 20 22 46 41 49 4c 22 29 20 22 72 65  atus "FAIL") "re
1e80: 64 22 29 0a 09 09 09 09 09 09 09 20 20 28 65 6c  d")........  (el
1e90: 73 65 20 22 62 6c 75 65 22 29 29 20 22 3e 22 20  se "blue")) ">" 
1ea0: 20 20 73 74 61 74 75 73 20 20 20 22 3c 2f 66 6f    status   "</fo
1eb0: 6e 74 3e 3c 2f 74 64 3e 22 0a 09 09 09 09 09 09  nt></td>".......
1ec0: 09 20 20 22 3c 74 64 3e 22 20 28 69 66 20 28 65  .  "<td>" (if (e
1ed0: 71 75 61 6c 3f 20 63 6f 6d 6d 65 6e 74 20 22 22  qual? comment ""
1ee0: 29 0a 09 09 09 09 09 09 09 09 20 20 20 20 20 22  ).........     "
1ef0: 26 6e 62 73 70 3b 22 0a 09 09 09 09 09 09 09 09  &nbsp;".........
1f00: 20 20 20 20 20 63 6f 6d 6d 65 6e 74 29 20 22 3c       comment) "<
1f10: 2f 74 64 3e 22 0a 09 09 09 09 09 09 09 20 20 22  /td>"........  "
1f20: 3c 2f 74 72 3e 22 29 29 29 0a 09 09 20 64 62 0a  </tr>")))... db.
1f30: 09 09 20 22 53 45 4c 45 43 54 20 69 64 2c 69 74  .. "SELECT id,it
1f40: 65 6d 5f 70 61 74 68 2c 73 74 61 74 65 2c 73 74  em_path,state,st
1f50: 61 74 75 73 2c 72 75 6e 5f 64 75 72 61 74 69 6f  atus,run_duratio
1f60: 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d  n,final_logf,com
1f70: 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 73 20  ment FROM tests 
1f80: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
1f90: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
1fa0: 44 20 69 74 65 6d 5f 70 61 74 68 20 21 3d 20 27  D item_path != '
1fb0: 27 3b 22 0a 09 09 20 72 75 6e 2d 69 64 20 74 65  ';"... run-id te
1fc0: 73 74 2d 6e 61 6d 65 29 0a 0a 09 09 3b 3b 20 50  st-name)....;; P
1fd0: 72 69 6e 74 20 6f 75 74 20 73 74 61 74 73 20 66  rint out stats f
1fe0: 6f 72 20 73 74 61 74 75 73 0a 09 09 28 73 65 74  or status...(set
1ff0: 21 20 74 6f 74 20 30 29 0a 09 09 28 70 72 69 6e  ! tot 0)...(prin
2000: 74 20 22 3c 68 32 3e 53 74 61 74 65 20 73 74 61  t "<h2>State sta
2010: 74 73 3c 2f 68 32 3e 3c 74 61 62 6c 65 20 63 65  ts</h2><table ce
2020: 6c 6c 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20  llspacing=\"0\" 
2030: 62 6f 72 64 65 72 3d 5c 22 31 5c 22 3e 22 29 0a  border=\"1\">").
2040: 09 09 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d  ..(for-each (lam
2050: 62 64 61 20 28 73 74 61 74 65 29 0a 09 09 09 20  bda (state).... 
2060: 20 20 20 28 73 65 74 21 20 74 6f 74 20 28 2b 20     (set! tot (+ 
2070: 74 6f 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  tot (hash-table-
2080: 72 65 66 20 73 74 61 74 65 63 6f 75 6e 74 73 20  ref statecounts 
2090: 73 74 61 74 65 29 29 29 0a 09 09 09 20 20 20 20  state)))....    
20a0: 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e  (print "<tr><td>
20b0: 22 20 73 74 61 74 65 20 22 3c 2f 74 64 3e 3c 74  " state "</td><t
20c0: 64 3e 22 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  d>" (hash-table-
20d0: 72 65 66 20 73 74 61 74 65 63 6f 75 6e 74 73 20  ref statecounts 
20e0: 73 74 61 74 65 29 20 22 3c 2f 74 64 3e 3c 2f 74  state) "</td></t
20f0: 72 3e 22 29 29 0a 09 09 09 20 20 28 68 61 73 68  r>"))....  (hash
2100: 2d 74 61 62 6c 65 2d 6b 65 79 73 20 73 74 61 74  -table-keys stat
2110: 65 63 6f 75 6e 74 73 29 29 0a 09 09 28 70 72 69  ecounts))...(pri
2120: 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 54 6f 74 61  nt "<tr><td>Tota
2130: 6c 3c 2f 74 64 3e 3c 74 64 3e 22 20 74 6f 74 20  l</td><td>" tot 
2140: 22 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62  "</td></tr></tab
2150: 6c 65 3e 22 29 0a 0a 09 09 3b 3b 20 50 72 69 6e  le>")....;; Prin
2160: 74 20 6f 75 74 20 73 74 61 74 73 20 66 6f 72 20  t out stats for 
2170: 73 74 61 74 65 0a 09 09 28 73 65 74 21 20 74 6f  state...(set! to
2180: 74 20 30 29 0a 09 09 28 70 72 69 6e 74 20 22 3c  t 0)...(print "<
2190: 68 32 3e 53 74 61 74 75 73 20 73 74 61 74 73 3c  h2>Status stats<
21a0: 2f 68 32 3e 3c 74 61 62 6c 65 20 63 65 6c 6c 73  /h2><table cells
21b0: 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f 72  pacing=\"0\" bor
21c0: 64 65 72 3d 5c 22 31 5c 22 3e 22 29 0a 09 09 28  der=\"1\">")...(
21d0: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
21e0: 20 28 73 74 61 74 75 73 29 0a 09 09 09 20 20 20   (status)....   
21f0: 20 28 73 65 74 21 20 74 6f 74 20 28 2b 20 74 6f   (set! tot (+ to
2200: 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  t (hash-table-re
2210: 66 20 63 6f 75 6e 74 73 20 73 74 61 74 75 73 29  f counts status)
2220: 29 29 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74  ))....    (print
2230: 20 22 3c 74 72 3e 3c 74 64 3e 22 20 73 74 61 74   "<tr><td>" stat
2240: 75 73 20 22 3c 2f 74 64 3e 3c 74 64 3e 22 20 28  us "</td><td>" (
2250: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 63  hash-table-ref c
2260: 6f 75 6e 74 73 20 73 74 61 74 75 73 29 20 22 3c  ounts status) "<
2270: 2f 74 64 3e 3c 2f 74 72 3e 22 29 29 0a 09 09 09  /td></tr>"))....
2280: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65    (hash-table-ke
2290: 79 73 20 63 6f 75 6e 74 73 29 29 0a 09 09 28 70  ys counts))...(p
22a0: 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 54 6f  rint "<tr><td>To
22b0: 74 61 6c 3c 2f 74 64 3e 3c 74 64 3e 22 20 74 6f  tal</td><td>" to
22c0: 74 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74  t "</td></tr></t
22d0: 61 62 6c 65 3e 22 29 0a 0a 09 09 28 70 72 69 6e  able>")....(prin
22e0: 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c 73 70  t "<table cellsp
22f0: 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f 72 64  acing=\"0\" bord
2300: 65 72 3d 5c 22 31 5c 22 3e 22 20 0a 09 09 20 20  er=\"1\">" ...  
2310: 20 20 20 20 20 22 3c 74 72 3e 3c 74 64 3e 49 74       "<tr><td>It
2320: 65 6d 3c 2f 74 64 3e 3c 74 64 3e 53 74 61 74 65  em</td><td>State
2330: 3c 2f 74 64 3e 3c 74 64 3e 53 74 61 74 75 73 3c  </td><td>Status<
2340: 2f 74 64 3e 3c 74 64 3e 43 6f 6d 6d 65 6e 74 3c  /td><td>Comment<
2350: 2f 74 64 3e 22 0a 09 09 20 20 20 20 20 20 20 6f  /td>"...       o
2360: 75 74 74 78 74 20 22 3c 2f 74 61 62 6c 65 3e 3c  uttxt "</table><
2370: 2f 62 6f 64 79 3e 3c 2f 68 74 6d 6c 3e 22 29 0a  /body></html>").
2380: 09 09 28 72 65 6c 65 61 73 65 2d 64 6f 74 2d 6c  ..(release-dot-l
2390: 6f 63 6b 20 6f 75 74 70 75 74 66 69 6c 65 6e 61  ock outputfilena
23a0: 6d 65 29 29 29 0a 09 20 20 20 20 28 63 6c 6f 73  me)))..    (clos
23b0: 65 2d 6f 75 74 70 75 74 2d 70 6f 72 74 20 6f 75  e-output-port ou
23c0: 70 29 0a 09 20 20 20 20 28 63 68 61 6e 67 65 2d  p)..    (change-
23d0: 64 69 72 65 63 74 6f 72 79 20 6f 72 69 67 2d 64  directory orig-d
23e0: 69 72 29 0a 09 20 20 20 20 28 74 65 73 74 2d 73  ir)..    (test-s
23f0: 65 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20 72 75  et-toplog! db ru
2400: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6f  n-id test-name o
2410: 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 0a 09  utputfilename)..
2420: 20 20 20 20 29 29 29 29 29 0a 0a 3b 3b 20 3b 3b      )))))..;; ;;
2430: 20 54 4f 44 4f 3a 20 43 6f 6e 76 65 72 67 65 20   TODO: Converge 
2440: 74 68 69 73 20 77 69 74 68 20 64 62 3a 67 65 74  this with db:get
2450: 2d 74 65 73 74 2d 69 6e 66 6f 0a 3b 3b 20 28 64  -test-info.;; (d
2460: 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74 2d  efine (runs:get-
2470: 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e  test-info db run
2480: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
2490: 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20 28 6c  em-path).;;   (l
24a0: 65 74 20 28 28 72 65 73 20 23 66 29 29 20 3b 3b  et ((res #f)) ;;
24b0: 20 28 76 65 63 74 6f 72 20 23 66 20 23 66 20 23   (vector #f #f #
24c0: 66 20 23 66 20 23 66 20 23 66 29 29 29 0a 3b 3b  f #f #f #f))).;;
24d0: 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f       (sqlite3:fo
24e0: 72 2d 65 61 63 68 2d 72 6f 77 20 0a 3b 3b 20 20  r-each-row .;;  
24f0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64 20      (lambda (id 
2500: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
2510: 20 73 74 61 74 65 20 73 74 61 74 75 73 29 0a 3b   state status).;
2520: 3b 20 20 20 20 20 20 20 20 28 73 65 74 21 20 72  ;        (set! r
2530: 65 73 20 28 76 65 63 74 6f 72 20 69 64 20 72 75  es (vector id ru
2540: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 73  n-id test-name s
2550: 74 61 74 65 20 73 74 61 74 75 73 20 69 74 65 6d  tate status item
2560: 2d 70 61 74 68 29 29 29 0a 3b 3b 20 20 20 20 20  -path))).;;     
2570: 20 64 62 20 22 53 45 4c 45 43 54 20 69 64 2c 72   db "SELECT id,r
2580: 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73  un_id,testname,s
2590: 74 61 74 65 2c 73 74 61 74 75 73 20 46 52 4f 4d  tate,status FROM
25a0: 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e   tests WHERE run
25b0: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
25c0: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
25d0: 74 68 3d 3f 3b 22 0a 3b 3b 20 20 20 20 20 20 72  th=?;".;;      r
25e0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
25f0: 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20  item-path).;;   
2600: 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65    res))..(define
2610: 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65  -inline (test:ge
2620: 74 2d 69 64 20 76 65 63 29 20 20 20 20 20 20 20  t-id vec)       
2630: 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20  (vector-ref vec 
2640: 30 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69  0)).(define-inli
2650: 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 72 75 6e  ne (test:get-run
2660: 5f 69 64 20 76 65 63 29 20 20 20 28 76 65 63 74  _id vec)   (vect
2670: 6f 72 2d 72 65 66 20 76 65 63 20 31 29 29 0a 28  or-ref vec 1)).(
2680: 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74  define-inline (t
2690: 65 73 74 3a 67 65 74 2d 74 65 73 74 2d 6e 61 6d  est:get-test-nam
26a0: 65 20 76 65 63 29 28 76 65 63 74 6f 72 2d 72 65  e vec)(vector-re
26b0: 66 20 76 65 63 20 32 29 29 0a 28 64 65 66 69 6e  f vec 2)).(defin
26c0: 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67  e-inline (test:g
26d0: 65 74 2d 73 74 61 74 65 20 76 65 63 29 20 20 20  et-state vec)   
26e0: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63   (vector-ref vec
26f0: 20 33 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c   3)).(define-inl
2700: 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 73 74  ine (test:get-st
2710: 61 74 75 73 20 76 65 63 29 20 20 20 28 76 65 63  atus vec)   (vec
2720: 74 6f 72 2d 72 65 66 20 76 65 63 20 34 29 29 0a  tor-ref vec 4)).
2730: 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28  (define-inline (
2740: 74 65 73 74 3a 67 65 74 2d 69 74 65 6d 2d 70 61  test:get-item-pa
2750: 74 68 20 76 65 63 29 28 76 65 63 74 6f 72 2d 72  th vec)(vector-r
2760: 65 66 20 76 65 63 20 35 29 29 0a 0a 28 64 65 66  ef vec 5))..(def
2770: 69 6e 65 20 28 72 75 6e 73 3a 74 65 73 74 2d 67  ine (runs:test-g
2780: 65 74 2d 66 75 6c 6c 2d 70 61 74 68 20 74 65 73  et-full-path tes
2790: 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73  t).  (let* ((tes
27a0: 74 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67  tname (db:test-g
27b0: 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20 74 65  et-testname   te
27c0: 73 74 29 29 0a 09 20 28 69 74 65 6d 70 61 74 68  st)).. (itempath
27d0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74   (db:test-get-it
27e0: 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 29 0a  em-path test))).
27f0: 20 20 20 20 28 63 6f 6e 63 20 74 65 73 74 6e 61      (conc testna
2800: 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69  me (if (equal? i
2810: 74 65 6d 70 61 74 68 20 22 22 29 20 22 22 20 28  tempath "") "" (
2820: 63 6f 6e 63 20 22 28 22 20 69 74 65 6d 70 61 74  conc "(" itempat
2830: 68 20 22 29 22 29 29 29 29 29 0a 0a 28 64 65 66  h ")")))))..(def
2840: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74  ine-inline (test
2850: 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 6e 61  :test-get-fullna
2860: 6d 65 20 74 65 73 74 29 0a 20 20 20 28 63 6f 6e  me test).   (con
2870: 63 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74  c (db:test-get-t
2880: 65 73 74 6e 61 6d 65 20 74 65 73 74 29 0a 09 20  estname test).. 
2890: 28 69 66 20 28 65 71 75 61 6c 3f 20 28 64 62 3a  (if (equal? (db:
28a0: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
28b0: 74 68 20 74 65 73 74 29 20 22 22 29 0a 09 20 20  th test) "")..  
28c0: 20 20 20 22 22 0a 09 20 20 20 20 20 28 63 6f 6e     ""..     (con
28d0: 63 20 22 28 22 20 28 64 62 3a 74 65 73 74 2d 67  c "(" (db:test-g
28e0: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
28f0: 74 29 20 22 29 22 29 29 29 29 0a 0a 28 64 65 66  t) ")"))))..(def
2900: 69 6e 65 20 28 63 68 65 63 6b 2d 76 61 6c 69 64  ine (check-valid
2910: 2d 69 74 65 6d 73 20 63 6c 61 73 73 20 69 74 65  -items class ite
2920: 6d 29 0a 20 20 28 6c 65 74 20 28 28 76 61 6c 69  m).  (let ((vali
2930: 64 2d 76 61 6c 75 65 73 20 28 6c 65 74 20 28 28  d-values (let ((
2940: 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70  s (config-lookup
2950: 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 76 61   *configdat* "va
2960: 6c 69 64 76 61 6c 75 65 73 22 20 63 6c 61 73 73  lidvalues" class
2970: 29 29 29 0a 09 09 09 28 69 66 20 73 20 28 73 74  )))....(if s (st
2980: 72 69 6e 67 2d 73 70 6c 69 74 20 73 29 20 23 66  ring-split s) #f
2990: 29 29 29 29 0a 20 20 20 20 28 69 66 20 76 61 6c  )))).    (if val
29a0: 69 64 2d 76 61 6c 75 65 73 0a 09 28 69 66 20 28  id-values..(if (
29b0: 6d 65 6d 62 65 72 20 69 74 65 6d 20 76 61 6c 69  member item vali
29c0: 64 2d 76 61 6c 75 65 73 29 0a 09 20 20 20 20 69  d-values)..    i
29d0: 74 65 6d 20 23 66 29 0a 09 69 74 65 6d 29 29 29  tem #f)..item)))
29e0: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 73  ..(define (tests
29f0: 74 65 70 2d 73 65 74 2d 73 74 61 74 75 73 21 20  tep-set-status! 
2a00: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
2a10: 61 6d 65 20 74 65 73 74 73 74 65 70 2d 6e 61 6d  ame teststep-nam
2a20: 65 20 73 74 61 74 65 2d 69 6e 20 73 74 61 74 75  e state-in statu
2a30: 73 2d 69 6e 20 69 74 65 6d 64 61 74 20 63 6f 6d  s-in itemdat com
2a40: 6d 65 6e 74 29 0a 20 20 28 64 65 62 75 67 3a 70  ment).  (debug:p
2a50: 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20  rint 4 "run-id: 
2a60: 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d  " run-id " test-
2a70: 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d  name: " test-nam
2a80: 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73 74 61  e).  (let* ((sta
2a90: 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d 76 61  te     (check-va
2aa0: 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61 74 65  lid-items "state
2ab0: 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09 20 28  " state-in)).. (
2ac0: 73 74 61 74 75 73 20 20 20 20 28 63 68 65 63 6b  status    (check
2ad0: 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74  -valid-items "st
2ae0: 61 74 75 73 22 20 73 74 61 74 75 73 2d 69 6e 29  atus" status-in)
2af0: 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68 20 28  ).. (item-path (
2b00: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
2b10: 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74 65 73  itemdat)).. (tes
2b20: 74 64 61 74 20 20 20 28 64 62 3a 67 65 74 2d 74  tdat   (db:get-t
2b30: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  est-info db run-
2b40: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
2b50: 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 28 64  m-path))).    (d
2b60: 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22 74 65  ebug:print 5 "te
2b70: 73 74 64 61 74 3a 20 22 20 74 65 73 74 64 61 74  stdat: " testdat
2b80: 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 74  ).    (if (and t
2b90: 65 73 74 64 61 74 20 3b 3b 20 69 66 20 74 68 65  estdat ;; if the
2ba0: 20 73 65 63 74 69 6f 6e 20 65 78 69 73 74 73 20   section exists 
2bb0: 74 68 65 6e 20 66 6f 72 63 65 20 73 70 65 63 69  then force speci
2bc0: 66 69 63 61 74 69 6f 6e 20 42 55 47 2c 20 49 20  fication BUG, I 
2bd0: 64 6f 6e 27 74 20 6c 69 6b 65 20 68 6f 77 20 74  don't like how t
2be0: 68 69 73 20 77 6f 72 6b 73 2e 0a 09 20 20 20 20  his works...    
2bf0: 20 28 6f 72 20 28 6e 6f 74 20 73 74 61 74 65 29   (or (not state)
2c00: 28 6e 6f 74 20 73 74 61 74 75 73 29 29 29 0a 09  (not status)))..
2c10: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
2c20: 57 41 52 4e 49 4e 47 3a 20 49 6e 76 61 6c 69 64  WARNING: Invalid
2c30: 20 22 20 28 69 66 20 73 74 61 74 75 73 20 22 73   " (if status "s
2c40: 74 61 74 75 73 22 20 22 73 74 61 74 65 22 29 0a  tatus" "state").
2c50: 09 20 20 20 20 20 20 20 22 20 76 61 6c 75 65 20  .       " value 
2c60: 5c 22 22 20 28 69 66 20 73 74 61 74 75 73 20 73  \"" (if status s
2c70: 74 61 74 75 73 2d 69 6e 20 73 74 61 74 65 2d 69  tatus-in state-i
2c80: 6e 29 20 22 5c 22 2c 20 75 70 64 61 74 65 20 79  n) "\", update y
2c90: 6f 75 72 20 76 61 6c 69 64 73 74 61 74 65 73 20  our validstates 
2ca0: 73 65 63 74 69 6f 6e 20 69 6e 20 6d 65 67 61 74  section in megat
2cb0: 65 73 74 2e 63 6f 6e 66 69 67 22 29 29 0a 20 20  est.config")).  
2cc0: 20 20 28 69 66 20 74 65 73 74 64 61 74 0a 09 28    (if testdat..(
2cd0: 6c 65 74 20 28 28 74 65 73 74 2d 69 64 20 28 74  let ((test-id (t
2ce0: 65 73 74 3a 67 65 74 2d 69 64 20 74 65 73 74 64  est:get-id testd
2cf0: 61 74 29 29 29 0a 09 20 20 28 73 71 6c 69 74 65  at)))..  (sqlite
2d00: 33 3a 65 78 65 63 75 74 65 20 64 62 20 0a 09 09  3:execute db ...
2d10: 09 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c  ."INSERT OR REPL
2d20: 41 43 45 20 69 6e 74 6f 20 74 65 73 74 5f 73 74  ACE into test_st
2d30: 65 70 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65  eps (test_id,ste
2d40: 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  pname,state,stat
2d50: 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f  us,event_time,co
2d60: 6d 6d 65 6e 74 29 20 56 41 4c 55 45 53 28 3f 2c  mment) VALUES(?,
2d70: 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28 27  ?,?,?,strftime('
2d80: 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 29 3b 22 0a  %s','now'),?);".
2d90: 09 09 09 74 65 73 74 2d 69 64 20 74 65 73 74 73  ...test-id tests
2da0: 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65 20 73  tep-name state s
2db0: 74 61 74 75 73 20 28 69 66 20 63 6f 6d 6d 65 6e  tatus (if commen
2dc0: 74 20 63 6f 6d 6d 65 6e 74 20 22 22 29 29 29 0a  t comment ""))).
2dd0: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
2de0: 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 75 70  "ERROR: Can't up
2df0: 64 61 74 65 20 22 20 74 65 73 74 2d 6e 61 6d 65  date " test-name
2e00: 20 22 20 66 6f 72 20 72 75 6e 20 22 20 72 75 6e   " for run " run
2e10: 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 73 75 63 68  -id " -> no such
2e20: 20 74 65 73 74 20 69 6e 20 64 62 22 29 29 29 29   test in db"))))
2e30: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d  ..(define (test-
2e40: 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65 73 74  get-kill-request
2e50: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
2e60: 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a 20 20  name itemdat).  
2e70: 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74  (let* ((item-pat
2e80: 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61  h (item-list->pa
2e90: 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28  th itemdat)).. (
2ea0: 74 65 73 74 64 61 74 20 20 20 28 64 62 3a 67 65  testdat   (db:ge
2eb0: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72  t-test-info db r
2ec0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
2ed0: 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20  item-path))).   
2ee0: 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67   (equal? (test:g
2ef0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
2f00: 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 29 0a 0a  ) "KILLREQ")))..
2f10: 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65  (define (test-se
2f20: 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62 20 72  t-meta-info db r
2f30: 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69  un-id testname i
2f40: 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74 20 28  temdat).  (let (
2f50: 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d  (item-path (item
2f60: 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d  -list->path item
2f70: 64 61 74 29 29 0a 09 28 63 70 75 6c 6f 61 64 20  dat))..(cpuload 
2f80: 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64 29 29   (get-cpu-load))
2f90: 0a 09 28 68 6f 73 74 6e 61 6d 65 20 28 67 65 74  ..(hostname (get
2fa0: 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 0a 09 28 64  -host-name))..(d
2fb0: 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64 66 20  iskfree (get-df 
2fc0: 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74 6f  (current-directo
2fd0: 72 79 29 29 29 0a 09 28 75 6e 61 6d 65 20 20 20  ry)))..(uname   
2fe0: 20 28 67 65 74 2d 75 6e 61 6d 65 20 22 2d 73 72   (get-uname "-sr
2ff0: 76 70 69 6f 22 29 29 0a 09 28 72 75 6e 70 61 74  vpio"))..(runpat
3000: 68 20 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65  h  (current-dire
3010: 63 74 6f 72 79 29 29 29 0a 20 20 20 20 28 73 71  ctory))).    (sq
3020: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
3030: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53   "UPDATE tests S
3040: 45 54 20 68 6f 73 74 3d 3f 2c 63 70 75 6c 6f 61  ET host=?,cpuloa
3050: 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c 75  d=?,diskfree=?,u
3060: 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d 3f 20  name=?,rundir=? 
3070: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
3080: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
3090: 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a  D item_path=?;".
30a0: 09 09 20 20 68 6f 73 74 6e 61 6d 65 0a 09 09 20  ..  hostname... 
30b0: 20 63 70 75 6c 6f 61 64 0a 09 09 20 20 64 69 73   cpuload...  dis
30c0: 6b 66 72 65 65 0a 09 09 20 20 75 6e 61 6d 65 0a  kfree...  uname.
30d0: 09 09 20 20 72 75 6e 70 61 74 68 0a 09 09 20 20  ..  runpath...  
30e0: 72 75 6e 2d 69 64 0a 09 09 20 20 74 65 73 74 6e  run-id...  testn
30f0: 61 6d 65 0a 09 09 20 20 69 74 65 6d 2d 70 61 74  ame...  item-pat
3100: 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74  h)))..(define (t
3110: 65 73 74 2d 75 70 64 61 74 65 2d 6d 65 74 61 2d  est-update-meta-
3120: 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74  info db run-id t
3130: 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61 74 20  estname itemdat 
3140: 6d 69 6e 75 74 65 73 29 0a 20 20 28 6c 65 74 20  minutes).  (let 
3150: 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65  ((item-path (ite
3160: 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65  m-list->path ite
3170: 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f 61 64  mdat))..(cpuload
3180: 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64 29    (get-cpu-load)
3190: 29 0a 09 28 64 69 73 6b 66 72 65 65 20 28 67 65  )..(diskfree (ge
31a0: 74 2d 64 66 20 28 63 75 72 72 65 6e 74 2d 64 69  t-df (current-di
31b0: 72 65 63 74 6f 72 79 29 29 29 29 0a 20 20 20 20  rectory)))).    
31c0: 28 69 66 20 28 6e 6f 74 20 63 70 75 6c 6f 61 64  (if (not cpuload
31d0: 29 20 20 28 62 65 67 69 6e 20 28 64 65 62 75 67  )  (begin (debug
31e0: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
31f0: 47 3a 20 43 50 55 4c 4f 41 44 20 6e 6f 74 20 66  G: CPULOAD not f
3200: 6f 75 6e 64 2e 22 29 20 20 28 73 65 74 21 20 63  ound.")  (set! c
3210: 70 75 6c 6f 61 64 20 22 6e 2f 61 22 29 29 29 0a  puload "n/a"))).
3220: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 64 69 73      (if (not dis
3230: 6b 66 72 65 65 29 20 28 62 65 67 69 6e 20 28 64  kfree) (begin (d
3240: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
3250: 52 4e 49 4e 47 3a 20 44 49 53 4b 46 52 45 45 20  RNING: DISKFREE 
3260: 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 20 28 73 65  not found.") (se
3270: 74 21 20 64 69 73 6b 66 72 65 65 20 22 6e 2f 61  t! diskfree "n/a
3280: 22 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f  "))).    (if (no
3290: 74 20 69 74 65 6d 2d 70 61 74 68 29 28 62 65 67  t item-path)(beg
32a0: 69 6e 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  in (debug:print 
32b0: 30 20 22 57 41 52 4e 49 4e 47 3a 20 49 54 45 4d  0 "WARNING: ITEM
32c0: 50 41 54 48 20 6e 6f 74 20 73 65 74 2e 22 29 20  PATH not set.") 
32d0: 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70 61 74    (set! item-pat
32e0: 68 20 22 22 29 29 29 0a 20 20 20 20 3b 3b 20 28  h ""))).    ;; (
32f0: 6c 65 74 20 28 28 74 65 73 74 69 6e 66 6f 20 28  let ((testinfo (
3300: 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f  db:get-test-info
3310: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 6e   db run-id testn
3320: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ame item-path)))
3330: 0a 20 20 20 20 3b 3b 20 20 20 28 69 66 20 28 61  .    ;;   (if (a
3340: 6e 64 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20  nd (not (equal? 
3350: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61  (db:test-get-sta
3360: 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20 22 43  tus testinfo) "C
3370: 4f 4d 50 4c 45 54 45 44 22 29 29 0a 20 20 20 20  OMPLETED")).    
3380: 3b 3b 20 20 20 20 20 20 20 20 20 20 20 20 28 6e  ;;            (n
3390: 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62 3a 74  ot (equal? (db:t
33a0: 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73 20 74  est-get-status t
33b0: 65 73 74 69 6e 66 6f 29 20 22 4b 49 4c 4c 52 45  estinfo) "KILLRE
33c0: 51 22 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65  Q")).    (sqlite
33d0: 33 3a 65 78 65 63 75 74 65 0a 20 20 20 20 20 64  3:execute.     d
33e0: 62 0a 20 20 20 20 20 22 55 50 44 41 54 45 20 74  b.     "UPDATE t
33f0: 65 73 74 73 20 53 45 54 20 63 70 75 6c 6f 61 64  ests SET cpuload
3400: 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c 72 75  =?,diskfree=?,ru
3410: 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f 2c 73 74 61  n_duration=?,sta
3420: 74 65 3d 27 52 55 4e 4e 49 4e 47 27 20 57 48 45  te='RUNNING' WHE
3430: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
3440: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
3450: 74 65 6d 5f 70 61 74 68 3d 3f 20 41 4e 44 20 73  tem_path=? AND s
3460: 74 61 74 65 20 4e 4f 54 20 49 4e 20 28 27 43 4f  tate NOT IN ('CO
3470: 4d 50 4c 45 54 45 44 27 2c 27 4b 49 4c 4c 52 45  MPLETED','KILLRE
3480: 51 27 2c 27 4b 49 4c 4c 45 44 27 29 3b 22 0a 20  Q','KILLED');". 
3490: 20 20 20 20 63 70 75 6c 6f 61 64 0a 20 20 20 20      cpuload.    
34a0: 20 64 69 73 6b 66 72 65 65 0a 20 20 20 20 20 6d   diskfree.     m
34b0: 69 6e 75 74 65 73 0a 20 20 20 20 20 72 75 6e 2d  inutes.     run-
34c0: 69 64 0a 20 20 20 20 20 74 65 73 74 6e 61 6d 65  id.     testname
34d0: 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74 68 29  .     item-path)
34e0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74  ))..(define (set
34f0: 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61  -megatest-env-va
3500: 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a 20 20  rs db run-id).  
3510: 28 6c 65 74 20 28 28 6b 65 79 73 20 28 64 62 2d  (let ((keys (db-
3520: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29 0a 20  get-keys db))). 
3530: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61     (for-each (la
3540: 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28 73 71  mbda (key)...(sq
3550: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
3560: 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 76  ow... (lambda (v
3570: 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a  al)...   (debug:
3580: 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20  print 2 "setenv 
3590: 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  " (key:get-field
35a0: 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20 76 61  name key) " " va
35b0: 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e 76 20  l)...   (setenv 
35c0: 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61  (key:get-fieldna
35d0: 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a 09 09  me key) val))...
35e0: 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20 22 53   db ... (conc "S
35f0: 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67 65 74  ELECT " (key:get
3600: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20  -fieldname key) 
3610: 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52  " FROM runs WHER
3620: 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e  E id=?;")... run
3630: 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b 65 79  -id))..      key
3640: 73 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73  s)))..(define (s
3650: 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61 72 73  et-item-env-vars
3660: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66 6f 72   itemdat).  (for
3670: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 69  -each (lambda (i
3680: 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64 65 62  tem)..      (deb
3690: 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65  ug:print 2 "sete
36a0: 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d 29 20  nv " (car item) 
36b0: 22 20 22 20 28 63 61 64 72 20 69 74 65 6d 29 29  " " (cadr item))
36c0: 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e 76 20  ..      (setenv 
36d0: 28 63 61 72 20 69 74 65 6d 29 20 28 63 61 64 72  (car item) (cadr
36e0: 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20 69 74   item)))..    it
36f0: 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69 6e 65  emdat))..(define
3700: 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c 2d   (get-all-legal-
3710: 74 65 73 74 73 29 0a 20 20 28 6c 65 74 2a 20 28  tests).  (let* (
3720: 28 74 65 73 74 73 20 20 28 67 6c 6f 62 20 28 63  (tests  (glob (c
3730: 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  onc *toppath* "/
3740: 74 65 73 74 73 2f 2a 22 29 29 29 0a 09 20 28 72  tests/*"))).. (r
3750: 65 73 20 20 20 20 27 28 29 29 29 0a 20 20 20 20  es    '())).    
3760: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
3770: 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20 61 74  INFO: Looking at
3780: 20 74 65 73 74 73 20 22 20 28 73 74 72 69 6e 67   tests " (string
3790: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 74 65 73  -intersperse tes
37a0: 74 73 20 22 2c 22 29 29 0a 20 20 20 20 28 66 6f  ts ",")).    (fo
37b0: 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28  r-each (lambda (
37c0: 74 65 73 74 70 61 74 68 29 0a 09 09 28 69 66 20  testpath)...(if 
37d0: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 28 63  (file-exists? (c
37e0: 6f 6e 63 20 74 65 73 74 70 61 74 68 20 22 2f 74  onc testpath "/t
37f0: 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 09 20  estconfig"))... 
3800: 20 20 20 28 73 65 74 21 20 72 65 73 20 28 63 6f     (set! res (co
3810: 6e 73 20 28 6c 61 73 74 20 28 73 74 72 69 6e 67  ns (last (string
3820: 2d 73 70 6c 69 74 20 74 65 73 74 70 61 74 68 20  -split testpath 
3830: 22 2f 22 29 29 20 72 65 73 29 29 29 29 0a 09 20  "/")) res)))).. 
3840: 20 20 20 20 20 74 65 73 74 73 29 0a 20 20 20 20       tests).    
3850: 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  res))..(define (
3860: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
3870: 65 2d 74 65 73 74 73 20 64 62 29 0a 20 20 28 6c  e-tests db).  (l
3880: 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67  et ((num-running
3890: 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74   (db:get-count-t
38a0: 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29  ests-running db)
38b0: 29 0a 09 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65  )..(max-concurre
38c0: 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d  nt-jobs (config-
38d0: 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61  lookup *configda
38e0: 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f  t* "setup" "max_
38f0: 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22  concurrent_jobs"
3900: 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ))).    (debug:p
3910: 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f 6e 63  rint 2 "max-conc
3920: 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d  urrent-jobs: " m
3930: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
3940: 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e  bs ", num-runnin
3950: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
3960: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ).    (if (not (
3970: 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c 65 78 69  eq? 0 *globalexi
3980: 74 73 74 61 74 75 73 2a 29 29 0a 09 23 66 0a 09  tstatus*))..#f..
3990: 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 6d 61 78  (if (or (not max
39a0: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
39b0: 29 0a 09 09 28 61 6e 64 20 6d 61 78 2d 63 6f 6e  )...(and max-con
39c0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a 09 09 20  current-jobs... 
39d0: 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d      (string->num
39e0: 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  ber max-concurre
39f0: 6e 74 2d 6a 6f 62 73 29 0a 09 09 20 20 20 20 20  nt-jobs)...     
3a00: 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e  (not (>= num-run
3a10: 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75  ning (string->nu
3a20: 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72  mber max-concurr
3a30: 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29 0a 09 20  ent-jobs))))).. 
3a40: 20 20 20 23 74 0a 09 20 20 20 20 28 62 65 67 69     #t..    (begi
3a50: 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 75 67  n ..      (debug
3a60: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
3a70: 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a  G: Max running j
3a80: 6f 62 73 20 65 78 63 65 65 64 65 64 2c 20 63 75  obs exceeded, cu
3a90: 72 72 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e  rrent number run
3aa0: 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e  ning: " num-runn
3ab0: 69 6e 67 20 0a 09 09 09 20 20 20 22 2c 20 6d 61  ing ....   ", ma
3ac0: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
3ad0: 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72  s: " max-concurr
3ae0: 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20 20 20  ent-jobs)..     
3af0: 20 23 66 29 29 29 29 29 0a 20 20 0a 28 64 65 66   #f))))).  .(def
3b00: 69 6e 65 20 28 72 75 6e 2d 74 65 73 74 73 20 64  ine (run-tests d
3b10: 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 20 20  b test-names).  
3b20: 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20  (let* ((keys    
3b30: 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73      (db-get-keys
3b40: 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c   db)).. (keyvall
3b50: 73 74 20 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c  st   (keys->vall
3b60: 69 73 74 20 6b 65 79 73 20 23 74 29 29 0a 09 20  ist keys #t)).. 
3b70: 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72 65  (run-id      (re
3b80: 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65  gister-run db ke
3b90: 79 73 29 29 29 20 3b 3b 20 20 74 65 73 74 2d 6e  ys))) ;;  test-n
3ba0: 61 6d 65 29 29 29 0a 20 20 20 20 3b 3b 20 6f 6e  ame))).    ;; on
3bb0: 20 74 68 65 20 66 69 72 73 74 20 70 61 73 73 20   the first pass 
3bc0: 6f 72 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74  or call to run-t
3bd0: 65 73 74 73 20 73 65 74 20 46 41 49 4c 53 20 74  ests set FAILS t
3be0: 6f 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66  o NOT_STARTED if
3bf0: 0a 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69  .    ;; -keepgoi
3c00: 6e 67 20 69 73 20 73 70 65 63 69 66 69 65 64 0a  ng is specified.
3c10: 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 65 71      (if (and (eq
3c20: 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09  ? *passnum* 0)..
3c30: 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61       (args:get-a
3c40: 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29  rg "-keepgoing")
3c50: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20  )..(begin..  ;; 
3c60: 68 61 76 65 20 74 6f 20 64 65 6c 65 74 65 20 74  have to delete t
3c70: 65 73 74 20 72 65 63 6f 72 64 73 20 77 68 65 72  est records wher
3c80: 65 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 73 69  e NOT_STARTED si
3c90: 6e 63 65 20 74 68 65 79 20 63 61 6e 20 63 61 75  nce they can cau
3ca0: 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74 6f  se -keepgoing to
3cb0: 20 0a 09 20 20 3b 3b 20 67 65 74 20 73 74 75 63   ..  ;; get stuc
3cc0: 6b 20 64 75 65 20 74 6f 20 62 65 63 6f 6d 69 6e  k due to becomin
3cd0: 67 20 69 6e 61 63 63 65 73 73 69 62 6c 65 20 66  g inaccessible f
3ce0: 72 6f 6d 20 61 20 66 61 69 6c 65 64 20 74 65 73  rom a failed tes
3cf0: 74 2e 20 49 2e 65 2e 20 69 66 20 74 65 73 74 20  t. I.e. if test 
3d00: 42 20 64 65 70 65 6e 64 73 20 0a 09 20 20 3b 3b  B depends ..  ;;
3d10: 20 6f 6e 20 74 65 73 74 20 41 20 62 75 74 20 74   on test A but t
3d20: 65 73 74 20 42 20 72 65 61 63 68 65 64 20 74 68  est B reached th
3d30: 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e 67  e point on being
3d40: 20 72 65 67 69 73 74 65 72 65 64 20 61 73 20 4e   registered as N
3d50: 4f 54 5f 53 54 41 52 54 45 44 20 61 6e 64 20 74  OT_STARTED and t
3d60: 65 73 74 0a 09 20 20 3b 3b 20 41 20 66 61 69 6c  est..  ;; A fail
3d70: 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65 61 73  ed for some reas
3d80: 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72 75  on then on re-ru
3d90: 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f 69  n using -keepgoi
3da0: 6e 67 20 74 68 65 20 72 75 6e 20 63 61 6e 20 6e  ng the run can n
3db0: 65 76 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a 09  ever complete...
3dc0: 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73    (db:delete-tes
3dd0: 74 73 2d 69 6e 2d 73 74 61 74 65 20 64 62 20 72  ts-in-state db r
3de0: 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54 41 52 54  un-id "NOT_START
3df0: 45 44 22 29 0a 09 20 20 28 64 62 3a 73 65 74 2d  ED")..  (db:set-
3e00: 74 65 73 74 73 2d 73 74 61 74 65 2d 73 74 61 74  tests-state-stat
3e10: 75 73 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  us db run-id tes
3e20: 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 41 49 4c  t-names #f "FAIL
3e30: 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 20  " "NOT_STARTED" 
3e40: 22 46 41 49 4c 22 29 29 29 0a 20 20 20 20 28 73  "FAIL"))).    (s
3e50: 65 74 21 20 2a 70 61 73 73 6e 75 6d 2a 20 28 2b  et! *passnum* (+
3e60: 20 2a 70 61 73 73 6e 75 6d 2a 20 31 29 29 0a 20   *passnum* 1)). 
3e70: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 6e     (let loop ((n
3e80: 75 6d 74 69 6d 65 73 20 30 29 29 0a 20 20 20 20  umtimes 0)).    
3e90: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
3ea0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73      (lambda (tes
3eb0: 74 2d 6e 61 6d 65 29 0a 09 20 28 69 66 20 28 72  t-name).. (if (r
3ec0: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
3ed0: 2d 74 65 73 74 73 20 64 62 29 0a 09 20 20 20 20  -tests db)..    
3ee0: 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64   (run-one-test d
3ef0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
3f00: 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a 09 20  me keyvallst).. 
3f10: 20 20 20 20 3b 3b 20 61 64 64 20 73 6f 6d 65 20      ;; add some 
3f20: 64 65 6c 61 79 20 0a 09 20 20 20 20 20 3b 28 73  delay ..     ;(s
3f30: 6c 65 65 70 20 32 29 0a 09 20 20 20 20 20 29 29  leep 2)..     ))
3f40: 0a 20 20 20 20 20 20 20 74 65 73 74 2d 6e 61 6d  .       test-nam
3f50: 65 73 29 0a 20 20 20 20 20 20 3b 3b 20 28 72 75  es).      ;; (ru
3f60: 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20  n-waiting-tests 
3f70: 64 62 29 0a 20 20 20 20 20 20 28 69 66 20 28 61  db).      (if (a
3f80: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65  rgs:get-arg "-ke
3f90: 65 70 67 6f 69 6e 67 22 29 0a 09 20 20 28 6c 65  epgoing")..  (le
3fa0: 74 20 28 28 65 73 74 72 65 6d 20 28 64 62 3a 65  t ((estrem (db:e
3fb0: 73 74 69 6d 61 74 65 64 2d 74 65 73 74 73 2d 72  stimated-tests-r
3fc0: 65 6d 61 69 6e 69 6e 67 20 64 62 20 72 75 6e 2d  emaining db run-
3fd0: 69 64 29 29 29 0a 09 20 20 20 20 28 69 66 20 28  id)))..    (if (
3fe0: 61 6e 64 20 28 3e 20 65 73 74 72 65 6d 20 30 29  and (> estrem 0)
3ff0: 0a 09 09 20 20 20 20 20 28 65 71 3f 20 2a 67 6c  ...     (eq? *gl
4000: 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20  obalexitstatus* 
4010: 30 29 29 0a 09 09 28 62 65 67 69 6e 0a 09 09 20  0))...(begin... 
4020: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
4030: 22 4b 65 65 70 20 67 6f 69 6e 67 2c 20 65 73 74  "Keep going, est
4040: 69 6d 61 74 65 64 20 22 20 65 73 74 72 65 6d 20  imated " estrem 
4050: 22 20 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e  " tests remainin
4060: 67 20 74 6f 20 72 75 6e 2c 20 77 69 6c 6c 20 63  g to run, will c
4070: 6f 6e 74 69 6e 75 65 20 69 6e 20 33 20 73 65 63  ontinue in 3 sec
4080: 6f 6e 64 73 20 2e 2e 2e 22 29 0a 09 09 20 20 28  onds ...")...  (
4090: 73 6c 65 65 70 20 33 29 0a 09 09 20 20 28 72 75  sleep 3)...  (ru
40a0: 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20  n-waiting-tests 
40b0: 64 62 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 2b  db)...  (loop (+
40c0: 20 6e 75 6d 74 69 6d 65 73 20 31 29 29 29 29 29   numtimes 1)))))
40d0: 29 29 29 29 0a 09 20 20 20 0a 3b 3b 20 56 45 52  ))))..   .;; VER
40e0: 59 20 49 4e 45 46 46 49 43 49 45 4e 54 21 20 4d  Y INEFFICIENT! M
40f0: 6f 76 65 20 73 74 75 66 66 20 74 68 61 74 20 73  ove stuff that s
4100: 68 6f 75 6c 64 20 62 65 20 64 6f 6e 65 20 6f 6e  hould be done on
4110: 63 65 20 75 70 20 74 6f 20 63 61 6c 6c 69 6e 67  ce up to calling
4120: 20 70 72 6f 63 0a 28 64 65 66 69 6e 65 20 28 72   proc.(define (r
4130: 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20 72  un-one-test db r
4140: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
4150: 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20 28 64 65  keyvallst).  (de
4160: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75  bug:print 1 "Lau
4170: 6e 63 68 69 6e 67 20 74 65 73 74 20 22 20 74 65  nching test " te
4180: 73 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41 6c  st-name).  ;; Al
4190: 6c 20 74 68 65 73 65 20 76 61 72 73 20 6d 69 67  l these vars mig
41a0: 68 74 20 62 65 20 72 65 66 65 72 65 6e 63 65 64  ht be referenced
41b0: 20 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66   by the testconf
41c0: 69 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20  ig file reader. 
41d0: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53   (setenv "MT_TES
41e0: 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d  T_NAME" test-nam
41f0: 65 29 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e 76  e) ;; .  (setenv
4200: 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20   "MT_RUNNAME"   
4210: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a  (args:get-arg ":
4220: 72 75 6e 6e 61 6d 65 22 29 29 0a 20 20 28 73 65  runname")).  (se
4230: 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76  t-megatest-env-v
4240: 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b  ars db run-id) ;
4250: 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e  ; these may be n
4260: 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61 75  eeded by the lau
4270: 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20  nching process. 
4280: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
4290: 72 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20  ry *toppath*).  
42a0: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74  (let* ((test-pat
42b0: 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70  h    (conc *topp
42c0: 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74  ath* "/tests/" t
42d0: 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 28 74 65  est-name)).. (te
42e0: 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63  st-configf (conc
42f0: 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73   test-path "/tes
4300: 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 74 65  tconfig")).. (te
4310: 73 74 65 78 69 73 74 73 20 20 20 28 61 6e 64 20  stexists   (and 
4320: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65  (file-exists? te
4330: 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65  st-configf)(file
4340: 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65  -read-access? te
4350: 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 20  st-configf))).. 
4360: 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69  (test-conf    (i
4370: 66 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65  f testexists (re
4380: 61 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63  ad-config test-c
4390: 6f 6e 66 69 67 66 29 20 28 6d 61 6b 65 2d 68 61  onfigf) (make-ha
43a0: 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 28 77  sh-table))).. (w
43b0: 61 69 74 6f 6e 20 20 20 20 20 20 20 28 6c 65 74  aiton       (let
43c0: 20 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f   ((w (config-loo
43d0: 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 72  kup test-conf "r
43e0: 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 77 61  equirements" "wa
43f0: 69 74 6f 6e 22 29 29 29 0a 09 09 09 20 28 69 66  iton"))).... (if
4400: 20 28 73 74 72 69 6e 67 3f 20 77 29 28 73 74 72   (string? w)(str
4410: 69 6e 67 2d 73 70 6c 69 74 20 77 29 27 28 29 29  ing-split w)'())
4420: 29 29 0a 09 20 28 74 61 67 73 20 20 20 20 20 20  )).. (tags      
4430: 20 20 20 28 6c 65 74 20 28 28 74 20 28 63 6f 6e     (let ((t (con
4440: 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d  fig-lookup test-
4450: 63 6f 6e 66 20 22 73 65 74 75 70 22 20 22 74 61  conf "setup" "ta
4460: 67 73 22 29 29 29 0a 09 09 09 20 28 69 66 20 28  gs"))).... (if (
4470: 73 74 72 69 6e 67 3f 20 74 29 28 73 74 72 69 6e  string? t)(strin
4480: 67 2d 73 70 6c 69 74 20 74 20 22 2c 22 29 20 27  g-split t ",") '
4490: 28 29 29 29 29 29 0a 20 20 20 20 28 69 66 20 28  ())))).    (if (
44a0: 6e 6f 74 20 74 65 73 74 65 78 69 73 74 73 29 0a  not testexists).
44b0: 09 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75  .(begin..  (debu
44c0: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
44d0: 3a 20 43 61 6e 27 74 20 66 69 6e 64 20 63 6f 6e  : Can't find con
44e0: 66 69 67 20 66 69 6c 65 20 22 20 74 65 73 74 2d  fig file " test-
44f0: 63 6f 6e 66 69 67 66 29 0a 09 20 20 28 65 78 69  configf)..  (exi
4500: 74 20 32 29 29 0a 09 3b 3b 20 70 75 74 20 74 6f  t 2))..;; put to
4510: 70 20 76 61 72 73 20 69 6e 74 6f 20 63 6f 6e 76  p vars into conv
4520: 65 6e 69 65 6e 74 20 76 61 72 69 61 62 6c 65 73  enient variables
4530: 20 61 6e 64 20 6f 70 65 6e 20 74 68 65 20 64 62   and open the db
4540: 0a 09 28 6c 65 74 2a 20 28 3b 3b 20 64 62 20 69  ..(let* (;; db i
4550: 73 20 61 6c 77 61 79 73 20 61 74 20 2a 74 6f 70  s always at *top
4560: 70 61 74 68 2a 2f 64 62 2f 6d 65 67 61 74 65 73  path*/db/megates
4570: 74 2e 64 62 0a 09 20 20 20 20 20 20 20 28 69 74  t.db..       (it
4580: 65 6d 73 20 20 20 20 20 20 20 28 68 61 73 68 2d  ems       (hash-
4590: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
45a0: 74 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65  t test-conf "ite
45b0: 6d 73 22 20 27 28 29 29 29 0a 09 20 20 20 20 20  ms" '()))..     
45c0: 20 20 28 69 74 65 6d 73 74 61 62 6c 65 20 20 28    (itemstable  (
45d0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
45e0: 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66  efault test-conf
45f0: 20 22 69 74 65 6d 73 74 61 62 6c 65 22 20 27 28   "itemstable" '(
4600: 29 29 29 0a 09 20 20 20 20 20 20 20 28 61 6c 6c  )))..       (all
4610: 69 74 65 6d 73 20 20 20 20 28 69 66 20 28 6f 72  items    (if (or
4620: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65   (not (null? ite
4630: 6d 73 29 29 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  ms))(not (null? 
4640: 69 74 65 6d 73 74 61 62 6c 65 29 29 29 0a 09 09  itemstable)))...
4650: 09 09 28 61 70 70 65 6e 64 20 28 69 74 65 6d 2d  ..(append (item-
4660: 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74  assoc->item-list
4670: 20 69 74 65 6d 73 29 0a 09 09 09 09 09 28 69 74   items)......(it
4680: 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c  em-table->item-l
4690: 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29  ist itemstable))
46a0: 0a 09 09 09 09 27 28 28 29 29 29 29 20 3b 3b 20  .....'(()))) ;; 
46b0: 61 20 6c 69 73 74 20 77 69 74 68 20 6f 6e 65 20  a list with one 
46c0: 6e 75 6c 6c 20 6c 69 73 74 20 69 73 20 61 20 74  null list is a t
46d0: 65 73 74 20 77 69 74 68 20 6e 6f 20 69 74 65 6d  est with no item
46e0: 73 0a 09 20 20 20 20 20 20 20 28 72 75 6e 63 6f  s..       (runco
46f0: 6e 66 69 67 66 20 20 28 63 6f 6e 63 20 20 2a 74  nfigf  (conc  *t
4700: 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e  oppath* "/runcon
4710: 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 29 0a  figs.config"))).
4720: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
4730: 31 20 22 69 74 65 6d 73 3a 20 22 29 0a 09 20 20  1 "items: ")..  
4740: 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69  (if (>= *verbosi
4750: 74 79 2a 20 31 29 28 70 70 20 61 6c 6c 69 74 65  ty* 1)(pp allite
4760: 6d 73 29 29 0a 09 20 20 28 69 66 20 28 3e 3d 20  ms))..  (if (>= 
4770: 2a 76 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09  *verbosity* 5)..
4780: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 28        (begin...(
4790: 70 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 22 29  print "items: ")
47a0: 28 70 70 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d  (pp (item-assoc-
47b0: 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73  >item-list items
47c0: 29 29 0a 09 09 28 70 72 69 6e 74 20 22 69 74 65  ))...(print "ite
47d0: 73 74 61 62 6c 65 3a 20 22 29 28 70 70 20 28 69  stable: ")(pp (i
47e0: 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d  tem-table->item-
47f0: 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29  list itemstable)
4800: 29 29 29 0a 09 20 20 28 69 66 20 28 61 72 67 73  )))..  (if (args
4810: 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 0a 09  :get-arg "-m")..
4820: 20 20 20 20 20 20 28 64 62 3a 73 65 74 2d 63 6f        (db:set-co
4830: 6d 6d 65 6e 74 2d 66 6f 72 2d 72 75 6e 20 64 62  mment-for-run db
4840: 20 72 75 6e 2d 69 64 20 28 61 72 67 73 3a 67 65   run-id (args:ge
4850: 74 2d 61 72 67 20 22 2d 6d 22 29 29 29 0a 09 20  t-arg "-m"))).. 
4860: 20 3b 3b 20 62 72 61 69 6e 64 65 61 64 20 77 6f   ;; braindead wo
4870: 72 6b 2d 61 72 6f 75 6e 64 20 66 6f 72 20 70 6f  rk-around for po
4880: 6f 72 6c 79 20 73 70 65 63 69 66 69 65 64 20 61  orly specified a
4890: 6c 6c 69 74 65 6d 73 20 6c 69 73 74 20 42 55 47  llitems list BUG
48a0: 21 21 21 20 46 49 58 4d 45 0a 09 20 20 28 69 66  !!! FIXME..  (if
48b0: 20 28 6e 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d 73   (null? allitems
48c0: 29 28 73 65 74 21 20 61 6c 6c 69 74 65 6d 73 20  )(set! allitems 
48d0: 27 28 28 29 29 29 29 0a 09 20 20 28 6c 65 74 20  '(())))..  (let 
48e0: 6c 6f 6f 70 20 28 28 69 74 65 6d 64 61 74 20 28  loop ((itemdat (
48f0: 63 61 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09  car allitems))..
4900: 09 20 20 20 20 20 28 74 61 6c 20 20 20 20 20 28  .     (tal     (
4910: 63 64 72 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a  cdr allitems))).
4920: 09 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20  .    ;; (lambda 
4930: 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28  (itemdat) ;;; ((
4940: 72 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69  ripeness "overri
4950: 70 65 22 29 20 28 74 65 6d 70 65 72 61 74 75 72  pe") (temperatur
4960: 65 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f  e "cool") (seaso
4970: 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a 09 20 20  n "summer"))..  
4980: 20 20 3b 3b 20 48 61 6e 64 6c 65 20 6c 69 73 74    ;; Handle list
4990: 73 20 6f 66 20 69 74 65 6d 73 0a 09 20 20 20 20  s of items..    
49a0: 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74  (let* ((item-pat
49b0: 68 20 20 20 20 20 28 69 74 65 6d 2d 6c 69 73 74  h     (item-list
49c0: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  ->path itemdat))
49d0: 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69 6e 74 65   ;; (string-inte
49e0: 72 73 70 65 72 73 65 20 28 6d 61 70 20 63 61 64  rsperse (map cad
49f0: 72 20 69 74 65 6d 64 61 74 29 20 22 2f 22 29 29  r itemdat) "/"))
4a00: 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d  ...   (new-test-
4a10: 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74  path (string-int
4a20: 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74  ersperse (cons t
4a30: 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61  est-path (map ca
4a40: 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22  dr itemdat)) "/"
4a50: 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73  ))...   (new-tes
4a60: 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61  t-name (if (equa
4a70: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
4a80: 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63   test-name (conc
4a90: 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69   test-name "/" i
4aa0: 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a  tem-path))) ;; j
4ab0: 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62  ust need it to b
4ac0: 65 20 75 6e 69 71 75 65 0a 09 09 20 20 20 28 74  e unique...   (t
4ad0: 65 73 74 64 61 74 20 20 20 23 66 29 0a 09 09 20  estdat   #f)... 
4ae0: 20 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28    (num-running (
4af0: 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73  db:get-count-tes
4b00: 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a  ts-running db)).
4b10: 09 09 20 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72  ..   (max-concur
4b20: 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69  rent-jobs (confi
4b30: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
4b40: 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61  dat* "setup" "ma
4b50: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
4b60: 73 22 29 29 0a 09 09 20 20 20 28 70 61 72 65 6e  s"))...   (paren
4b70: 74 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 6f 74  t-test (and (not
4b80: 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28   (null? items))(
4b90: 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68  equal? item-path
4ba0: 20 22 22 29 29 29 0a 09 09 20 20 20 28 73 69 6e   "")))...   (sin
4bb0: 67 6c 65 2d 74 65 73 74 20 28 61 6e 64 20 28 6e  gle-test (and (n
4bc0: 75 6c 6c 3f 20 69 74 65 6d 73 29 20 28 65 71 75  ull? items) (equ
4bd0: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
4be0: 29 29 29 0a 09 09 20 20 20 28 69 74 65 6d 2d 74  )))...   (item-t
4bf0: 65 73 74 20 20 20 28 6e 6f 74 20 28 65 71 75 61  est   (not (equa
4c00: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
4c10: 29 29 29 0a 09 20 20 20 20 20 20 28 64 65 62 75  )))..      (debu
4c20: 67 3a 70 72 69 6e 74 20 33 20 22 6d 61 78 2d 63  g:print 3 "max-c
4c30: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20  oncurrent-jobs: 
4c40: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  " max-concurrent
4c50: 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e  -jobs ", num-run
4c60: 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e  ning: " num-runn
4c70: 69 6e 67 29 0a 09 20 20 20 20 20 20 28 69 66 20  ing)..      (if 
4c80: 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f  (runs:can-run-mo
4c90: 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09 09 20  re-tests db)... 
4ca0: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28 6c   (begin...    (l
4cb0: 65 74 20 6c 6f 6f 70 32 20 28 28 74 73 20 28 64  et loop2 ((ts (d
4cc0: 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20  b:get-test-info 
4cd0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
4ce0: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 20  ame item-path)) 
4cf0: 3b 3b 20 23 66 29 0a 09 09 09 09 28 63 74 20 30  ;; #f).....(ct 0
4d00: 29 29 0a 09 09 20 20 20 20 20 20 28 69 66 20 28  ))...      (if (
4d10: 61 6e 64 20 28 6e 6f 74 20 74 73 29 0a 09 09 09  and (not ts)....
4d20: 20 20 20 20 20 20 20 28 3c 20 63 74 20 31 30 29         (< ct 10)
4d30: 29 0a 09 09 09 20 20 28 62 65 67 69 6e 0a 09 09  )....  (begin...
4d40: 09 20 20 20 20 28 72 65 67 69 73 74 65 72 2d 74  .    (register-t
4d50: 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65  est db run-id te
4d60: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
4d70: 68 20 74 61 67 73 29 0a 09 09 09 20 20 20 20 28  h tags)....    (
4d80: 64 62 3a 74 65 73 74 2d 73 65 74 2d 63 6f 6d 6d  db:test-set-comm
4d90: 65 6e 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65  ent db run-id te
4da0: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
4db0: 68 20 22 22 29 0a 09 09 09 20 20 20 20 28 6c 6f  h "")....    (lo
4dc0: 6f 70 32 20 28 64 62 3a 67 65 74 2d 74 65 73 74  op2 (db:get-test
4dd0: 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20  -info db run-id 
4de0: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
4df0: 61 74 68 29 0a 09 09 09 09 20 20 20 28 2b 20 63  ath).....   (+ c
4e00: 74 20 31 29 29 29 0a 09 09 09 20 20 28 69 66 20  t 1)))....  (if 
4e10: 74 73 0a 09 09 09 20 20 20 20 20 20 28 73 65 74  ts....      (set
4e20: 21 20 74 65 73 74 64 61 74 20 74 73 29 0a 09 09  ! testdat ts)...
4e30: 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09  .      (begin...
4e40: 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
4e50: 20 22 57 41 52 4e 49 4e 47 3a 20 43 6f 75 6c 64   "WARNING: Could
4e60: 6e 27 74 20 72 65 67 69 73 74 65 72 20 74 65 73  n't register tes
4e70: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  t " test-name " 
4e80: 77 69 74 68 20 69 74 65 6d 20 70 61 74 68 20 22  with item path "
4e90: 20 69 74 65 6d 2d 70 61 74 68 20 22 2c 20 73 6b   item-path ", sk
4ea0: 69 70 70 69 6e 67 22 29 0a 09 09 09 09 28 69 66  ipping").....(if
4eb0: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c   (not (null? tal
4ec0: 29 29 0a 09 09 09 09 20 20 20 20 28 6c 6f 6f 70  )).....    (loop
4ed0: 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74   (car tal)(cdr t
4ee0: 61 6c 29 29 29 29 29 29 29 0a 09 09 20 20 20 20  al)))))))...    
4ef0: 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72  (change-director
4f00: 79 20 74 65 73 74 2d 70 61 74 68 29 0a 09 09 20  y test-path)... 
4f10: 20 20 20 3b 3b 20 74 68 69 73 20 62 6c 6f 63 6b     ;; this block
4f20: 20 69 73 20 68 65 72 65 20 6f 6e 6c 79 20 74 6f   is here only to
4f30: 20 69 6e 66 6f 72 6d 20 74 68 65 20 75 73 65 72   inform the user
4f40: 20 65 61 72 6c 79 20 6f 6e 0a 09 09 20 20 20 20   early on...    
4f50: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
4f60: 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09  ? runconfigf)...
4f70: 09 28 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61  .(setup-env-defa
4f80: 75 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69  ults db runconfi
4f90: 67 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61  gf run-id *alrea
4fa0: 64 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69  dy-seen-runconfi
4fb0: 67 2d 69 6e 66 6f 2a 29 0a 09 09 09 28 64 65 62  g-info*)....(deb
4fc0: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
4fd0: 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 20  ING: You do not 
4fe0: 68 61 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 69  have a run confi
4ff0: 67 20 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f 6e  g file: " runcon
5000: 66 69 67 66 29 29 0a 09 09 20 20 20 20 28 64 65  figf))...    (de
5010: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e  bug:print 4 "run
5020: 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 20 22 20  -id: " run-id " 
5030: 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73  test-name: " tes
5040: 74 2d 6e 61 6d 65 20 22 20 69 74 65 6d 2d 70 61  t-name " item-pa
5050: 74 68 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 20  th: " item-path 
5060: 22 20 74 65 73 74 64 61 74 3a 20 22 20 28 74 65  " testdat: " (te
5070: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
5080: 73 74 64 61 74 29 20 22 20 74 65 73 74 2d 73 74  stdat) " test-st
5090: 61 74 65 3a 20 22 20 28 74 65 73 74 3a 67 65 74  ate: " (test:get
50a0: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29  -state testdat))
50b0: 0a 09 09 20 20 20 20 28 63 61 73 65 20 28 69 66  ...    (case (if
50c0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
50d0: 2d 66 6f 72 63 65 22 29 0a 09 09 09 20 20 20 20  -force")....    
50e0: 20 20 27 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09    'NOT_STARTED..
50f0: 09 09 20 20 20 20 20 20 28 69 66 20 74 65 73 74  ..      (if test
5100: 64 61 74 0a 09 09 09 09 20 20 28 73 74 72 69 6e  dat.....  (strin
5110: 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a  g->symbol (test:
5120: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
5130: 74 29 29 0a 09 09 09 09 20 20 27 66 61 69 6c 65  t)).....  'faile
5140: 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09 09  d-to-insert))...
5150: 20 20 20 20 20 20 28 28 66 61 69 6c 65 64 2d 74        ((failed-t
5160: 6f 2d 69 6e 73 65 72 74 29 0a 09 09 20 20 20 20  o-insert)...    
5170: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
5180: 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  0 "ERROR: Failed
5190: 20 74 6f 20 69 6e 73 65 72 74 20 74 68 65 20 72   to insert the r
51a0: 65 63 6f 72 64 20 69 6e 74 6f 20 74 68 65 20 64  ecord into the d
51b0: 62 22 29 29 0a 09 09 20 20 20 20 20 20 28 28 4e  b"))...      ((N
51c0: 4f 54 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 4c  OT_STARTED COMPL
51d0: 45 54 45 44 29 0a 09 09 20 20 20 20 20 20 20 28  ETED)...       (
51e0: 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22 47  debug:print 6 "G
51f0: 6f 74 20 68 65 72 65 2c 20 22 20 28 74 65 73 74  ot here, " (test
5200: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
5210: 61 74 29 29 0a 09 09 20 20 20 20 20 20 20 28 6c  at))...       (l
5220: 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23 66 29  et ((runflag #f)
5230: 29 0a 09 09 09 20 28 63 6f 6e 64 0a 09 09 09 20  ).... (cond.... 
5240: 20 3b 3b 20 69 2e 65 2e 20 74 68 69 73 20 69 73   ;; i.e. this is
5250: 20 74 68 65 20 70 61 72 65 6e 74 20 74 65 73 74   the parent test
5260: 20 74 6f 20 61 20 73 75 69 74 65 20 6f 66 20 69   to a suite of i
5270: 74 65 6d 73 2c 20 6e 65 76 65 72 20 22 72 75 6e  tems, never "run
5280: 22 20 69 74 0a 09 09 09 20 20 28 70 61 72 65 6e  " it....  (paren
5290: 74 2d 74 65 73 74 0a 09 09 09 20 20 20 28 73 65  t-test....   (se
52a0: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a  t! runflag #f)).
52b0: 09 09 09 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20  ...  ;; -force, 
52c0: 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68  run no matter wh
52d0: 61 74 0a 09 09 09 20 20 28 28 61 72 67 73 3a 67  at....  ((args:g
52e0: 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29  et-arg "-force")
52f0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
5300: 29 29 0a 09 09 09 20 20 3b 3b 20 4e 4f 54 5f 53  ))....  ;; NOT_S
5310: 54 41 52 54 45 44 2c 20 72 75 6e 20 6e 6f 20 6d  TARTED, run no m
5320: 61 74 74 65 72 20 77 68 61 74 0a 09 09 09 20 20  atter what....  
5330: 28 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67  ((equal? (test:g
5340: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
5350: 29 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 29  ) "NOT_STARTED")
5360: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
5370: 29 29 0a 09 09 09 20 20 3b 3b 20 6e 6f 74 20 2d  ))....  ;; not -
5380: 72 65 72 75 6e 20 61 6e 64 20 50 41 53 53 2c 20  rerun and PASS, 
5390: 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 2c 20 64  WARN or CHECK, d
53a0: 6f 20 6e 6f 20 72 75 6e 0a 09 09 09 20 20 28 28  o no run....  ((
53b0: 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20 28 61 72  and (or (not (ar
53c0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72  gs:get-arg "-rer
53d0: 75 6e 22 29 29 0a 09 09 09 09 20 20 20 20 28 61  un")).....    (a
53e0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65  rgs:get-arg "-ke
53f0: 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 28  epgoing")).....(
5400: 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74  member (test:get
5410: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
5420: 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e 22   '("PASS" "WARN"
5430: 20 22 43 48 45 43 4b 22 29 29 29 0a 09 09 09 20   "CHECK"))).... 
5440: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
5450: 23 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d 72 65  #f))....  ;; -re
5460: 72 75 6e 20 61 6e 64 20 73 74 61 74 75 73 20 69  run and status i
5470: 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 73 70 65  s one of the spe
5480: 63 69 66 65 64 2c 20 72 75 6e 20 69 74 0a 09 09  cifed, run it...
5490: 09 20 20 28 28 61 6e 64 20 28 61 72 67 73 3a 67  .  ((and (args:g
54a0: 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29  et-arg "-rerun")
54b0: 0a 09 09 09 09 28 6c 65 74 20 28 28 72 65 72 75  .....(let ((reru
54c0: 6e 6c 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c  nlst (string-spl
54d0: 69 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  it (args:get-arg
54e0: 20 22 2d 72 65 72 75 6e 22 29 20 22 2c 22 29 29   "-rerun") ","))
54f0: 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 09 09 20  ) ;; FAIL,..... 
5500: 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67   (member (test:g
5510: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
5520: 74 29 20 72 65 72 75 6e 6c 73 74 29 29 29 0a 09  t) rerunlst)))..
5530: 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c  ..   (set! runfl
5540: 61 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20  ag #t))....  ;; 
5550: 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20 6e  -keepgoing, do n
5560: 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a 09 09  ot rerun FAIL...
5570: 09 20 20 28 28 61 6e 64 20 28 61 72 67 73 3a 67  .  ((and (args:g
5580: 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69  et-arg "-keepgoi
5590: 6e 67 22 29 0a 09 09 09 09 28 6d 65 6d 62 65 72  ng").....(member
55a0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
55b0: 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41  s testdat) '("FA
55c0: 49 4c 22 29 29 29 0a 09 09 09 20 20 20 28 73 65  IL")))....   (se
55d0: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a  t! runflag #f)).
55e0: 09 09 09 20 20 28 28 61 6e 64 20 28 6e 6f 74 20  ...  ((and (not 
55f0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
5600: 72 65 72 75 6e 22 29 29 0a 09 09 09 09 28 6d 65  rerun")).....(me
5610: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
5620: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27  tatus testdat) '
5630: 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 29  ("FAIL" "n/a")))
5640: 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e  ....   (set! run
5650: 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 28  flag #t))....  (
5660: 65 6c 73 65 20 28 73 65 74 21 20 72 75 6e 66 6c  else (set! runfl
5670: 61 67 20 23 66 29 29 29 0a 09 09 09 20 28 64 65  ag #f))).... (de
5680: 62 75 67 3a 70 72 69 6e 74 20 36 20 22 52 55 4e  bug:print 6 "RUN
5690: 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a  NING => runflag:
56a0: 20 22 20 72 75 6e 66 6c 61 67 20 22 20 53 54 41   " runflag " STA
56b0: 54 45 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  TE: " (test:get-
56c0: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22  state testdat) "
56d0: 20 53 54 41 54 55 53 3a 20 22 20 28 74 65 73 74   STATUS: " (test
56e0: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
56f0: 64 61 74 29 29 0a 09 09 09 20 28 69 66 20 28 6e  dat)).... (if (n
5700: 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09 09 09 20  ot runflag).... 
5710: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 70 61 72      (if (not par
5720: 65 6e 74 2d 74 65 73 74 29 0a 09 09 09 09 20 28  ent-test)..... (
5730: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e  debug:print 1 "N
5740: 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e  OTE: Not startin
5750: 67 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73  g test " new-tes
5760: 74 2d 6e 61 6d 65 20 22 20 61 73 20 69 74 20 69  t-name " as it i
5770: 73 20 73 74 61 74 65 20 5c 22 43 4f 4d 50 4c 45  s state \"COMPLE
5780: 54 45 44 5c 22 20 61 6e 64 20 73 74 61 74 75 73  TED\" and status
5790: 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73   \"" (test:get-s
57a0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 22  tatus testdat) "
57b0: 5c 22 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74  \", use -force t
57c0: 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a 09 09  o override"))...
57d0: 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28 67 65  .     (let* ((ge
57e0: 74 2d 70 72 65 72 65 71 73 2d 63 6d 64 20 28 6c  t-prereqs-cmd (l
57f0: 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09 09 20  ambda ()....... 
5800: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 70 72        (db-get-pr
5810: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62  ereqs-not-met db
5820: 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 29 29   run-id waiton))
5830: 29 20 3b 3b 20 63 68 65 63 6b 20 62 65 66 6f 72  ) ;; check befor
5840: 65 20 72 75 6e 6e 69 6e 67 20 2e 2e 2e 2e 0a 09  e running ......
5850: 09 09 09 20 20 20 20 28 6c 61 75 6e 63 68 2d 63  ...    (launch-c
5860: 6d 64 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20  md      (lambda 
5870: 28 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20  ().......       
5880: 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62 20  (launch-test db 
5890: 72 75 6e 2d 69 64 20 74 65 73 74 2d 63 6f 6e 66  run-id test-conf
58a0: 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d   keyvallst test-
58b0: 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68 20 69  name test-path i
58c0: 74 65 6d 64 61 74 29 29 29 0a 09 09 09 09 20 20  temdat))).....  
58d0: 20 20 28 74 65 73 74 72 75 6e 64 61 74 20 20 20    (testrundat   
58e0: 20 20 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65     (list get-pre
58f0: 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d  reqs-cmd launch-
5900: 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20 20  cmd)))....      
5910: 20 28 69 66 20 28 6f 72 20 28 61 72 67 73 3a 67   (if (or (args:g
5920: 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29  et-arg "-force")
5930: 0a 09 09 09 09 20 20 20 20 20 20 20 28 6e 75 6c  .....       (nul
5940: 6c 3f 20 28 28 63 61 72 20 74 65 73 74 72 75 6e  l? ((car testrun
5950: 64 61 74 29 29 29 29 20 3b 3b 20 61 72 65 20 74  dat)))) ;; are t
5960: 68 65 72 65 20 61 6e 79 20 74 65 73 74 73 20 74  here any tests t
5970: 68 61 74 20 6d 75 73 74 20 62 65 20 72 75 6e 20  hat must be run 
5980: 62 65 66 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e  before this one.
5990: 2e 2e 0a 09 09 09 09 20 20 20 28 69 66 20 28 6e  .......   (if (n
59a0: 6f 74 20 28 28 63 61 64 72 20 74 65 73 74 72 75  ot ((cadr testru
59b0: 6e 64 61 74 29 29 29 20 3b 3b 20 74 68 69 73 20  ndat))) ;; this 
59c0: 69 73 20 74 68 65 20 6c 69 6e 65 20 74 68 61 74  is the line that
59d0: 20 6c 61 75 6e 63 68 65 73 20 74 68 65 20 74 65   launches the te
59e0: 73 74 20 74 6f 20 74 68 65 20 72 65 6d 6f 74 65  st to the remote
59f0: 20 68 6f 73 74 0a 09 09 09 09 20 20 20 20 20 20   host.....      
5a00: 20 28 62 65 67 69 6e 0a 09 09 09 09 09 20 28 70   (begin...... (p
5a10: 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 46 61 69  rint "ERROR: Fai
5a20: 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 68  led to launch th
5a30: 65 20 74 65 73 74 2e 20 45 78 69 74 69 6e 67 20  e test. Exiting 
5a40: 61 73 20 73 6f 6f 6e 20 61 73 20 70 6f 73 73 69  as soon as possi
5a50: 62 6c 65 22 29 0a 09 09 09 09 09 20 28 73 65 74  ble")...... (set
5a60: 21 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61  ! *globalexitsta
5a70: 74 75 73 2a 20 31 29 20 3b 3b 20 0a 09 09 09 09  tus* 1) ;; .....
5a80: 09 20 28 70 72 6f 63 65 73 73 2d 73 69 67 6e 61  . (process-signa
5a90: 6c 20 28 63 75 72 72 65 6e 74 2d 70 72 6f 63 65  l (current-proce
5aa0: 73 73 2d 69 64 29 20 73 69 67 6e 61 6c 2f 6b 69  ss-id) signal/ki
5ab0: 6c 6c 29 0a 09 09 09 09 09 20 3b 28 65 78 69 74  ll)...... ;(exit
5ac0: 20 31 29 0a 09 09 09 09 09 20 29 29 0a 09 09 09   1)...... ))....
5ad0: 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 61 72  .   (if (not (ar
5ae0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65  gs:get-arg "-kee
5af0: 70 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 20 20  pgoing")).....  
5b00: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
5b10: 2d 73 65 74 21 20 2a 77 61 69 74 69 6e 67 2d 71  -set! *waiting-q
5b20: 75 65 75 65 2a 20 6e 65 77 2d 74 65 73 74 2d 6e  ueue* new-test-n
5b30: 61 6d 65 20 74 65 73 74 72 75 6e 64 61 74 29 29  ame testrundat))
5b40: 29 29 29 29 29 0a 09 09 20 20 20 20 20 20 28 28  )))))...      ((
5b50: 4b 49 4c 4c 45 44 29 20 0a 09 09 20 20 20 20 20  KILLED) ...     
5b60: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
5b70: 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65   "NOTE: " new-te
5b80: 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72  st-name " is alr
5b90: 65 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20  eady running or 
5ba0: 77 61 73 20 65 78 70 6c 69 63 74 6c 79 20 6b 69  was explictly ki
5bb0: 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 63 65  lled, use -force
5bc0: 20 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22 29   to launch it.")
5bd0: 29 0a 09 09 20 20 20 20 20 20 28 28 4c 41 55 4e  )...      ((LAUN
5be0: 43 48 45 44 20 52 45 4d 4f 54 45 48 4f 53 54 53  CHED REMOTEHOSTS
5bf0: 54 41 52 54 20 52 55 4e 4e 49 4e 47 29 20 20 0a  TART RUNNING)  .
5c00: 09 09 20 20 20 20 20 20 20 28 69 66 20 28 3e 20  ..       (if (> 
5c10: 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f  (- (current-seco
5c20: 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73 74 2d  nds)(+ (db:test-
5c30: 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74  get-event_time t
5c40: 65 73 74 64 61 74 29 0a 09 09 09 09 09 09 20 20  estdat).......  
5c50: 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d     (db:test-get-
5c60: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65 73  run_duration tes
5c70: 74 64 61 74 29 29 29 0a 09 09 09 20 20 20 20 20  tdat)))....     
5c80: 20 31 30 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f   100) ;; i.e. no
5c90: 20 75 70 64 61 74 65 20 66 6f 72 20 6d 6f 72 65   update for more
5ca0: 20 74 68 61 6e 20 31 30 30 20 73 65 63 6f 6e 64   than 100 second
5cb0: 73 0a 09 09 09 20 20 20 28 62 65 67 69 6e 0a 09  s....   (begin..
5cc0: 09 09 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  ..     (debug:pr
5cd0: 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20  int 0 "WARNING: 
5ce0: 54 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65  Test " test-name
5cf0: 20 22 20 61 70 70 65 61 72 73 20 74 6f 20 62 65   " appears to be
5d00: 20 64 65 61 64 2e 20 46 6f 72 63 69 6e 67 20 69   dead. Forcing i
5d10: 74 20 74 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d  t to state INCOM
5d20: 50 4c 45 54 45 20 61 6e 64 20 73 74 61 74 75 73  PLETE and status
5d30: 20 53 54 55 43 4b 2f 44 45 41 44 22 29 0a 09 09   STUCK/DEAD")...
5d40: 09 20 20 20 20 20 28 74 65 73 74 2d 73 65 74 2d  .     (test-set-
5d50: 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d 69  status! db run-i
5d60: 64 20 74 65 73 74 2d 6e 61 6d 65 20 22 49 4e 43  d test-name "INC
5d70: 4f 4d 50 4c 45 54 45 22 20 22 53 54 55 43 4b 2f  OMPLETE" "STUCK/
5d80: 44 45 41 44 22 20 69 74 65 6d 64 61 74 20 22 54  DEAD" itemdat "T
5d90: 65 73 74 20 69 73 20 73 74 75 63 6b 20 6f 72 20  est is stuck or 
5da0: 64 65 61 64 22 29 29 0a 09 09 09 20 20 20 28 64  dead"))....   (d
5db0: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f  ebug:print 2 "NO
5dc0: 54 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  TE: " test-name 
5dd0: 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e  " is already run
5de0: 6e 69 6e 67 22 29 29 29 0a 09 09 20 20 20 20 20  ning")))...     
5df0: 20 28 65 6c 73 65 20 20 20 20 20 20 20 28 64 65   (else       (de
5e00: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
5e10: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61  OR: Failed to la
5e20: 75 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d  unch test " new-
5e30: 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72  test-name ". Unr
5e40: 65 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20  ecognised state 
5e50: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
5e60: 65 20 74 65 73 74 64 61 74 29 29 29 29 29 29 0a  e testdat)))))).
5e70: 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20  .      (if (not 
5e80: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20  (null? tal))... 
5e90: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
5ea0: 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 29  (cdr tal))))))))
5eb0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d  )..(define (run-
5ec0: 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62  waiting-tests db
5ed0: 29 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 74 72  ).  (let ((numtr
5ee0: 69 65 73 20 20 20 20 20 20 20 20 20 20 20 30 29  ies           0)
5ef0: 0a 09 28 6c 61 73 74 2d 74 72 79 2d 74 69 6d 65  ..(last-try-time
5f00: 20 20 20 20 20 20 28 63 75 72 72 65 6e 74 2d 73        (current-s
5f10: 65 63 6f 6e 64 73 29 29 0a 09 28 74 69 6d 65 73  econds))..(times
5f20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6c                (l
5f30: 69 73 74 20 31 29 29 29 20 3b 3b 20 6d 69 6e 75  ist 1))) ;; minu
5f40: 74 65 73 20 74 6f 20 77 61 69 74 20 62 65 66 6f  tes to wait befo
5f50: 72 65 20 74 72 79 69 6e 67 20 61 67 61 69 6e 20  re trying again 
5f60: 74 6f 20 6b 69 63 6b 20 6f 66 66 20 72 75 6e 73  to kick off runs
5f70: 0a 20 20 20 20 3b 3b 20 42 55 47 20 74 68 69 73  .    ;; BUG this
5f80: 20 68 61 63 6b 20 6f 66 20 62 72 75 74 65 20 66   hack of brute f
5f90: 6f 72 63 65 20 72 65 74 72 79 69 6e 67 20 77 6f  orce retrying wo
5fa0: 72 6b 73 20 71 75 69 74 65 20 77 65 6c 6c 20 66  rks quite well f
5fb0: 6f 72 20 6d 61 6e 79 20 63 61 73 65 73 20 62 75  or many cases bu
5fc0: 74 20 0a 20 20 20 20 3b 3b 20 20 20 20 20 77 68  t .    ;;     wh
5fd0: 61 74 20 69 73 20 6e 65 65 64 65 64 20 69 73 20  at is needed is 
5fe0: 74 6f 20 63 68 65 63 6b 20 74 68 65 20 64 62 20  to check the db 
5ff0: 66 6f 72 20 74 65 73 74 73 20 74 68 61 74 20 68  for tests that h
6000: 61 76 65 20 66 61 69 6c 65 64 20 6c 65 73 73 20  ave failed less 
6010: 74 68 61 6e 0a 20 20 20 20 3b 3b 20 20 20 20 20  than.    ;;     
6020: 4e 20 74 69 6d 65 73 20 6f 72 20 6e 65 76 65 72  N times or never
6030: 20 62 65 65 6e 20 73 74 61 72 74 65 64 20 61 6e   been started an
6040: 64 20 6b 69 63 6b 20 74 68 65 6d 20 6f 66 66 20  d kick them off 
6050: 61 67 61 69 6e 0a 20 20 20 20 28 6c 65 74 20 6c  again.    (let l
6060: 6f 6f 70 20 28 28 77 61 69 74 69 6e 67 2d 74 65  oop ((waiting-te
6070: 73 74 2d 6e 61 6d 65 73 20 28 68 61 73 68 2d 74  st-names (hash-t
6080: 61 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69  able-keys *waiti
6090: 6e 67 2d 71 75 65 75 65 2a 29 29 29 0a 20 20 20  ng-queue*))).   
60a0: 20 20 20 28 63 6f 6e 64 0a 20 20 20 20 20 20 20     (cond.       
60b0: 28 28 6e 6f 74 20 28 72 75 6e 73 3a 63 61 6e 2d  ((not (runs:can-
60c0: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64  run-more-tests d
60d0: 62 29 29 0a 09 28 73 6c 65 65 70 20 32 29 0a 09  b))..(sleep 2)..
60e0: 28 6c 6f 6f 70 20 77 61 69 74 69 6e 67 2d 74 65  (loop waiting-te
60f0: 73 74 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20 20  st-names)).     
6100: 20 20 28 28 6e 75 6c 6c 3f 20 77 61 69 74 69 6e    ((null? waitin
6110: 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09 28  g-test-names)..(
6120: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 41  debug:print 1 "A
6130: 6c 6c 20 74 65 73 74 73 20 6c 61 75 6e 63 68 65  ll tests launche
6140: 64 22 29 29 0a 20 20 20 20 20 20 20 28 65 6c 73  d")).       (els
6150: 65 0a 09 28 73 65 74 21 20 6e 75 6d 74 72 69 65  e..(set! numtrie
6160: 73 20 28 2b 20 6e 75 6d 74 72 69 65 73 20 31 29  s (+ numtries 1)
6170: 29 0a 09 28 66 6f 72 2d 65 61 63 68 20 28 6c 61  )..(for-each (la
6180: 6d 62 64 61 20 28 74 65 73 74 6e 61 6d 65 29 0a  mbda (testname).
6190: 09 09 20 20 20 20 28 69 66 20 28 72 75 6e 73 3a  ..    (if (runs:
61a0: 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73  can-run-more-tes
61b0: 74 73 20 64 62 29 0a 09 09 09 28 6c 65 74 2a 20  ts db)....(let* 
61c0: 28 28 74 65 73 74 64 61 74 20 28 68 61 73 68 2d  ((testdat (hash-
61d0: 74 61 62 6c 65 2d 72 65 66 20 2a 77 61 69 74 69  table-ref *waiti
61e0: 6e 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e 61  ng-queue* testna
61f0: 6d 65 29 29 0a 09 09 09 20 20 20 20 20 20 20 28  me))....       (
6200: 70 72 65 72 65 71 73 20 28 28 63 61 72 20 74 65  prereqs ((car te
6210: 73 74 64 61 74 29 29 29 0a 09 09 09 20 20 20 20  stdat)))....    
6220: 20 20 20 28 6c 64 62 20 20 20 20 20 28 69 66 20     (ldb     (if 
6230: 64 62 20 64 62 20 28 6f 70 65 6e 2d 64 62 29 29  db db (open-db))
6240: 29 29 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70  ))....  (debug:p
6250: 72 69 6e 74 20 32 20 22 70 72 65 72 65 71 73 20  rint 2 "prereqs 
6260: 72 65 6d 61 69 6e 69 6e 67 3a 20 22 20 70 72 65  remaining: " pre
6270: 72 65 71 73 29 0a 09 09 09 20 20 28 69 66 20 28  reqs)....  (if (
6280: 6e 75 6c 6c 3f 20 70 72 65 72 65 71 73 29 0a 09  null? prereqs)..
6290: 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  ..      (begin..
62a0: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  ...(debug:print 
62b0: 32 20 22 50 72 65 72 65 71 75 69 73 69 74 65 73  2 "Prerequisites
62c0: 20 6d 65 74 2c 20 6c 61 75 6e 63 68 69 6e 67 20   met, launching 
62d0: 22 20 74 65 73 74 6e 61 6d 65 29 0a 09 09 09 09  " testname).....
62e0: 28 28 63 61 64 72 20 74 65 73 74 64 61 74 29 29  ((cadr testdat))
62f0: 0a 09 09 09 09 28 68 61 73 68 2d 74 61 62 6c 65  .....(hash-table
6300: 2d 64 65 6c 65 74 65 21 20 2a 77 61 69 74 69 6e  -delete! *waitin
6310: 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d  g-queue* testnam
6320: 65 29 29 29 0a 09 09 09 20 20 28 69 66 20 28 6e  e)))....  (if (n
6330: 6f 74 20 64 62 29 0a 09 09 09 20 20 20 20 20 20  ot db)....      
6340: 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a  (sqlite3:finaliz
6350: 65 21 20 6c 64 62 29 29 29 29 29 0a 09 09 20 20  e! ldb)))))...  
6360: 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d  waiting-test-nam
6370: 65 73 29 0a 09 3b 3b 20 28 73 6c 65 65 70 20 31  es)..;; (sleep 1
6380: 30 29 20 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69  0) ;; no point i
6390: 6e 20 72 75 73 68 69 6e 67 20 74 68 69 6e 67 73  n rushing things
63a0: 20 61 74 20 74 68 69 73 20 73 74 61 67 65 3f 0a   at this stage?.
63b0: 09 28 6c 6f 6f 70 20 28 68 61 73 68 2d 74 61 62  .(loop (hash-tab
63c0: 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67  le-keys *waiting
63d0: 2d 71 75 65 75 65 2a 29 29 29 29 29 29 29 0a 0a  -queue*)))))))..
63e0: 28 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72  (define (get-dir
63f0: 2d 75 70 2d 6e 20 64 69 72 20 2e 20 70 61 72 61  -up-n dir . para
6400: 6d 73 29 20 0a 20 20 28 6c 65 74 20 28 28 64 70  ms) .  (let ((dp
6410: 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70  arts  (string-sp
6420: 6c 69 74 20 64 69 72 20 22 2f 22 29 29 0a 09 28  lit dir "/"))..(
6430: 63 6f 75 6e 74 20 20 20 28 69 66 20 28 6e 75 6c  count   (if (nul
6440: 6c 3f 20 70 61 72 61 6d 73 29 20 31 20 28 63 61  l? params) 1 (ca
6450: 72 20 70 61 72 61 6d 73 29 29 29 29 0a 20 20 20  r params)))).   
6460: 20 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69   (conc "/" (stri
6470: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a  ng-intersperse .
6480: 09 20 20 20 20 20 20 20 28 74 61 6b 65 20 64 70  .       (take dp
6490: 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20  arts (- (length 
64a0: 64 70 61 72 74 73 29 20 63 6f 75 6e 74 29 29 0a  dparts) count)).
64b0: 09 20 20 20 20 20 20 20 22 2f 22 29 29 29 29 0a  .       "/")))).
64c0: 3b 3b 20 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b  ;; Remove runs.;
64d0: 3b 20 66 69 65 6c 64 73 20 61 72 65 20 70 61 73  ; fields are pas
64e0: 73 69 6e 67 20 69 6e 20 74 68 72 6f 75 67 68 20  sing in through 
64f0: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72  .(define (runs:r
6500: 65 6d 6f 76 65 2d 72 75 6e 73 20 64 62 20 72 75  emove-runs db ru
6510: 6e 6e 61 6d 65 70 61 74 74 20 74 65 73 74 70 61  nnamepatt testpa
6520: 74 74 20 69 74 65 6d 70 61 74 74 29 0a 20 20 28  tt itempatt).  (
6530: 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20  let* ((keys     
6540: 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20     (db-get-keys 
6550: 64 62 29 29 0a 09 20 28 72 75 6e 64 61 74 20 20  db)).. (rundat  
6560: 20 20 20 20 28 72 75 6e 73 3a 67 65 74 2d 72 75      (runs:get-ru
6570: 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20 6b 65  ns-by-patt db ke
6580: 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74 29 29  ys runnamepatt))
6590: 0a 09 20 28 68 65 61 64 65 72 20 20 20 20 20 20  .. (header      
65a0: 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64  (vector-ref rund
65b0: 61 74 20 30 29 29 0a 09 20 28 72 75 6e 73 20 20  at 0)).. (runs  
65c0: 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65        (vector-re
65d0: 66 20 72 75 6e 64 61 74 20 31 29 29 29 0a 20 20  f rundat 1))).  
65e0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
65f0: 20 22 48 65 61 64 65 72 3a 20 22 20 68 65 61 64   "Header: " head
6600: 65 72 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  er).    (for-eac
6610: 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  h.     (lambda (
6620: 72 75 6e 29 0a 20 20 20 20 20 20 20 28 6c 65 74  run).       (let
6630: 20 28 28 72 75 6e 6b 65 79 20 28 73 74 72 69 6e   ((runkey (strin
6640: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d  g-intersperse (m
6650: 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09  ap (lambda (k)..
6660: 09 09 09 09 09 28 64 62 3a 67 65 74 2d 76 61 6c  .....(db:get-val
6670: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
6680: 20 68 65 61 64 65 72 20 28 76 65 63 74 6f 72 2d   header (vector-
6690: 72 65 66 20 6b 20 30 29 29 29 20 6b 65 79 73 29  ref k 0))) keys)
66a0: 20 22 2f 22 29 29 29 0a 09 20 28 6c 65 74 2a 20   "/"))).. (let* 
66b0: 28 28 72 75 6e 2d 69 64 20 28 64 62 3a 67 65 74  ((run-id (db:get
66c0: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
66d0: 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22   run header "id"
66e0: 29 20 29 0a 09 09 28 74 65 73 74 73 20 20 28 64  ) )...(tests  (d
66f0: 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d  b-get-tests-for-
6700: 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76  run db (db:get-v
6710: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
6720: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20  un header "id") 
6730: 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 74  testpatt itempat
6740: 74 29 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68  t))...(lasttpath
6750: 20 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73   "/does/not/exis
6760: 74 2f 49 2f 68 6f 70 65 22 29 29 0a 09 20 20 20  t/I/hope"))..   
6770: 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  (if (not (null? 
6780: 74 65 73 74 73 29 29 0a 09 20 20 20 20 20 20 20  tests))..       
6790: 28 62 65 67 69 6e 0a 09 09 20 28 64 65 62 75 67  (begin... (debug
67a0: 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69  :print 1 "Removi
67b0: 6e 67 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e  ng tests for run
67c0: 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28  : " runkey " " (
67d0: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
67e0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
67f0: 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09  r "runname"))...
6800: 20 28 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 28   (for-each...  (
6810: 6c 61 6d 62 64 61 20 28 74 65 73 74 29 0a 09 09  lambda (test)...
6820: 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d      (let* ((item
6830: 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  -path (db:test-g
6840: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
6850: 74 29 29 0a 09 09 09 20 20 20 28 74 65 73 74 2d  t))....   (test-
6860: 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65  name (db:test-ge
6870: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
6880: 29 0a 09 09 09 20 20 20 28 72 75 6e 2d 64 69 72  )....   (run-dir
6890: 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d     (db:test-get-
68a0: 72 75 6e 64 69 72 20 74 65 73 74 29 29 29 0a 09  rundir test)))..
68b0: 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
68c0: 69 6e 74 20 31 20 22 20 20 22 20 28 64 62 3a 74  int 1 "  " (db:t
68d0: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
68e0: 20 74 65 73 74 29 20 22 20 69 64 3a 20 22 20 28   test) " id: " (
68f0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
6900: 65 73 74 29 20 22 20 22 20 69 74 65 6d 2d 70 61  est) " " item-pa
6910: 74 68 29 0a 09 09 20 20 20 20 20 20 28 64 62 3a  th)...      (db:
6920: 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65 63 6f  delete-test-reco
6930: 72 64 73 20 64 62 20 28 64 62 3a 74 65 73 74 2d  rds db (db:test-
6940: 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a 09 09  get-id test))...
6950: 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 73 74        (if (> (st
6960: 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e 2d  ring-length run-
6970: 64 69 72 29 20 35 29 20 3b 3b 20 62 61 64 20 68  dir) 5) ;; bad h
6980: 65 75 72 69 73 74 69 63 20 62 75 74 20 73 68 6f  euristic but sho
6990: 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74 6d 70  uld prevent /tmp
69a0: 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09 20   /home etc..... 
69b0: 20 28 6c 65 74 20 28 28 66 75 6c 6c 70 61 74 68   (let ((fullpath
69c0: 20 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20 22 2f   run-dir)) ;; "/
69d0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
69e0: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 29  tem-path test)))
69f0: 29 0a 09 09 09 20 20 20 20 28 73 65 74 21 20 6c  )....    (set! l
6a00: 61 73 74 74 70 61 74 68 20 66 75 6c 6c 70 61 74  asttpath fullpat
6a10: 68 29 0a 09 09 09 20 20 20 20 28 64 65 62 75 67  h)....    (debug
6a20: 3a 70 72 69 6e 74 20 31 20 22 72 6d 20 2d 72 66  :print 1 "rm -rf
6a30: 20 22 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09   " fullpath)....
6a40: 20 20 20 20 28 73 79 73 74 65 6d 20 28 63 6f 6e      (system (con
6a50: 63 20 22 72 6d 20 2d 72 66 20 22 20 66 75 6c 6c  c "rm -rf " full
6a60: 70 61 74 68 29 29 0a 09 09 09 20 20 20 20 28 6c  path))....    (l
6a70: 65 74 2a 20 28 28 64 69 72 73 2d 63 6f 75 6e 74  et* ((dirs-count
6a80: 20 28 2b 20 31 20 28 6c 65 6e 67 74 68 20 6b 65   (+ 1 (length ke
6a90: 79 73 29 28 6c 65 6e 67 74 68 20 28 73 74 72 69  ys)(length (stri
6aa0: 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61  ng-split item-pa
6ab0: 74 68 20 22 2f 22 29 29 29 29 0a 09 09 09 09 20  th "/"))))..... 
6ac0: 20 20 28 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67    (dir-to-rem (g
6ad0: 65 74 2d 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c  et-dir-up-n full
6ae0: 70 61 74 68 20 64 69 72 73 2d 63 6f 75 6e 74 29  path dirs-count)
6af0: 29 0a 09 09 09 09 20 20 20 28 72 65 6d 61 69 6e  ).....   (remain
6b00: 69 6e 67 64 20 28 73 74 72 69 6e 67 2d 73 75 62  ingd (string-sub
6b10: 73 74 69 74 75 74 65 20 28 72 65 67 65 78 70 20  stitute (regexp 
6b20: 28 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d 74 6f  (conc "^" dir-to
6b30: 2d 72 65 6d 20 22 2f 22 29 29 20 22 22 20 66 75  -rem "/")) "" fu
6b40: 6c 6c 70 61 74 68 29 29 0a 09 09 09 09 20 20 20  llpath)).....   
6b50: 28 63 6d 64 20 28 63 6f 6e 63 20 22 63 64 20 22  (cmd (conc "cd "
6b60: 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 3b 20 72   dir-to-rem "; r
6b70: 6d 64 69 72 20 2d 70 20 22 20 72 65 6d 61 69 6e  mdir -p " remain
6b80: 69 6e 67 64 20 29 29 29 0a 09 09 09 20 20 20 20  ingd )))....    
6b90: 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73    (if (file-exis
6ba0: 74 73 3f 20 66 75 6c 6c 70 61 74 68 29 0a 09 09  ts? fullpath)...
6bb0: 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 09 20  ..  (begin..... 
6bc0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
6bd0: 31 20 63 6d 64 29 0a 09 09 09 09 20 20 20 20 28  1 cmd).....    (
6be0: 73 79 73 74 65 6d 20 63 6d 64 29 29 29 0a 09 09  system cmd)))...
6bf0: 09 20 20 20 20 20 20 29 29 0a 09 09 09 20 20 20  .      ))....   
6c00: 20 29 29 29 0a 09 09 20 20 20 20 74 65 73 74 73   )))...    tests
6c10: 29 29 29 0a 09 20 20 20 28 6c 65 74 20 28 28 72  )))..   (let ((r
6c20: 65 6d 74 65 73 74 73 20 28 64 62 2d 67 65 74 2d  emtests (db-get-
6c30: 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62  tests-for-run db
6c40: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
6c50: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
6c60: 64 65 72 20 22 69 64 22 29 29 29 29 0a 09 20 20  der "id"))))..  
6c70: 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 72 65     (if (null? re
6c80: 6d 74 65 73 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f  mtests) ;; no mo
6c90: 72 65 20 74 65 73 74 73 20 72 65 6d 61 69 6e 69  re tests remaini
6ca0: 6e 67 0a 09 09 20 28 6c 65 74 2a 20 28 28 64 70  ng... (let* ((dp
6cb0: 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70  arts  (string-sp
6cc0: 6c 69 74 20 6c 61 73 74 74 70 61 74 68 20 22 2f  lit lasttpath "/
6cd0: 22 29 29 0a 09 09 09 28 72 75 6e 70 61 74 68 20  "))....(runpath 
6ce0: 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e  (conc "/" (strin
6cf0: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09  g-intersperse ..
6d00: 09 09 09 09 20 20 20 20 28 74 61 6b 65 20 64 70  ....    (take dp
6d10: 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20  arts (- (length 
6d20: 64 70 61 72 74 73 29 20 31 29 29 0a 09 09 09 09  dparts) 1)).....
6d30: 09 20 20 20 20 22 2f 22 29 29 29 29 0a 09 09 20  .    "/"))))... 
6d40: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
6d50: 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 3a 20   "Removing run: 
6d60: 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28 64 62  " runkey " " (db
6d70: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
6d80: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
6d90: 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09 20 20  "runname"))...  
6da0: 20 28 64 62 3a 64 65 6c 65 74 65 2d 72 75 6e 20   (db:delete-run 
6db0: 64 62 20 72 75 6e 2d 69 64 29 0a 09 09 20 20 20  db run-id)...   
6dc0: 3b 3b 20 6e 65 65 64 20 74 6f 20 66 69 67 75 72  ;; need to figur
6dd0: 65 20 6f 75 74 20 74 68 65 20 70 61 74 68 20 74  e out the path t
6de0: 6f 20 74 68 65 20 72 75 6e 20 64 69 72 20 61 6e  o the run dir an
6df0: 64 20 72 65 6d 6f 76 65 20 69 74 20 69 66 20 65  d remove it if e
6e00: 6d 70 74 79 0a 09 09 20 20 20 3b 3b 20 20 20 20  mpty...   ;;    
6e10: 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67 6c 6f 62  (if (null? (glob
6e20: 20 28 63 6f 6e 63 20 72 75 6e 70 61 74 68 20 22   (conc runpath "
6e30: 2f 2a 22 29 29 29 0a 09 09 20 20 20 3b 3b 20 20  /*")))...   ;;  
6e40: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 20        (begin... 
6e50: 20 20 3b 3b 20 09 20 28 64 65 62 75 67 3a 70 72    ;; . (debug:pr
6e60: 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20  int 1 "Removing 
6e70: 72 75 6e 20 64 69 72 20 22 20 72 75 6e 70 61 74  run dir " runpat
6e80: 68 29 0a 09 09 20 20 20 3b 3b 20 09 20 28 73 79  h)...   ;; . (sy
6e90: 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 64 69  stem (conc "rmdi
6ea0: 72 20 2d 70 20 22 20 72 75 6e 70 61 74 68 29 29  r -p " runpath))
6eb0: 29 29 0a 09 09 20 20 20 29 29 29 29 0a 09 20 29  ))...   )))).. )
6ec0: 29 0a 20 20 20 20 20 72 75 6e 73 29 29 29 0a     ).     runs))).