Megatest

Hex Artifact Content
Login

Artifact 40e5373888f359d363f1f5a3f285c2f747b6ca87:


0000: 0a 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30  .;; Copyright 20
0010: 30 36 2d 32 30 31 31 2c 20 4d 61 74 74 68 65 77  06-2011, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b   Welland..;; .;;
0030: 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69    This program i
0040: 73 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65  s made available
0050: 20 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47   under the GNU G
0060: 50 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f  PL version 2.0 o
0070: 72 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53  r.;;  greater. S
0080: 65 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79  ee the accompany
0090: 69 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47  ing file COPYING
00a0: 20 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b   for details..;;
00b0: 20 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72   .;;  This progr
00c0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65  am is distribute
00d0: 64 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41  d WITHOUT ANY WA
00e0: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20  RRANTY; without 
00f0: 65 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70  even the.;;  imp
0100: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66  lied warranty of
0110: 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59   MERCHANTABILITY
0120: 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20   or FITNESS FOR 
0130: 41 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20  A PARTICULAR.;; 
0140: 20 50 55 52 50 4f 53 45 2e 0a 0a 3b 3b 20 20 73   PURPOSE...;;  s
0150: 74 72 66 74 69 6d 65 28 27 25 6d 2f 25 64 2f 25  trftime('%m/%d/%
0160: 59 20 25 48 3a 25 4d 3a 25 53 27 2c 27 6e 6f 77  Y %H:%M:%S','now
0170: 27 2c 27 6c 6f 63 61 6c 74 69 6d 65 27 29 0a 0a  ','localtime')..
0180: 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20 74 65  ;; register a te
0190: 73 74 20 72 75 6e 20 77 69 74 68 20 74 68 65 20  st run with the 
01a0: 64 62 0a 28 64 65 66 69 6e 65 20 28 72 65 67 69  db.(define (regi
01b0: 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73  ster-run db keys
01c0: 29 20 3b 3b 20 74 65 73 74 2d 6e 61 6d 65 29 0a  ) ;; test-name).
01d0: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 74 72    (let* ((keystr
01e0: 20 20 20 20 28 6b 65 79 73 2d 3e 6b 65 79 73 74      (keys->keyst
01f0: 72 20 6b 65 79 73 29 29 0a 09 20 28 63 6f 6d 6d  r keys)).. (comm
0200: 61 20 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65  a     (if (> (le
0210: 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20 22 2c  ngth keys) 0) ",
0220: 22 20 22 22 29 29 0a 09 20 28 61 6e 64 73 74 72  " "")).. (andstr
0230: 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e 67      (if (> (leng
0240: 74 68 20 6b 65 79 73 29 20 30 29 20 22 20 41 4e  th keys) 0) " AN
0250: 44 20 22 20 22 22 29 29 0a 09 20 28 76 61 6c 73  D " "")).. (vals
0260: 6c 6f 74 73 20 20 28 6b 65 79 73 2d 3e 76 61 6c  lots  (keys->val
0270: 73 6c 6f 74 73 20 6b 65 79 73 29 29 20 3b 3b 20  slots keys)) ;; 
0280: 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20 28 6b 65 79  ?,?,? ..... (key
0290: 76 61 6c 6c 73 74 20 28 6b 65 79 73 2d 3e 76 61  vallst (keys->va
02a0: 6c 6c 69 73 74 20 6b 65 79 73 29 29 20 3b 3b 20  llist keys)) ;; 
02b0: 65 78 74 72 61 63 74 73 20 74 68 65 20 76 61 6c  extracts the val
02c0: 75 65 73 20 66 72 6f 6d 20 72 65 6d 61 69 6e 64  ues from remaind
02d0: 65 72 20 6f 66 20 28 61 72 67 76 29 0a 09 20 28  er of (argv).. (
02e0: 72 75 6e 6e 61 6d 65 20 20 20 28 67 65 74 2d 77  runname   (get-w
02f0: 69 74 68 2d 64 65 66 61 75 6c 74 20 22 3a 72 75  ith-default ":ru
0300: 6e 6e 61 6d 65 22 20 23 66 29 29 0a 09 20 28 73  nname" #f)).. (s
0310: 74 61 74 65 20 20 20 20 20 28 67 65 74 2d 77 69  tate     (get-wi
0320: 74 68 2d 64 65 66 61 75 6c 74 20 22 3a 73 74 61  th-default ":sta
0330: 74 65 22 20 22 6e 6f 22 29 29 0a 09 20 28 73 74  te" "no")).. (st
0340: 61 74 75 73 20 20 20 20 28 67 65 74 2d 77 69 74  atus    (get-wit
0350: 68 2d 64 65 66 61 75 6c 74 20 22 3a 73 74 61 74  h-default ":stat
0360: 75 73 22 20 22 6e 2f 61 22 29 29 0a 09 20 28 61  us" "n/a")).. (a
0370: 6c 6c 76 61 6c 73 20 20 20 28 61 70 70 65 6e 64  llvals   (append
0380: 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65 20 73   (list runname s
0390: 74 61 74 65 20 73 74 61 74 75 73 20 75 73 65 72  tate status user
03a0: 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20  ) keyvallst)).. 
03b0: 28 71 72 79 76 61 6c 73 20 20 20 28 61 70 70 65  (qryvals   (appe
03c0: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65  nd (list runname
03d0: 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20  ) keyvallst)).. 
03e0: 28 6b 65 79 3d 3f 73 74 72 20 20 28 73 74 72 69  (key=?str  (stri
03f0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28  ng-intersperse (
0400: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 28  map (lambda (k)(
0410: 63 6f 6e 63 20 28 6b 65 79 3a 67 65 74 2d 66 69  conc (key:get-fi
0420: 65 6c 64 6e 61 6d 65 20 6b 29 20 22 3d 3f 22 29  eldname k) "=?")
0430: 29 20 6b 65 79 73 29 20 22 20 41 4e 44 20 22 29  ) keys) " AND ")
0440: 29 29 0a 20 20 20 20 3b 3b 20 28 70 72 69 6e 74  )).    ;; (print
0450: 20 22 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22   "keys: " keys "
0460: 20 61 6c 6c 76 61 6c 73 3a 20 22 20 61 6c 6c 76   allvals: " allv
0470: 61 6c 73 20 22 20 6b 65 79 76 61 6c 6c 73 74 3a  als " keyvallst:
0480: 20 22 20 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20   " keyvallst).  
0490: 20 20 28 70 72 69 6e 74 20 22 4e 4f 54 45 3a 20    (print "NOTE: 
04a0: 75 73 69 6e 67 20 6b 65 79 20 22 20 28 73 74 72  using key " (str
04b0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
04c0: 6b 65 79 76 61 6c 6c 73 74 20 22 2f 22 29 20 22  keyvallst "/") "
04d0: 20 66 6f 72 20 74 68 69 73 20 72 75 6e 22 29 0a   for this run").
04e0: 20 20 20 20 28 69 66 20 28 61 6e 64 20 72 75 6e      (if (and run
04f0: 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c  name (null? (fil
0500: 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29 28  ter (lambda (x)(
0510: 6e 6f 74 20 78 29 29 20 6b 65 79 76 61 6c 6c 73  not x)) keyvalls
0520: 74 29 29 29 20 3b 3b 20 74 68 65 72 65 20 6d 75  t))) ;; there mu
0530: 73 74 20 62 65 20 61 20 62 65 74 74 65 72 20 77  st be a better w
0540: 61 79 20 74 6f 20 22 61 70 70 6c 79 20 61 6e 64  ay to "apply and
0550: 22 0a 09 28 6c 65 74 20 28 28 72 65 73 20 23 66  "..(let ((res #f
0560: 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c  ))..  (apply sql
0570: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
0580: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
0590: 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e   IGNORE INTO run
05a0: 73 20 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65  s (runname,state
05b0: 2c 73 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76  ,status,owner,ev
05c0: 65 6e 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20  ent_time" comma 
05d0: 6b 65 79 73 74 72 20 22 29 20 56 41 4c 55 45 53  keystr ") VALUES
05e0: 20 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69   (?,?,?,?,strfti
05f0: 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 22 20  me('%s','now')" 
0600: 63 6f 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22  comma valslots "
0610: 29 3b 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29  );")... allvals)
0620: 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74  ..  (apply sqlit
0630: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20  e3:for-each-row 
0640: 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64  ..   (lambda (id
0650: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 65  )..     (set! re
0660: 73 20 69 64 29 29 0a 09 20 20 20 64 62 0a 09 20  s id))..   db.. 
0670: 20 20 28 6c 65 74 20 28 28 71 72 79 20 28 63 6f    (let ((qry (co
0680: 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46 52  nc "SELECT id FR
0690: 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 28 72  OM runs WHERE (r
06a0: 75 6e 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74  unname=? " andst
06b0: 72 20 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22 29  r key=?str ");")
06c0: 29 29 0a 09 20 20 20 20 20 3b 3b 20 28 70 72 69  ))..     ;; (pri
06d0: 6e 74 20 22 71 72 79 3a 20 22 20 71 72 79 29 20  nt "qry: " qry) 
06e0: 0a 09 20 20 20 20 20 71 72 79 29 0a 09 20 20 20  ..     qry)..   
06f0: 71 72 79 76 61 6c 73 29 0a 09 20 20 28 73 71 6c  qryvals)..  (sql
0700: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
0710: 22 55 50 44 41 54 45 20 72 75 6e 73 20 53 45 54  "UPDATE runs SET
0720: 20 73 74 61 74 65 3d 3f 2c 73 74 61 74 75 73 3d   state=?,status=
0730: 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 20 73  ? WHERE id=?;" s
0740: 74 61 74 65 20 73 74 61 74 75 73 20 72 65 73 29  tate status res)
0750: 0a 09 20 20 72 65 73 29 20 0a 09 28 62 65 67 69  ..  res) ..(begi
0760: 6e 0a 09 20 20 28 70 72 69 6e 74 20 22 45 52 52  n..  (print "ERR
0770: 4f 52 3a 20 43 61 6c 6c 65 64 20 77 69 74 68 6f  OR: Called witho
0780: 75 74 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79  ut all necessary
0790: 20 6b 65 79 73 22 29 0a 09 20 20 23 66 29 29 29   keys")..  #f)))
07a0: 29 0a 0a 3b 3b 20 72 75 6e 73 3a 67 65 74 2d 72  )..;; runs:get-r
07b0: 75 6e 73 2d 62 79 2d 70 61 74 74 0a 3b 3b 20 67  uns-by-patt.;; g
07c0: 65 74 20 72 75 6e 73 20 62 79 20 6c 69 73 74 20  et runs by list 
07d0: 6f 66 20 63 72 69 74 65 72 69 61 0a 3b 3b 20 72  of criteria.;; r
07e0: 65 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72  egister a test r
07f0: 75 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 3b  un with the db.;
0800: 3b 0a 3b 3b 20 55 73 65 3a 20 28 64 62 2d 67 65  ;.;; Use: (db-ge
0810: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
0820: 72 20 28 64 62 3a 67 65 74 2d 68 65 61 64 65 72  r (db:get-header
0830: 20 72 75 6e 69 6e 66 6f 29 28 64 62 3a 67 65 74   runinfo)(db:get
0840: 2d 72 6f 77 20 72 75 6e 69 6e 66 6f 29 29 0a 3b  -row runinfo)).;
0850: 3b 20 20 74 6f 20 65 78 74 72 61 63 74 20 69 6e  ;  to extract in
0860: 66 6f 20 66 72 6f 6d 20 74 68 65 20 73 74 72 75  fo from the stru
0870: 63 74 75 72 65 20 72 65 74 75 72 6e 65 64 0a 3b  cture returned.;
0880: 3b 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ;.(define (runs:
0890: 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74  get-runs-by-patt
08a0: 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65   db keys runname
08b0: 70 61 74 74 29 20 3b 3b 20 74 65 73 74 2d 6e 61  patt) ;; test-na
08c0: 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65  me).  (let* ((ke
08d0: 79 76 61 6c 6c 73 74 20 28 6b 65 79 73 2d 3e 76  yvallst (keys->v
08e0: 61 6c 6c 69 73 74 20 6b 65 79 73 29 29 0a 09 20  allist keys)).. 
08f0: 28 74 6d 70 20 20 20 20 20 20 28 72 75 6e 73 3a  (tmp      (runs:
0900: 67 65 74 2d 73 74 64 2d 72 75 6e 2d 66 69 65 6c  get-std-run-fiel
0910: 64 73 20 6b 65 79 73 20 27 28 22 69 64 22 20 22  ds keys '("id" "
0920: 72 75 6e 6e 61 6d 65 22 20 22 73 74 61 74 65 22  runname" "state"
0930: 20 22 73 74 61 74 75 73 22 20 22 6f 77 6e 65 72   "status" "owner
0940: 22 20 22 65 76 65 6e 74 5f 74 69 6d 65 22 29 29  " "event_time"))
0950: 29 0a 09 20 28 6b 65 79 73 74 72 20 20 20 28 63  ).. (keystr   (c
0960: 61 72 20 74 6d 70 29 29 0a 09 20 28 68 65 61 64  ar tmp)).. (head
0970: 65 72 20 20 20 28 63 61 64 72 20 74 6d 70 29 29  er   (cadr tmp))
0980: 0a 09 20 28 72 65 73 20 20 20 20 20 27 28 29 29  .. (res     '())
0990: 0a 09 20 28 6b 65 79 2d 70 61 74 74 20 22 22 29  .. (key-patt "")
09a0: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  ).    (for-each 
09b0: 28 6c 61 6d 62 64 61 20 28 6b 65 79 76 61 6c 29  (lambda (keyval)
09c0: 0a 09 09 28 6c 65 74 2a 20 28 28 6b 65 79 20 20  ...(let* ((key  
09d0: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 65    (vector-ref ke
09e0: 79 76 61 6c 20 30 29 29 0a 09 09 20 20 20 20 20  yval 0))...     
09f0: 20 20 28 66 75 6c 6b 65 79 20 28 63 6f 6e 63 20    (fulkey (conc 
0a00: 22 3a 22 20 6b 65 79 29 29 0a 09 09 20 20 20 20  ":" key))...    
0a10: 20 20 20 28 70 61 74 74 20 20 20 28 61 72 67 73     (patt   (args
0a20: 3a 67 65 74 2d 61 72 67 20 66 75 6c 6b 65 79 29  :get-arg fulkey)
0a30: 29 29 0a 09 09 20 20 28 69 66 20 70 61 74 74 0a  ))...  (if patt.
0a40: 09 09 20 20 20 20 20 20 28 73 65 74 21 20 6b 65  ..      (set! ke
0a50: 79 2d 70 61 74 74 20 28 63 6f 6e 63 20 6b 65 79  y-patt (conc key
0a60: 2d 70 61 74 74 20 22 20 41 4e 44 20 22 20 6b 65  -patt " AND " ke
0a70: 79 20 22 20 6c 69 6b 65 20 27 22 20 70 61 74 74  y " like '" patt
0a80: 20 22 27 22 29 29 0a 09 09 20 20 20 20 20 20 28   "'"))...      (
0a90: 62 65 67 69 6e 0a 09 09 09 28 70 72 69 6e 74 20  begin....(print 
0aa0: 22 45 52 52 4f 52 3a 20 73 65 61 72 63 68 69 6e  "ERROR: searchin
0ab0: 67 20 66 6f 72 20 72 75 6e 73 20 77 69 74 68 20  g for runs with 
0ac0: 6e 6f 20 70 61 74 74 65 72 6e 20 73 65 74 20 66  no pattern set f
0ad0: 6f 72 20 22 20 66 75 6c 6b 65 79 29 0a 09 09 09  or " fulkey)....
0ae0: 28 65 78 69 74 20 36 29 29 29 29 29 0a 09 20 20  (exit 6)))))..  
0af0: 20 20 20 20 6b 65 79 73 29 0a 20 20 20 20 28 73      keys).    (s
0b00: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
0b10: 72 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64  row .     (lambd
0b20: 61 20 28 61 20 2e 20 72 29 0a 20 20 20 20 20 20  a (a . r).      
0b30: 20 28 73 65 74 21 20 72 65 73 20 28 63 6f 6e 73   (set! res (cons
0b40: 20 28 6c 69 73 74 2d 3e 76 65 63 74 6f 72 20 28   (list->vector (
0b50: 63 6f 6e 73 20 61 20 72 29 29 20 72 65 73 29 29  cons a r)) res))
0b60: 29 0a 20 20 20 20 20 64 62 20 0a 20 20 20 20 20  ).     db .     
0b70: 28 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20  (conc "SELECT " 
0b80: 6b 65 79 73 74 72 20 22 20 46 52 4f 4d 20 72 75  keystr " FROM ru
0b90: 6e 73 20 57 48 45 52 45 20 72 75 6e 6e 61 6d 65  ns WHERE runname
0ba0: 20 6c 69 6b 65 20 3f 20 22 20 6b 65 79 2d 70 61   like ? " key-pa
0bb0: 74 74 20 22 3b 22 29 0a 20 20 20 20 20 72 75 6e  tt ";").     run
0bc0: 6e 61 6d 65 70 61 74 74 29 0a 20 20 20 20 28 76  namepatt).    (v
0bd0: 65 63 74 6f 72 20 68 65 61 64 65 72 20 72 65 73  ector header res
0be0: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 65  )))..(define (re
0bf0: 67 69 73 74 65 72 2d 74 65 73 74 20 64 62 20 72  gister-test db r
0c00: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
0c10: 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 28 73 71  item-path).  (sq
0c20: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
0c30: 20 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f   "INSERT OR IGNO
0c40: 52 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72  RE INTO tests (r
0c50: 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 65  un_id,testname,e
0c60: 76 65 6e 74 5f 74 69 6d 65 2c 69 74 65 6d 5f 70  vent_time,item_p
0c70: 61 74 68 29 20 56 41 4c 55 45 53 20 28 3f 2c 3f  ath) VALUES (?,?
0c80: 2c 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27  ,strftime('%s','
0c90: 6e 6f 77 27 29 2c 3f 29 3b 22 20 72 75 6e 2d 69  now'),?);" run-i
0ca0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
0cb0: 2d 70 61 74 68 29 29 0a 0a 28 64 65 66 69 6e 65  -path))..(define
0cc0: 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75   (test-set-statu
0cd0: 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  s! db run-id tes
0ce0: 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61  t-name state sta
0cf0: 74 75 73 20 69 74 65 6d 64 61 74 2d 6f 72 2d 70  tus itemdat-or-p
0d00: 61 74 68 20 2e 20 63 6f 6d 6d 65 6e 74 29 0a 20  ath . comment). 
0d10: 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74   (let ((item-pat
0d20: 68 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 69  h (if (string? i
0d30: 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 29 20  temdat-or-path) 
0d40: 69 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 20  itemdat-or-path 
0d50: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
0d60: 20 69 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68   itemdat-or-path
0d70: 29 29 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65  )))).    (sqlite
0d80: 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50  3:execute db "UP
0d90: 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20 73  DATE tests SET s
0da0: 74 61 74 65 3d 3f 2c 73 74 61 74 75 73 3d 3f 2c  tate=?,status=?,
0db0: 65 76 65 6e 74 5f 74 69 6d 65 3d 73 74 72 66 74  event_time=strft
0dc0: 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 20  ime('%s','now') 
0dd0: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
0de0: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
0df0: 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 20  D item_path=?;" 
0e00: 0a 09 09 20 20 20 20 20 73 74 61 74 65 20 73 74  ...     state st
0e10: 61 74 75 73 20 72 75 6e 2d 69 64 20 74 65 73 74  atus run-id test
0e20: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
0e30: 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e  .    (if (and (n
0e40: 6f 74 20 28 6e 75 6c 6c 3f 20 63 6f 6d 6d 65 6e  ot (null? commen
0e50: 74 29 29 0a 09 20 20 20 20 20 28 63 61 72 20 63  t))..     (car c
0e60: 6f 6d 6d 65 6e 74 29 29 0a 09 28 73 71 6c 69 74  omment))..(sqlit
0e70: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
0e80: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
0e90: 63 6f 6d 6d 65 6e 74 3d 3f 20 57 48 45 52 45 20  comment=? WHERE 
0ea0: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
0eb0: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
0ec0: 5f 70 61 74 68 3d 3f 3b 22 0a 09 09 09 20 28 63  _path=?;".... (c
0ed0: 61 72 20 63 6f 6d 6d 65 6e 74 29 20 72 75 6e 2d  ar comment) run-
0ee0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
0ef0: 6d 2d 70 61 74 68 29 29 29 29 0a 0a 28 64 65 66  m-path))))..(def
0f00: 69 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 6c 6f  ine (test-set-lo
0f10: 67 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  g! db run-id tes
0f20: 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6c  t-name itemdat l
0f30: 6f 67 66 29 20 0a 20 20 28 6c 65 74 20 28 28 69  ogf) .  (let ((i
0f40: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  tem-path (item-l
0f50: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
0f60: 74 29 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65  t))).    (sqlite
0f70: 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50  3:execute db "UP
0f80: 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20 66  DATE tests SET f
0f90: 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52  inal_logf=? WHER
0fa0: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
0fb0: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
0fc0: 65 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 20  em_path=?;" ... 
0fd0: 20 20 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20      logf run-id 
0fe0: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
0ff0: 61 74 68 29 29 29 0a 0a 3b 3b 20 3b 3b 20 54 4f  ath)))..;; ;; TO
1000: 44 4f 3a 20 43 6f 6e 76 65 72 67 65 20 74 68 69  DO: Converge thi
1010: 73 20 77 69 74 68 20 64 62 3a 67 65 74 2d 74 65  s with db:get-te
1020: 73 74 2d 69 6e 66 6f 0a 3b 3b 20 28 64 65 66 69  st-info.;; (defi
1030: 6e 65 20 28 72 75 6e 73 3a 67 65 74 2d 74 65 73  ne (runs:get-tes
1040: 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  t-info db run-id
1050: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
1060: 70 61 74 68 29 0a 3b 3b 20 20 20 28 6c 65 74 20  path).;;   (let 
1070: 28 28 72 65 73 20 23 66 29 29 20 3b 3b 20 28 76  ((res #f)) ;; (v
1080: 65 63 74 6f 72 20 23 66 20 23 66 20 23 66 20 23  ector #f #f #f #
1090: 66 20 23 66 20 23 66 29 29 29 0a 3b 3b 20 20 20  f #f #f))).;;   
10a0: 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65    (sqlite3:for-e
10b0: 61 63 68 2d 72 6f 77 20 0a 3b 3b 20 20 20 20 20  ach-row .;;     
10c0: 20 28 6c 61 6d 62 64 61 20 28 69 64 20 72 75 6e   (lambda (id run
10d0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 73 74  -id test-name st
10e0: 61 74 65 20 73 74 61 74 75 73 29 0a 3b 3b 20 20  ate status).;;  
10f0: 20 20 20 20 20 20 28 73 65 74 21 20 72 65 73 20        (set! res 
1100: 28 76 65 63 74 6f 72 20 69 64 20 72 75 6e 2d 69  (vector id run-i
1110: 64 20 74 65 73 74 2d 6e 61 6d 65 20 73 74 61 74  d test-name stat
1120: 65 20 73 74 61 74 75 73 20 69 74 65 6d 2d 70 61  e status item-pa
1130: 74 68 29 29 29 0a 3b 3b 20 20 20 20 20 20 64 62  th))).;;      db
1140: 20 22 53 45 4c 45 43 54 20 69 64 2c 72 75 6e 5f   "SELECT id,run_
1150: 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73 74 61 74  id,testname,stat
1160: 65 2c 73 74 61 74 75 73 20 46 52 4f 4d 20 74 65  e,status FROM te
1170: 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64  sts WHERE run_id
1180: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
1190: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
11a0: 3f 3b 22 0a 3b 3b 20 20 20 20 20 20 72 75 6e 2d  ?;".;;      run-
11b0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
11c0: 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20 20 20 72  m-path).;;     r
11d0: 65 73 29 29 0a 0a 28 64 65 66 69 6e 65 2d 69 6e  es))..(define-in
11e0: 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 69  line (test:get-i
11f0: 64 20 76 65 63 29 20 20 20 20 20 20 20 28 76 65  d vec)       (ve
1200: 63 74 6f 72 2d 72 65 66 20 76 65 63 20 30 29 29  ctor-ref vec 0))
1210: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20  .(define-inline 
1220: 28 74 65 73 74 3a 67 65 74 2d 72 75 6e 5f 69 64  (test:get-run_id
1230: 20 76 65 63 29 20 20 20 28 76 65 63 74 6f 72 2d   vec)   (vector-
1240: 72 65 66 20 76 65 63 20 31 29 29 0a 28 64 65 66  ref vec 1)).(def
1250: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74  ine-inline (test
1260: 3a 67 65 74 2d 74 65 73 74 2d 6e 61 6d 65 20 76  :get-test-name v
1270: 65 63 29 28 76 65 63 74 6f 72 2d 72 65 66 20 76  ec)(vector-ref v
1280: 65 63 20 32 29 29 0a 28 64 65 66 69 6e 65 2d 69  ec 2)).(define-i
1290: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d  nline (test:get-
12a0: 73 74 61 74 65 20 76 65 63 29 20 20 20 20 28 76  state vec)    (v
12b0: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 33 29  ector-ref vec 3)
12c0: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ).(define-inline
12d0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
12e0: 73 20 76 65 63 29 20 20 20 28 76 65 63 74 6f 72  s vec)   (vector
12f0: 2d 72 65 66 20 76 65 63 20 34 29 29 0a 28 64 65  -ref vec 4)).(de
1300: 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73  fine-inline (tes
1310: 74 3a 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20  t:get-item-path 
1320: 76 65 63 29 28 76 65 63 74 6f 72 2d 72 65 66 20  vec)(vector-ref 
1330: 76 65 63 20 35 29 29 0a 0a 28 64 65 66 69 6e 65  vec 5))..(define
1340: 20 28 72 75 6e 73 3a 74 65 73 74 2d 67 65 74 2d   (runs:test-get-
1350: 66 75 6c 6c 2d 70 61 74 68 20 74 65 73 74 29 0a  full-path test).
1360: 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61    (let* ((testna
1370: 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  me (db:test-get-
1380: 74 65 73 74 6e 61 6d 65 20 20 20 74 65 73 74 29  testname   test)
1390: 29 0a 09 20 28 69 74 65 6d 70 61 74 68 20 28 64  ).. (itempath (d
13a0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
13b0: 70 61 74 68 20 74 65 73 74 29 29 29 0a 20 20 20  path test))).   
13c0: 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20   (conc testname 
13d0: 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65 6d  (if (equal? item
13e0: 70 61 74 68 20 22 22 29 20 22 22 20 28 63 6f 6e  path "") "" (con
13f0: 63 20 22 28 22 20 69 74 65 6d 70 61 74 68 20 22  c "(" itempath "
1400: 29 22 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65  )")))))..(define
1410: 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 74 65  -inline (test:te
1420: 73 74 2d 67 65 74 2d 66 75 6c 6c 6e 61 6d 65 20  st-get-fullname 
1430: 74 65 73 74 29 0a 20 20 20 28 63 6f 6e 63 20 28  test).   (conc (
1440: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
1450: 6e 61 6d 65 20 74 65 73 74 29 0a 09 20 28 69 66  name test).. (if
1460: 20 28 65 71 75 61 6c 3f 20 28 64 62 3a 74 65 73   (equal? (db:tes
1470: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20  t-get-item-path 
1480: 74 65 73 74 29 20 22 22 29 0a 09 20 20 20 20 20  test) "")..     
1490: 22 22 0a 09 20 20 20 20 20 28 63 6f 6e 63 20 22  ""..     (conc "
14a0: 28 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  (" (db:test-get-
14b0: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 20  item-path test) 
14c0: 22 29 22 29 29 29 29 0a 0a 28 64 65 66 69 6e 65  ")"))))..(define
14d0: 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74   (check-valid-it
14e0: 65 6d 73 20 63 6c 61 73 73 20 69 74 65 6d 29 0a  ems class item).
14f0: 20 20 28 6c 65 74 20 28 28 76 61 6c 69 64 2d 76    (let ((valid-v
1500: 61 6c 75 65 73 20 28 6c 65 74 20 28 28 73 20 28  alues (let ((s (
1510: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63  config-lookup *c
1520: 6f 6e 66 69 67 64 61 74 2a 20 22 76 61 6c 69 64  onfigdat* "valid
1530: 76 61 6c 75 65 73 22 20 63 6c 61 73 73 29 29 29  values" class)))
1540: 0a 09 09 09 28 69 66 20 73 20 28 73 74 72 69 6e  ....(if s (strin
1550: 67 2d 73 70 6c 69 74 20 73 29 20 23 66 29 29 29  g-split s) #f)))
1560: 29 0a 20 20 20 20 28 69 66 20 76 61 6c 69 64 2d  ).    (if valid-
1570: 76 61 6c 75 65 73 0a 09 28 69 66 20 28 6d 65 6d  values..(if (mem
1580: 62 65 72 20 69 74 65 6d 20 76 61 6c 69 64 2d 76  ber item valid-v
1590: 61 6c 75 65 73 29 0a 09 20 20 20 20 69 74 65 6d  alues)..    item
15a0: 20 23 66 29 0a 09 69 74 65 6d 29 29 29 0a 0a 28   #f)..item)))..(
15b0: 64 65 66 69 6e 65 20 28 74 65 73 74 73 74 65 70  define (teststep
15c0: 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62 20  -set-status! db 
15d0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
15e0: 20 74 65 73 74 73 74 65 70 2d 6e 61 6d 65 20 73   teststep-name s
15f0: 74 61 74 65 2d 69 6e 20 73 74 61 74 75 73 2d 69  tate-in status-i
1600: 6e 20 69 74 65 6d 64 61 74 20 63 6f 6d 6d 65 6e  n itemdat commen
1610: 74 29 0a 20 20 3b 3b 20 28 70 72 69 6e 74 20 22  t).  ;; (print "
1620: 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64  run-id: " run-id
1630: 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20   " test-name: " 
1640: 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65  test-name).  (le
1650: 74 2a 20 28 28 73 74 61 74 65 20 20 20 20 20 28  t* ((state     (
1660: 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d  check-valid-item
1670: 73 20 22 73 74 61 74 65 22 20 73 74 61 74 65 2d  s "state" state-
1680: 69 6e 29 29 0a 09 20 28 73 74 61 74 75 73 20 20  in)).. (status  
1690: 20 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69    (check-valid-i
16a0: 74 65 6d 73 20 22 73 74 61 74 75 73 22 20 73 74  tems "status" st
16b0: 61 74 75 73 2d 69 6e 29 29 0a 09 20 28 69 74 65  atus-in)).. (ite
16c0: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73  m-path (item-lis
16d0: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29  t->path itemdat)
16e0: 29 0a 09 20 28 74 65 73 74 64 61 74 20 20 20 28  ).. (testdat   (
16f0: 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f  db:get-test-info
1700: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
1710: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
1720: 29 0a 20 20 20 20 3b 3b 20 28 70 72 69 6e 74 20  ).    ;; (print 
1730: 22 74 65 73 74 64 61 74 3a 20 22 20 74 65 73 74  "testdat: " test
1740: 64 61 74 29 0a 20 20 20 20 28 69 66 20 28 61 6e  dat).    (if (an
1750: 64 20 74 65 73 74 64 61 74 20 3b 3b 20 69 66 20  d testdat ;; if 
1760: 74 68 65 20 73 65 63 74 69 6f 6e 20 65 78 69 73  the section exis
1770: 74 73 20 74 68 65 6e 20 66 6f 72 63 65 20 73 70  ts then force sp
1780: 65 63 69 66 69 63 61 74 69 6f 6e 20 42 55 47 2c  ecification BUG,
1790: 20 49 20 64 6f 6e 27 74 20 6c 69 6b 65 20 68 6f   I don't like ho
17a0: 77 20 74 68 69 73 20 77 6f 72 6b 73 2e 0a 09 20  w this works... 
17b0: 20 20 20 20 28 6f 72 20 28 6e 6f 74 20 73 74 61      (or (not sta
17c0: 74 65 29 28 6e 6f 74 20 73 74 61 74 75 73 29 29  te)(not status))
17d0: 29 0a 09 28 70 72 69 6e 74 20 22 57 41 52 4e 49  )..(print "WARNI
17e0: 4e 47 3a 20 49 6e 76 61 6c 69 64 20 22 20 28 69  NG: Invalid " (i
17f0: 66 20 73 74 61 74 75 73 20 22 73 74 61 74 75 73  f status "status
1800: 22 20 22 73 74 61 74 65 22 29 0a 09 20 20 20 20  " "state")..    
1810: 20 20 20 22 20 76 61 6c 75 65 20 5c 22 22 20 28     " value \"" (
1820: 69 66 20 73 74 61 74 75 73 20 73 74 61 74 75 73  if status status
1830: 2d 69 6e 20 73 74 61 74 65 2d 69 6e 29 20 22 5c  -in state-in) "\
1840: 22 2c 20 75 70 64 61 74 65 20 79 6f 75 72 20 76  ", update your v
1850: 61 6c 69 64 73 74 61 74 65 73 20 73 65 63 74 69  alidstates secti
1860: 6f 6e 20 69 6e 20 6d 65 67 61 74 65 73 74 2e 63  on in megatest.c
1870: 6f 6e 66 69 67 22 29 29 0a 20 20 20 20 28 69 66  onfig")).    (if
1880: 20 74 65 73 74 64 61 74 0a 09 28 6c 65 74 20 28   testdat..(let (
1890: 28 74 65 73 74 2d 69 64 20 28 74 65 73 74 3a 67  (test-id (test:g
18a0: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 29  et-id testdat)))
18b0: 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65  ..  (sqlite3:exe
18c0: 63 75 74 65 20 64 62 20 0a 09 09 09 22 49 4e 53  cute db ...."INS
18d0: 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20 69  ERT OR REPLACE i
18e0: 6e 74 6f 20 74 65 73 74 5f 73 74 65 70 73 20 28  nto test_steps (
18f0: 74 65 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65  test_id,stepname
1900: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76  ,state,status,ev
1910: 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74  ent_time,comment
1920: 29 20 56 41 4c 55 45 53 28 3f 2c 3f 2c 3f 2c 3f  ) VALUES(?,?,?,?
1930: 2c 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27  ,strftime('%s','
1940: 6e 6f 77 27 29 2c 3f 29 3b 22 0a 09 09 09 74 65  now'),?);"....te
1950: 73 74 2d 69 64 20 74 65 73 74 73 74 65 70 2d 6e  st-id teststep-n
1960: 61 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73  ame state status
1970: 20 28 69 66 20 63 6f 6d 6d 65 6e 74 20 63 6f 6d   (if comment com
1980: 6d 65 6e 74 20 22 22 29 29 29 0a 09 28 70 72 69  ment "")))..(pri
1990: 6e 74 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74  nt "ERROR: Can't
19a0: 20 75 70 64 61 74 65 20 22 20 74 65 73 74 2d 6e   update " test-n
19b0: 61 6d 65 20 22 20 66 6f 72 20 72 75 6e 20 22 20  ame " for run " 
19c0: 72 75 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 73  run-id " -> no s
19d0: 75 63 68 20 74 65 73 74 20 69 6e 20 64 62 22 29  uch test in db")
19e0: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65  )))..(define (te
19f0: 73 74 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75  st-get-kill-requ
1a00: 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65  est db run-id te
1a10: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 29  st-name itemdat)
1a20: 0a 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d  .  (let* ((item-
1a30: 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d  path (item-list-
1a40: 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a  >path itemdat)).
1a50: 09 20 28 74 65 73 74 64 61 74 20 20 20 28 64 62  . (testdat   (db
1a60: 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64  :get-test-info d
1a70: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
1a80: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a  me item-path))).
1a90: 20 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73      (equal? (tes
1aa0: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
1ab0: 64 61 74 29 20 22 4b 49 4c 4c 52 45 51 22 29 29  dat) "KILLREQ"))
1ac0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
1ad0: 2d 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64  -set-meta-info d
1ae0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d  b run-id testnam
1af0: 65 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65  e itemdat).  (le
1b00: 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69  t ((item-path (i
1b10: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
1b20: 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f  temdat))..(cpulo
1b30: 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61  ad  (get-cpu-loa
1b40: 64 29 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20 28  d))..(hostname (
1b50: 67 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 0a  get-host-name)).
1b60: 09 28 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d  .(diskfree (get-
1b70: 64 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65  df (current-dire
1b80: 63 74 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d 65  ctory)))..(uname
1b90: 20 20 20 20 28 67 65 74 2d 75 6e 61 6d 65 20 22      (get-uname "
1ba0: 2d 73 72 76 70 69 6f 22 29 29 0a 09 28 72 75 6e  -srvpio"))..(run
1bb0: 70 61 74 68 20 20 28 63 75 72 72 65 6e 74 2d 64  path  (current-d
1bc0: 69 72 65 63 74 6f 72 79 29 29 29 0a 20 20 20 20  irectory))).    
1bd0: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
1be0: 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74   db "UPDATE test
1bf0: 73 20 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70 75  s SET host=?,cpu
1c00: 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d  load=?,diskfree=
1c10: 3f 2c 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 72  ?,uname=?,rundir
1c20: 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  =? WHERE run_id=
1c30: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
1c40: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f   AND item_path=?
1c50: 3b 22 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65 0a  ;"...  hostname.
1c60: 09 09 20 20 63 70 75 6c 6f 61 64 0a 09 09 20 20  ..  cpuload...  
1c70: 64 69 73 6b 66 72 65 65 0a 09 09 20 20 75 6e 61  diskfree...  una
1c80: 6d 65 0a 09 09 20 20 72 75 6e 70 61 74 68 0a 09  me...  runpath..
1c90: 09 20 20 72 75 6e 2d 69 64 0a 09 09 20 20 74 65  .  run-id...  te
1ca0: 73 74 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d 2d  stname...  item-
1cb0: 70 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65  path)))..(define
1cc0: 20 28 74 65 73 74 2d 75 70 64 61 74 65 2d 6d 65   (test-update-me
1cd0: 74 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69  ta-info db run-i
1ce0: 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64  d testname itemd
1cf0: 61 74 20 6d 69 6e 75 74 65 73 29 0a 20 20 28 6c  at minutes).  (l
1d00: 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28  et ((item-path (
1d10: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
1d20: 69 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c  itemdat))..(cpul
1d30: 6f 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f  oad  (get-cpu-lo
1d40: 61 64 29 29 0a 09 28 64 69 73 6b 66 72 65 65 20  ad))..(diskfree 
1d50: 28 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e 74  (get-df (current
1d60: 2d 64 69 72 65 63 74 6f 72 79 29 29 29 29 0a 20  -directory)))). 
1d70: 20 20 20 28 69 66 20 28 6e 6f 74 20 63 70 75 6c     (if (not cpul
1d80: 6f 61 64 29 20 20 28 62 65 67 69 6e 20 28 70 72  oad)  (begin (pr
1d90: 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20 43 50  int "WARNING: CP
1da0: 55 4c 4f 41 44 20 6e 6f 74 20 66 6f 75 6e 64 2e  ULOAD not found.
1db0: 22 29 20 20 28 73 65 74 21 20 63 70 75 6c 6f 61  ")  (set! cpuloa
1dc0: 64 20 22 6e 2f 61 22 29 29 29 0a 20 20 20 20 28  d "n/a"))).    (
1dd0: 69 66 20 28 6e 6f 74 20 64 69 73 6b 66 72 65 65  if (not diskfree
1de0: 29 20 28 62 65 67 69 6e 20 28 70 72 69 6e 74 20  ) (begin (print 
1df0: 22 57 41 52 4e 49 4e 47 3a 20 44 49 53 4b 46 52  "WARNING: DISKFR
1e00: 45 45 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 20  EE not found.") 
1e10: 28 73 65 74 21 20 64 69 73 6b 66 72 65 65 20 22  (set! diskfree "
1e20: 6e 2f 61 22 29 29 29 0a 20 20 20 20 28 69 66 20  n/a"))).    (if 
1e30: 28 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29 28  (not item-path)(
1e40: 62 65 67 69 6e 20 28 70 72 69 6e 74 20 22 57 41  begin (print "WA
1e50: 52 4e 49 4e 47 3a 20 49 54 45 4d 50 41 54 48 20  RNING: ITEMPATH 
1e60: 6e 6f 74 20 73 65 74 2e 22 29 20 20 20 28 73 65  not set.")   (se
1e70: 74 21 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  t! item-path "")
1e80: 29 29 0a 20 20 20 20 3b 3b 20 28 6c 65 74 20 28  )).    ;; (let (
1e90: 28 74 65 73 74 69 6e 66 6f 20 28 64 62 3a 67 65  (testinfo (db:ge
1ea0: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72  t-test-info db r
1eb0: 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69  un-id testname i
1ec0: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
1ed0: 3b 3b 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e  ;;   (if (and (n
1ee0: 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62 3a 74  ot (equal? (db:t
1ef0: 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73 20 74  est-get-status t
1f00: 65 73 74 69 6e 66 6f 29 20 22 43 4f 4d 50 4c 45  estinfo) "COMPLE
1f10: 54 45 44 22 29 29 0a 20 20 20 20 3b 3b 20 20 20  TED")).    ;;   
1f20: 20 20 20 20 20 20 20 20 20 28 6e 6f 74 20 28 65           (not (e
1f30: 71 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67  qual? (db:test-g
1f40: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 69 6e  et-status testin
1f50: 66 6f 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 0a  fo) "KILLREQ")).
1f60: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
1f70: 63 75 74 65 0a 20 20 20 20 20 64 62 0a 20 20 20  cute.     db.   
1f80: 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20    "UPDATE tests 
1f90: 53 45 54 20 63 70 75 6c 6f 61 64 3d 3f 2c 64 69  SET cpuload=?,di
1fa0: 73 6b 66 72 65 65 3d 3f 2c 72 75 6e 5f 64 75 72  skfree=?,run_dur
1fb0: 61 74 69 6f 6e 3d 3f 2c 73 74 61 74 65 3d 27 52  ation=?,state='R
1fc0: 55 4e 4e 49 4e 47 27 20 57 48 45 52 45 20 72 75  UNNING' WHERE ru
1fd0: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
1fe0: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
1ff0: 61 74 68 3d 3f 20 41 4e 44 20 73 74 61 74 65 20  ath=? AND state 
2000: 4e 4f 54 20 49 4e 20 28 27 43 4f 4d 50 4c 45 54  NOT IN ('COMPLET
2010: 45 44 27 2c 27 4b 49 4c 4c 52 45 51 27 2c 27 4b  ED','KILLREQ','K
2020: 49 4c 4c 45 44 27 29 3b 22 0a 20 20 20 20 20 63  ILLED');".     c
2030: 70 75 6c 6f 61 64 0a 20 20 20 20 20 64 69 73 6b  puload.     disk
2040: 66 72 65 65 0a 20 20 20 20 20 6d 69 6e 75 74 65  free.     minute
2050: 73 0a 20 20 20 20 20 72 75 6e 2d 69 64 0a 20 20  s.     run-id.  
2060: 20 20 20 74 65 73 74 6e 61 6d 65 0a 20 20 20 20     testname.    
2070: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28   item-path)))..(
2080: 64 65 66 69 6e 65 20 28 73 65 74 2d 6d 65 67 61  define (set-mega
2090: 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62  test-env-vars db
20a0: 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c 65 74 20   run-id).  (let 
20b0: 28 28 6b 65 79 73 20 28 64 62 2d 67 65 74 2d 6b  ((keys (db-get-k
20c0: 65 79 73 20 64 62 29 29 29 0a 20 20 20 20 28 66  eys db))).    (f
20d0: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
20e0: 28 6b 65 79 29 0a 09 09 28 73 71 6c 69 74 65 33  (key)...(sqlite3
20f0: 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09  :for-each-row...
2100: 20 28 6c 61 6d 62 64 61 20 28 76 61 6c 29 0a 09   (lambda (val)..
2110: 09 20 20 20 28 70 72 69 6e 74 20 22 73 65 74 65  .   (print "sete
2120: 6e 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69  nv " (key:get-fi
2130: 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 22  eldname key) " "
2140: 20 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 65   val)...   (sete
2150: 6e 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c  nv (key:get-fiel
2160: 64 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 29  dname key) val))
2170: 0a 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e 63  ... db ... (conc
2180: 20 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a   "SELECT " (key:
2190: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
21a0: 79 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57  y) " FROM runs W
21b0: 48 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20  HERE id=?;")... 
21c0: 72 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 20  run-id))..      
21d0: 6b 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e 65  keys)))..(define
21e0: 20 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76   (set-item-env-v
21f0: 61 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 28  ars itemdat).  (
2200: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
2210: 20 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 28   (item)..      (
2220: 70 72 69 6e 74 20 22 73 65 74 65 6e 76 20 22 20  print "setenv " 
2230: 28 63 61 72 20 69 74 65 6d 29 20 22 20 22 20 28  (car item) " " (
2240: 63 61 64 72 20 69 74 65 6d 29 29 0a 09 20 20 20  cadr item))..   
2250: 20 20 20 28 73 65 74 65 6e 76 20 28 63 61 72 20     (setenv (car 
2260: 69 74 65 6d 29 20 28 63 61 64 72 20 69 74 65 6d  item) (cadr item
2270: 29 29 29 0a 09 20 20 20 20 69 74 65 6d 64 61 74  )))..    itemdat
2280: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 74  ))..(define (get
2290: 2d 61 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73  -all-legal-tests
22a0: 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74  ).  (let* ((test
22b0: 73 20 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 2a  s  (glob (conc *
22c0: 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73  toppath* "/tests
22d0: 2f 2a 22 29 29 29 0a 09 20 28 72 65 73 20 20 20  /*"))).. (res   
22e0: 20 27 28 29 29 29 0a 20 20 20 20 3b 3b 20 28 70   '())).    ;; (p
22f0: 72 69 6e 74 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b  rint "INFO: Look
2300: 69 6e 67 20 61 74 20 74 65 73 74 73 20 22 20 28  ing at tests " (
2310: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
2320: 73 65 20 74 65 73 74 73 20 22 2c 22 29 29 0a 20  se tests ",")). 
2330: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61     (for-each (la
2340: 6d 62 64 61 20 28 74 65 73 74 70 61 74 68 29 0a  mbda (testpath).
2350: 09 09 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73  ..(if (file-exis
2360: 74 73 3f 20 28 63 6f 6e 63 20 74 65 73 74 70 61  ts? (conc testpa
2370: 74 68 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22  th "/testconfig"
2380: 29 29 0a 09 09 20 20 20 20 28 73 65 74 21 20 72  ))...    (set! r
2390: 65 73 20 28 63 6f 6e 73 20 28 6c 61 73 74 20 28  es (cons (last (
23a0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73  string-split tes
23b0: 74 70 61 74 68 20 22 2f 22 29 29 20 72 65 73 29  tpath "/")) res)
23c0: 29 29 29 0a 09 20 20 20 20 20 20 74 65 73 74 73  )))..      tests
23d0: 29 0a 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65  ).    res))..(de
23e0: 66 69 6e 65 20 28 72 75 6e 2d 74 65 73 74 73 20  fine (run-tests 
23f0: 64 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 20  db test-names). 
2400: 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 28   (for-each .   (
2410: 6c 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d  lambda (test-nam
2420: 65 29 0a 20 20 20 20 20 28 6c 65 74 20 28 28 6e  e).     (let ((n
2430: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a 67  um-running (db:g
2440: 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72  et-count-tests-r
2450: 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 20 20 20  unning db))..   
2460: 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d  (max-concurrent-
2470: 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f  jobs (config-loo
2480: 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20  kup *configdat* 
2490: 22 73 65 74 75 70 22 20 22 6d 61 78 5f 63 6f 6e  "setup" "max_con
24a0: 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29 29 29  current_jobs")))
24b0: 0a 20 20 20 20 20 20 20 28 70 72 69 6e 74 20 22  .       (print "
24c0: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
24d0: 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75  obs: " max-concu
24e0: 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75  rrent-jobs ", nu
24f0: 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d  m-running: " num
2500: 2d 72 75 6e 6e 69 6e 67 29 0a 20 20 20 20 20 20  -running).      
2510: 20 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 6d 61   (if (or (not ma
2520: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
2530: 73 29 0a 09 20 20 20 20 20 20 20 28 61 6e 64 20  s)..       (and 
2540: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
2550: 6f 62 73 0a 09 09 20 20 20 20 28 73 74 72 69 6e  obs...    (strin
2560: 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f  g->number max-co
2570: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09  ncurrent-jobs)..
2580: 09 20 20 20 20 28 6e 6f 74 20 28 3e 20 6e 75 6d  .    (not (> num
2590: 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67  -running (string
25a0: 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e  ->number max-con
25b0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29  current-jobs))))
25c0: 29 0a 09 20 20 20 28 72 75 6e 2d 6f 6e 65 2d 74  )..   (run-one-t
25d0: 65 73 74 20 64 62 20 74 65 73 74 2d 6e 61 6d 65  est db test-name
25e0: 29 0a 09 20 20 20 28 70 72 69 6e 74 20 22 57 41  )..   (print "WA
25f0: 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69  RNING: Max runni
2600: 6e 67 20 6a 6f 62 73 20 65 78 63 65 65 64 65 64  ng jobs exceeded
2610: 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d 62 65 72  , current number
2620: 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d   running: " num-
2630: 72 75 6e 6e 69 6e 67 20 0a 09 09 20 20 22 2c 20  running ...  ", 
2640: 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a  max_concurrent_j
2650: 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75  obs: " max-concu
2660: 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29 0a 20  rrent-jobs)))). 
2670: 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 0a    test-names))..
2680: 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 6f 6e 65  (define (run-one
2690: 2d 74 65 73 74 20 64 62 20 74 65 73 74 2d 6e 61  -test db test-na
26a0: 6d 65 29 0a 20 20 28 70 72 69 6e 74 20 22 4c 61  me).  (print "La
26b0: 75 6e 63 68 69 6e 67 20 74 65 73 74 20 22 20 74  unching test " t
26c0: 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74  est-name).  (let
26d0: 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20 20 20  * ((test-path   
26e0: 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a   (conc *toppath*
26f0: 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d   "/tests/" test-
2700: 6e 61 6d 65 29 29 0a 09 20 28 74 65 73 74 2d 63  name)).. (test-c
2710: 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74 65 73  onfigf (conc tes
2720: 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63 6f 6e  t-path "/testcon
2730: 66 69 67 22 29 29 0a 09 20 28 74 65 73 74 65 78  fig")).. (testex
2740: 69 73 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c  ists   (and (fil
2750: 65 2d 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63  e-exists? test-c
2760: 6f 6e 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61  onfigf)(file-rea
2770: 64 2d 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63  d-access? test-c
2780: 6f 6e 66 69 67 66 29 29 29 0a 09 20 28 74 65 73  onfigf))).. (tes
2790: 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65  t-conf    (if te
27a0: 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63  stexists (read-c
27b0: 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69  onfig test-confi
27c0: 67 66 29 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74  gf) (make-hash-t
27d0: 61 62 6c 65 29 29 29 0a 09 20 28 77 61 69 74 6f  able))).. (waito
27e0: 6e 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 77  n       (let ((w
27f0: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
2800: 74 65 73 74 2d 63 6f 6e 66 20 22 72 65 71 75 69  test-conf "requi
2810: 72 65 6d 65 6e 74 73 22 20 22 77 61 69 74 6f 6e  rements" "waiton
2820: 22 29 29 29 0a 09 09 09 20 28 69 66 20 28 73 74  "))).... (if (st
2830: 72 69 6e 67 3f 20 77 29 28 73 74 72 69 6e 67 2d  ring? w)(string-
2840: 73 70 6c 69 74 20 77 29 27 28 29 29 29 29 29 0a  split w)'())))).
2850: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 74 65 73      (if (not tes
2860: 74 65 78 69 73 74 73 29 0a 09 28 62 65 67 69 6e  texists)..(begin
2870: 0a 09 20 20 28 70 72 69 6e 74 20 22 45 52 52 4f  ..  (print "ERRO
2880: 52 3a 20 43 61 6e 27 74 20 66 69 6e 64 20 63 6f  R: Can't find co
2890: 6e 66 69 67 20 66 69 6c 65 20 22 20 74 65 73 74  nfig file " test
28a0: 2d 63 6f 6e 66 69 67 66 29 0a 09 20 20 28 65 78  -configf)..  (ex
28b0: 69 74 20 32 29 29 0a 09 3b 3b 20 70 75 74 20 74  it 2))..;; put t
28c0: 6f 70 20 76 61 72 73 20 69 6e 74 6f 20 63 6f 6e  op vars into con
28d0: 76 65 6e 69 65 6e 74 20 76 61 72 69 61 62 6c 65  venient variable
28e0: 73 20 61 6e 64 20 6f 70 65 6e 20 74 68 65 20 64  s and open the d
28f0: 62 0a 09 28 6c 65 74 2a 20 28 3b 3b 20 64 62 20  b..(let* (;; db 
2900: 69 73 20 61 6c 77 61 79 73 20 61 74 20 2a 74 6f  is always at *to
2910: 70 70 61 74 68 2a 2f 64 62 2f 6d 65 67 61 74 65  ppath*/db/megate
2920: 73 74 2e 64 62 0a 09 20 20 20 20 20 20 20 28 6b  st.db..       (k
2930: 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d 67  eys        (db-g
2940: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 20  et-keys db))..  
2950: 20 20 20 20 20 28 6b 65 79 76 61 6c 6c 73 74 20       (keyvallst 
2960: 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74    (keys->vallist
2970: 20 6b 65 79 73 20 23 74 29 29 0a 09 20 20 20 20   keys #t))..    
2980: 20 20 20 28 69 74 65 6d 73 20 20 20 20 20 20 20     (items       
2990: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
29a0: 64 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e  default test-con
29b0: 66 20 22 69 74 65 6d 73 22 20 23 66 29 29 0a 09  f "items" #f))..
29c0: 20 20 20 20 20 20 20 28 61 6c 6c 69 74 65 6d 73         (allitems
29d0: 20 20 20 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d      (item-assoc-
29e0: 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73  >item-list items
29f0: 29 29 0a 09 20 20 20 20 20 20 20 28 72 75 6e 2d  ))..       (run-
2a00: 69 64 20 20 20 20 20 20 28 72 65 67 69 73 74 65  id      (registe
2a10: 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 29 29 20  r-run db keys)) 
2a20: 3b 3b 20 20 74 65 73 74 2d 6e 61 6d 65 29 29 29  ;;  test-name)))
2a30: 0a 09 20 20 20 20 20 20 20 28 72 75 6e 63 6f 6e  ..       (runcon
2a40: 66 69 67 66 20 20 28 63 6f 6e 63 20 20 2a 74 6f  figf  (conc  *to
2a50: 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66  ppath* "/runconf
2a60: 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 29 0a 09  igs.config")))..
2a70: 20 20 3b 3b 20 28 70 72 69 6e 74 20 22 69 74 65    ;; (print "ite
2a80: 6d 73 3a 20 22 29 28 70 70 20 61 6c 6c 69 74 65  ms: ")(pp allite
2a90: 6d 73 29 0a 09 20 20 28 69 66 20 28 61 72 67 73  ms)..  (if (args
2aa0: 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 0a 09  :get-arg "-m")..
2ab0: 20 20 20 20 20 20 28 64 62 3a 73 65 74 2d 63 6f        (db:set-co
2ac0: 6d 6d 65 6e 74 2d 66 6f 72 2d 72 75 6e 20 64 62  mment-for-run db
2ad0: 20 72 75 6e 2d 69 64 20 28 61 72 67 73 3a 67 65   run-id (args:ge
2ae0: 74 2d 61 72 67 20 22 2d 6d 22 29 29 29 0a 09 20  t-arg "-m"))).. 
2af0: 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 69 74 65   (let loop ((ite
2b00: 6d 64 61 74 20 28 63 61 72 20 61 6c 6c 69 74 65  mdat (car allite
2b10: 6d 73 29 29 0a 09 09 20 20 20 20 20 28 74 61 6c  ms))...     (tal
2b20: 20 20 20 20 20 28 63 64 72 20 61 6c 6c 69 74 65       (cdr allite
2b30: 6d 73 29 29 29 0a 09 20 20 20 20 3b 3b 20 28 6c  ms)))..    ;; (l
2b40: 61 6d 62 64 61 20 28 69 74 65 6d 64 61 74 29 20  ambda (itemdat) 
2b50: 3b 3b 3b 20 28 28 72 69 70 65 6e 65 73 73 20 22  ;;; ((ripeness "
2b60: 6f 76 65 72 72 69 70 65 22 29 20 28 74 65 6d 70  overripe") (temp
2b70: 65 72 61 74 75 72 65 20 22 63 6f 6f 6c 22 29 20  erature "cool") 
2b80: 28 73 65 61 73 6f 6e 20 22 73 75 6d 6d 65 72 22  (season "summer"
2b90: 29 29 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28  ))..    (let* ((
2ba0: 69 74 65 6d 2d 70 61 74 68 20 20 20 20 20 28 69  item-path     (i
2bb0: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
2bc0: 74 65 6d 64 61 74 29 29 20 3b 3b 20 28 73 74 72  temdat)) ;; (str
2bd0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
2be0: 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64 61  (map cadr itemda
2bf0: 74 29 20 22 2f 22 29 29 0a 09 09 20 20 20 28 6e  t) "/"))...   (n
2c00: 65 77 2d 74 65 73 74 2d 70 61 74 68 20 28 73 74  ew-test-path (st
2c10: 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65  ring-intersperse
2c20: 20 28 63 6f 6e 73 20 74 65 73 74 2d 70 61 74 68   (cons test-path
2c30: 20 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64   (map cadr itemd
2c40: 61 74 29 29 20 22 2f 22 29 29 0a 09 09 20 20 20  at)) "/"))...   
2c50: 28 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 28  (new-test-name (
2c60: 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d  if (equal? item-
2c70: 70 61 74 68 20 22 22 29 20 74 65 73 74 2d 6e 61  path "") test-na
2c80: 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 2d 6e 61  me (conc test-na
2c90: 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68  me "/" item-path
2ca0: 29 29 29 20 3b 3b 20 6a 75 73 74 20 6e 65 65 64  ))) ;; just need
2cb0: 20 69 74 20 74 6f 20 62 65 20 75 6e 69 71 75 65   it to be unique
2cc0: 0a 09 09 20 20 20 28 74 65 73 74 2d 73 74 61 74  ...   (test-stat
2cd0: 75 73 20 20 20 23 66 29 0a 09 09 20 20 20 28 6e  us   #f)...   (n
2ce0: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a 67  um-running (db:g
2cf0: 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72  et-count-tests-r
2d00: 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 09 20 20  unning db))...  
2d10: 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74   (max-concurrent
2d20: 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c 6f  -jobs (config-lo
2d30: 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a  okup *configdat*
2d40: 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f 63 6f   "setup" "max_co
2d50: 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29 29  ncurrent_jobs"))
2d60: 29 0a 09 20 20 20 20 20 20 28 70 72 69 6e 74 20  )..      (print 
2d70: 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d  "max-concurrent-
2d80: 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63  jobs: " max-conc
2d90: 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e  urrent-jobs ", n
2da0: 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75  um-running: " nu
2db0: 6d 2d 72 75 6e 6e 69 6e 67 29 0a 09 20 20 20 20  m-running)..    
2dc0: 20 20 28 69 66 20 28 6e 6f 74 20 28 6f 72 20 28    (if (not (or (
2dd0: 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  not max-concurre
2de0: 6e 74 2d 6a 6f 62 73 29 0a 09 09 09 20 20 20 28  nt-jobs)....   (
2df0: 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  and max-concurre
2e00: 6e 74 2d 6a 6f 62 73 0a 09 09 09 09 28 73 74 72  nt-jobs.....(str
2e10: 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d  ing->number max-
2e20: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29  concurrent-jobs)
2e30: 0a 09 09 09 09 28 6e 6f 74 20 28 3e 20 6e 75 6d  .....(not (> num
2e40: 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67  -running (string
2e50: 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e  ->number max-con
2e60: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29  current-jobs))))
2e70: 29 29 0a 09 09 20 20 28 70 72 69 6e 74 20 22 57  ))...  (print "W
2e80: 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e  ARNING: Max runn
2e90: 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65 64 65  ing jobs exceede
2ea0: 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d 62 65  d, current numbe
2eb0: 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d  r running: " num
2ec0: 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 20 22 2c  -running .... ",
2ed0: 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f   max_concurrent_
2ee0: 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63  jobs: " max-conc
2ef0: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 20  urrent-jobs)... 
2f00: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28 6c   (begin...    (l
2f10: 65 74 20 6c 6f 6f 70 32 20 28 28 74 73 20 23 66  et loop2 ((ts #f
2f20: 29 0a 09 09 09 09 28 63 74 20 30 29 29 0a 09 09  ).....(ct 0))...
2f30: 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 28        (if (and (
2f40: 6e 6f 74 20 74 73 29 0a 09 09 09 20 20 20 20 20  not ts)....     
2f50: 20 20 28 3c 20 63 74 20 31 30 29 29 0a 09 09 09    (< ct 10))....
2f60: 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20    (begin....    
2f70: 28 72 65 67 69 73 74 65 72 2d 74 65 73 74 20 64  (register-test d
2f80: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
2f90: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09  me item-path)...
2fa0: 09 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  .    (db:delete-
2fb0: 74 65 73 74 2d 73 74 65 70 2d 72 65 63 6f 72 64  test-step-record
2fc0: 73 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  s db run-id test
2fd0: 2d 6e 61 6d 65 29 20 3b 3b 20 63 6c 65 61 6e 20  -name) ;; clean 
2fe0: 6f 75 74 20 69 66 20 74 68 69 73 20 69 73 20 61  out if this is a
2ff0: 20 72 65 2d 72 75 6e 0a 09 09 09 20 20 20 20 28   re-run....    (
3000: 6c 6f 6f 70 32 20 28 64 62 3a 67 65 74 2d 74 65  loop2 (db:get-te
3010: 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69  st-info db run-i
3020: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
3030: 2d 70 61 74 68 29 0a 09 09 09 09 20 20 20 28 2b  -path).....   (+
3040: 20 63 74 20 31 29 29 29 0a 09 09 09 20 20 28 69   ct 1)))....  (i
3050: 66 20 74 73 0a 09 09 09 20 20 20 20 20 20 28 73  f ts....      (s
3060: 65 74 21 20 74 65 73 74 2d 73 74 61 74 75 73 20  et! test-status 
3070: 74 73 29 0a 09 09 09 20 20 20 20 20 20 28 62 65  ts)....      (be
3080: 67 69 6e 0a 09 09 09 09 28 70 72 69 6e 74 20 22  gin.....(print "
3090: 57 41 52 4e 49 4e 47 3a 20 43 6f 75 6c 64 6e 27  WARNING: Couldn'
30a0: 74 20 72 65 67 69 73 74 65 72 20 74 65 73 74 20  t register test 
30b0: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 77 69  " test-name " wi
30c0: 74 68 20 69 74 65 6d 20 70 61 74 68 20 22 20 69  th item path " i
30d0: 74 65 6d 2d 70 61 74 68 20 22 2c 20 73 6b 69 70  tem-path ", skip
30e0: 70 69 6e 67 22 29 0a 09 09 09 09 28 69 66 20 28  ping").....(if (
30f0: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29  not (null? tal))
3100: 0a 09 09 09 09 20 20 20 20 28 6c 6f 6f 70 20 28  .....    (loop (
3110: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
3120: 29 29 29 29 29 29 29 0a 09 09 20 20 20 20 28 63  )))))))...    (c
3130: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20  hange-directory 
3140: 74 65 73 74 2d 70 61 74 68 29 0a 09 09 20 20 20  test-path)...   
3150: 20 3b 3b 20 74 68 69 73 20 62 6c 6f 63 6b 20 69   ;; this block i
3160: 73 20 68 65 72 65 20 6f 6e 6c 79 20 74 6f 20 69  s here only to i
3170: 6e 66 6f 72 6d 20 74 68 65 20 75 73 65 72 20 65  nform the user e
3180: 61 72 6c 79 20 6f 6e 0a 09 09 20 20 20 20 28 69  arly on...    (i
3190: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
31a0: 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09 09 28  runconfigf)....(
31b0: 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c  setup-env-defaul
31c0: 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69 67 66  ts db runconfigf
31d0: 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79   run-id *already
31e0: 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d  -seen-runconfig-
31f0: 69 6e 66 6f 2a 29 0a 09 09 09 28 70 72 69 6e 74  info*)....(print
3200: 20 22 57 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64   "WARNING: You d
3210: 6f 20 6e 6f 74 20 68 61 76 65 20 61 20 72 75 6e  o not have a run
3220: 20 63 6f 6e 66 69 67 20 66 69 6c 65 3a 20 22 20   config file: " 
3230: 72 75 6e 63 6f 6e 66 69 67 66 29 29 0a 09 09 20  runconfigf))... 
3240: 20 20 20 3b 3b 20 28 70 72 69 6e 74 20 22 72 75     ;; (print "ru
3250: 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 20 22  n-id: " run-id "
3260: 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65   test-name: " te
3270: 73 74 2d 6e 61 6d 65 20 22 20 69 74 65 6d 2d 70  st-name " item-p
3280: 61 74 68 3a 20 22 20 69 74 65 6d 2d 70 61 74 68  ath: " item-path
3290: 20 22 20 74 65 73 74 2d 73 74 61 74 75 73 3a 20   " test-status: 
32a0: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
32b0: 75 73 20 74 65 73 74 2d 73 74 61 74 75 73 29 20  us test-status) 
32c0: 22 20 74 65 73 74 2d 73 74 61 74 65 3a 20 22 20  " test-state: " 
32d0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
32e0: 74 65 73 74 2d 73 74 61 74 75 73 29 29 0a 09 09  test-status))...
32f0: 20 20 20 20 28 63 61 73 65 20 28 69 66 20 28 61      (case (if (a
3300: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f  rgs:get-arg "-fo
3310: 72 63 65 22 29 0a 09 09 09 20 20 20 20 20 20 27  rce")....      '
3320: 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 09 20  NOT_STARTED.... 
3330: 20 20 20 20 20 28 69 66 20 74 65 73 74 2d 73 74       (if test-st
3340: 61 74 75 73 0a 09 09 09 09 20 20 28 73 74 72 69  atus.....  (stri
3350: 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74  ng->symbol (test
3360: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 2d  :get-state test-
3370: 73 74 61 74 75 73 29 29 0a 09 09 09 09 20 20 27  status)).....  '
3380: 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74  failed-to-insert
3390: 29 29 0a 09 09 20 20 20 20 20 20 28 28 66 61 69  ))...      ((fai
33a0: 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 0a 09  led-to-insert)..
33b0: 09 20 20 20 20 20 20 20 28 70 72 69 6e 74 20 22  .       (print "
33c0: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f  ERROR: Failed to
33d0: 20 69 6e 73 65 72 74 20 74 68 65 20 72 65 63 6f   insert the reco
33e0: 72 64 20 69 6e 74 6f 20 74 68 65 20 64 62 22 29  rd into the db")
33f0: 29 0a 09 09 20 20 20 20 20 20 28 28 4e 4f 54 5f  )...      ((NOT_
3400: 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54 45  STARTED COMPLETE
3410: 44 29 20 3b 3b 20 28 63 61 64 72 20 73 74 61 74  D) ;; (cadr stat
3420: 75 73 20 69 73 20 74 68 65 20 72 6f 77 20 69 64  us is the row id
3430: 20 66 6f 72 20 74 68 65 20 72 75 6e 20 72 65 63   for the run rec
3440: 6f 72 64 29 0a 09 09 20 20 20 20 20 20 20 28 69  ord)...       (i
3450: 66 20 28 61 6e 64 20 28 65 71 75 61 6c 3f 20 28  f (and (equal? (
3460: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
3470: 65 73 74 2d 73 74 61 74 75 73 29 20 20 22 43 4f  est-status)  "CO
3480: 4d 50 4c 45 54 45 44 22 29 0a 09 09 09 09 28 6f  MPLETED").....(o
3490: 72 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a  r (equal? (test:
34a0: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 2d  get-status test-
34b0: 73 74 61 74 75 73 29 20 22 50 41 53 53 22 29 0a  status) "PASS").
34c0: 09 09 09 09 20 20 20 20 28 65 71 75 61 6c 3f 20  ....    (equal? 
34d0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
34e0: 20 74 65 73 74 2d 73 74 61 74 75 73 29 20 22 43   test-status) "C
34f0: 48 45 43 4b 22 29 29 0a 09 09 09 09 28 6e 6f 74  HECK")).....(not
3500: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
3510: 2d 66 6f 72 63 65 22 29 29 29 0a 09 09 09 20 20  -force")))....  
3520: 20 28 70 72 69 6e 74 20 22 4e 4f 54 45 3a 20 4e   (print "NOTE: N
3530: 6f 74 20 73 74 61 72 74 69 6e 67 20 74 65 73 74  ot starting test
3540: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65   " new-test-name
3550: 20 22 20 61 73 20 69 74 20 69 73 20 73 74 61 74   " as it is stat
3560: 65 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20  e \"COMPLETED\" 
3570: 61 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20 28  and status \"" (
3580: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
3590: 74 65 73 74 2d 73 74 61 74 75 73 29 20 22 5c 22  test-status) "\"
35a0: 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20  , use -force to 
35b0: 6f 76 65 72 72 69 64 65 22 29 0a 09 09 09 20 20  override")....  
35c0: 20 28 6c 65 74 2a 20 28 28 67 65 74 2d 70 72 65   (let* ((get-pre
35d0: 72 65 71 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61  reqs-cmd (lambda
35e0: 20 28 29 0a 09 09 09 09 09 09 20 20 20 20 20 28   ().......     (
35f0: 64 62 2d 67 65 74 2d 70 72 65 72 65 71 73 2d 6e  db-get-prereqs-n
3600: 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64  ot-met db run-id
3610: 20 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68   waiton))) ;; ch
3620: 65 63 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e 69  eck before runni
3630: 6e 67 20 2e 2e 2e 2e 0a 09 09 09 09 20 20 28 6c  ng .........  (l
3640: 61 75 6e 63 68 2d 63 6d 64 20 20 20 20 20 20 28  aunch-cmd      (
3650: 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09 09  lambda ().......
3660: 20 20 20 20 20 28 6c 61 75 6e 63 68 2d 74 65 73       (launch-tes
3670: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
3680: 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20  -conf keyvallst 
3690: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70  test-name test-p
36a0: 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a 09  ath itemdat)))..
36b0: 09 09 09 20 20 28 74 65 73 74 72 75 6e 64 61 74  ...  (testrundat
36c0: 20 20 20 20 20 20 28 6c 69 73 74 20 67 65 74 2d        (list get-
36d0: 70 72 65 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e  prereqs-cmd laun
36e0: 63 68 2d 63 6d 64 29 29 29 0a 09 09 09 20 20 20  ch-cmd)))....   
36f0: 20 20 28 69 66 20 28 6f 72 20 28 61 72 67 73 3a    (if (or (args:
3700: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22  get-arg "-force"
3710: 29 0a 09 09 09 09 20 20 20 20 20 28 6e 75 6c 6c  ).....     (null
3720: 3f 20 28 28 63 61 72 20 74 65 73 74 72 75 6e 64  ? ((car testrund
3730: 61 74 29 29 29 29 20 3b 3b 20 61 72 65 20 74 68  at)))) ;; are th
3740: 65 72 65 20 61 6e 79 20 74 65 73 74 73 20 74 68  ere any tests th
3750: 61 74 20 6d 75 73 74 20 62 65 20 72 75 6e 20 62  at must be run b
3760: 65 66 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e  efore this one..
3770: 2e 0a 09 09 09 09 20 28 28 63 61 64 72 20 74 65  ...... ((cadr te
3780: 73 74 72 75 6e 64 61 74 29 29 20 3b 3b 20 74 68  strundat)) ;; th
3790: 69 73 20 69 73 20 74 68 65 20 6c 69 6e 65 20 74  is is the line t
37a0: 68 61 74 20 6c 61 75 6e 63 68 65 73 20 74 68 65  hat launches the
37b0: 20 74 65 73 74 20 74 6f 20 74 68 65 20 72 65 6d   test to the rem
37c0: 6f 74 65 20 68 6f 73 74 0a 09 09 09 09 20 28 68  ote host..... (h
37d0: 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 2a  ash-table-set! *
37e0: 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 6e  waiting-queue* n
37f0: 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  ew-test-name tes
3800: 74 72 75 6e 64 61 74 29 29 29 29 29 0a 09 09 20  trundat)))))... 
3810: 20 20 20 20 20 28 28 4b 49 4c 4c 45 44 29 20 0a       ((KILLED) .
3820: 09 09 20 20 20 20 20 20 20 28 70 72 69 6e 74 20  ..       (print 
3830: 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73  "NOTE: " new-tes
3840: 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65  t-name " is alre
3850: 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77  ady running or w
3860: 61 73 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c  as explictly kil
3870: 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20  led, use -force 
3880: 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29  to launch it."))
3890: 0a 09 09 20 20 20 20 20 20 28 28 4c 41 55 4e 43  ...      ((LAUNC
38a0: 48 45 44 20 52 45 4d 4f 54 45 48 4f 53 54 53 54  HED REMOTEHOSTST
38b0: 41 52 54 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09  ART RUNNING)  ..
38c0: 09 20 20 20 20 20 20 20 28 69 66 20 28 3e 20 28  .       (if (> (
38d0: 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e  - (current-secon
38e0: 64 73 29 28 2b 20 28 64 62 3a 74 65 73 74 2d 67  ds)(+ (db:test-g
38f0: 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74 65  et-event_time te
3900: 73 74 2d 73 74 61 74 75 73 29 0a 09 09 09 09 09  st-status)......
3910: 09 20 20 20 20 20 28 64 62 3a 74 65 73 74 2d 67  .     (db:test-g
3920: 65 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20  et-run_duration 
3930: 74 65 73 74 2d 73 74 61 74 75 73 29 29 29 0a 09  test-status)))..
3940: 09 09 20 20 20 20 20 20 31 30 30 29 20 3b 3b 20  ..      100) ;; 
3950: 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74 65 20 66  i.e. no update f
3960: 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 31 30 30  or more than 100
3970: 20 73 65 63 6f 6e 64 73 0a 09 09 09 20 20 20 28   seconds....   (
3980: 62 65 67 69 6e 0a 09 09 09 20 20 20 20 20 28 70  begin....     (p
3990: 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20 54  rint "WARNING: T
39a0: 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  est " test-name 
39b0: 22 20 61 70 70 65 61 72 73 20 74 6f 20 62 65 20  " appears to be 
39c0: 64 65 61 64 2e 22 29 0a 09 09 09 20 20 20 20 20  dead.")....     
39d0: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73  (test-set-status
39e0: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
39f0: 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54  -name "INCOMPLET
3a00: 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20  E" "STUCK/DEAD" 
3a10: 69 74 65 6d 64 61 74 20 22 54 65 73 74 20 69 73  itemdat "Test is
3a20: 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 29   stuck or dead")
3a30: 29 0a 09 09 09 20 20 20 28 70 72 69 6e 74 20 22  )....   (print "
3a40: 4e 4f 54 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d  NOTE: " test-nam
3a50: 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72  e " is already r
3a60: 75 6e 6e 69 6e 67 22 29 29 29 0a 09 09 20 20 20  unning")))...   
3a70: 20 20 20 28 65 6c 73 65 20 20 20 20 20 20 20 28     (else       (
3a80: 70 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 46 61  print "ERROR: Fa
3a90: 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74  iled to launch t
3aa0: 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  est " new-test-n
3ab0: 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69  ame ". Unrecogni
3ac0: 73 65 64 20 73 74 61 74 65 20 22 20 28 74 65 73  sed state " (tes
3ad0: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
3ae0: 2d 73 74 61 74 75 73 29 29 29 29 29 29 0a 09 20  -status)))))).. 
3af0: 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e       (if (not (n
3b00: 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20 20 28  ull? tal))...  (
3b10: 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63  loop (car tal)(c
3b20: 64 72 20 74 61 6c 29 29 29 29 29 29 29 29 29 0a  dr tal))))))))).
3b30: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 77 61  .(define (run-wa
3b40: 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a  iting-tests db).
3b50: 20 20 28 6c 65 74 20 28 28 6e 75 6d 74 72 69 65    (let ((numtrie
3b60: 73 20 20 20 20 20 20 20 20 20 20 20 30 29 0a 09  s           0)..
3b70: 28 6c 61 73 74 2d 74 72 79 2d 74 69 6d 65 20 20  (last-try-time  
3b80: 20 20 20 20 28 63 75 72 72 65 6e 74 2d 73 65 63      (current-sec
3b90: 6f 6e 64 73 29 29 0a 09 28 74 69 6d 65 73 20 20  onds))..(times  
3ba0: 20 20 20 20 20 20 20 20 20 20 20 20 28 6c 69 73              (lis
3bb0: 74 20 31 29 29 29 20 3b 3b 20 6d 69 6e 75 74 65  t 1))) ;; minute
3bc0: 73 20 74 6f 20 77 61 69 74 20 62 65 66 6f 72 65  s to wait before
3bd0: 20 74 72 79 69 6e 67 20 61 67 61 69 6e 20 74 6f   trying again to
3be0: 20 6b 69 63 6b 20 6f 66 66 20 72 75 6e 73 0a 20   kick off runs. 
3bf0: 20 20 20 3b 3b 20 42 55 47 20 74 68 69 73 20 68     ;; BUG this h
3c00: 61 63 6b 20 6f 66 20 62 72 75 74 65 20 66 6f 72  ack of brute for
3c10: 63 65 20 72 65 74 72 79 69 6e 67 20 77 6f 72 6b  ce retrying work
3c20: 73 20 71 75 69 74 65 20 77 65 6c 6c 20 66 6f 72  s quite well for
3c30: 20 6d 61 6e 79 20 63 61 73 65 73 20 62 75 74 20   many cases but 
3c40: 0a 20 20 20 20 3b 3b 20 20 20 20 20 77 68 61 74  .    ;;     what
3c50: 20 69 73 20 6e 65 65 64 65 64 20 69 73 20 74 6f   is needed is to
3c60: 20 63 68 65 63 6b 20 74 68 65 20 64 62 20 66 6f   check the db fo
3c70: 72 20 74 65 73 74 73 20 74 68 61 74 20 68 61 76  r tests that hav
3c80: 65 20 66 61 69 6c 65 64 20 6c 65 73 73 20 74 68  e failed less th
3c90: 61 6e 0a 20 20 20 20 3b 3b 20 20 20 20 20 4e 20  an.    ;;     N 
3ca0: 74 69 6d 65 73 20 6f 72 20 6e 65 76 65 72 20 62  times or never b
3cb0: 65 65 6e 20 73 74 61 72 74 65 64 20 61 6e 64 20  een started and 
3cc0: 6b 69 63 6b 20 74 68 65 6d 20 6f 66 66 20 61 67  kick them off ag
3cd0: 61 69 6e 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f  ain.    (let loo
3ce0: 70 20 28 28 77 61 69 74 69 6e 67 2d 74 65 73 74  p ((waiting-test
3cf0: 2d 6e 61 6d 65 73 20 28 68 61 73 68 2d 74 61 62  -names (hash-tab
3d00: 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67  le-keys *waiting
3d10: 2d 71 75 65 75 65 2a 29 29 29 0a 20 20 20 20 20  -queue*))).     
3d20: 20 28 63 6f 6e 64 0a 20 20 20 20 20 20 20 28 28   (cond.       ((
3d30: 6e 75 6c 6c 3f 20 77 61 69 74 69 6e 67 2d 74 65  null? waiting-te
3d40: 73 74 2d 6e 61 6d 65 73 29 0a 09 28 70 72 69 6e  st-names)..(prin
3d50: 74 20 22 41 6c 6c 20 74 65 73 74 73 20 6c 61 75  t "All tests lau
3d60: 6e 63 68 65 64 22 29 29 0a 20 20 20 20 20 20 20  nched")).       
3d70: 28 28 3e 20 6e 75 6d 74 72 69 65 73 20 34 29 0a  ((> numtries 4).
3d80: 09 28 70 72 69 6e 74 20 22 4e 4f 54 45 3a 20 54  .(print "NOTE: T
3d90: 72 69 65 64 20 6c 61 75 6e 63 68 69 6e 67 20 66  ried launching f
3da0: 6f 75 72 20 74 69 6d 65 73 2c 20 70 65 72 68 61  our times, perha
3db0: 70 73 20 72 75 6e 20 6d 65 67 61 74 65 73 74 20  ps run megatest 
3dc0: 61 67 61 69 6e 20 69 6e 20 61 20 66 65 77 20 6d  again in a few m
3dd0: 69 6e 75 74 65 73 22 29 29 0a 20 20 20 20 20 20  inutes")).      
3de0: 20 28 65 6c 73 65 0a 09 28 73 65 74 21 20 6e 75   (else..(set! nu
3df0: 6d 74 72 69 65 73 20 28 2b 20 6e 75 6d 74 72 69  mtries (+ numtri
3e00: 65 73 20 31 29 29 0a 09 28 66 6f 72 2d 65 61 63  es 1))..(for-eac
3e10: 68 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 6e  h (lambda (testn
3e20: 61 6d 65 29 0a 09 09 20 20 20 20 28 6c 65 74 2a  ame)...    (let*
3e30: 20 28 28 74 65 73 74 64 61 74 20 28 68 61 73 68   ((testdat (hash
3e40: 2d 74 61 62 6c 65 2d 72 65 66 20 2a 77 61 69 74  -table-ref *wait
3e50: 69 6e 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e  ing-queue* testn
3e60: 61 6d 65 29 29 0a 09 09 09 20 20 20 28 70 72 65  ame))....   (pre
3e70: 72 65 71 73 20 28 28 63 61 72 20 74 65 73 74 64  reqs ((car testd
3e80: 61 74 29 29 29 0a 09 09 09 20 20 20 28 6c 64 62  at)))....   (ldb
3e90: 20 20 20 20 20 28 69 66 20 64 62 20 64 62 20 28       (if db db (
3ea0: 6f 70 65 6e 2d 64 62 29 29 29 29 0a 09 09 20 20  open-db))))...  
3eb0: 20 20 20 20 3b 3b 20 28 70 72 69 6e 74 20 22 70      ;; (print "p
3ec0: 72 65 72 65 71 73 20 72 65 6d 61 69 6e 69 6e 67  rereqs remaining
3ed0: 3a 20 22 20 70 72 65 72 65 71 73 29 0a 09 09 20  : " prereqs)... 
3ee0: 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20       (if (null? 
3ef0: 70 72 65 72 65 71 73 29 0a 09 09 09 20 20 28 62  prereqs)....  (b
3f00: 65 67 69 6e 0a 09 09 09 20 20 20 20 28 70 72 69  egin....    (pri
3f10: 6e 74 20 22 50 72 65 72 65 71 75 69 73 69 74 65  nt "Prerequisite
3f20: 73 20 6d 65 74 2c 20 6c 61 75 6e 63 68 69 6e 67  s met, launching
3f30: 20 22 20 74 65 73 74 6e 61 6d 65 29 0a 09 09 09   " testname)....
3f40: 20 20 20 20 28 28 63 61 64 72 20 74 65 73 74 64      ((cadr testd
3f50: 61 74 29 29 0a 09 09 09 20 20 20 20 28 68 61 73  at))....    (has
3f60: 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 20  h-table-delete! 
3f70: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20  *waiting-queue* 
3f80: 74 65 73 74 6e 61 6d 65 29 29 29 0a 09 09 20 20  testname)))...  
3f90: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 64 62 29      (if (not db)
3fa0: 0a 09 09 09 20 20 28 73 71 6c 69 74 65 33 3a 66  ....  (sqlite3:f
3fb0: 69 6e 61 6c 69 7a 65 21 20 6c 64 62 29 29 29 29  inalize! ldb))))
3fc0: 0a 09 09 20 20 77 61 69 74 69 6e 67 2d 74 65 73  ...  waiting-tes
3fd0: 74 2d 6e 61 6d 65 73 29 0a 09 28 73 6c 65 65 70  t-names)..(sleep
3fe0: 20 31 30 29 20 3b 3b 20 6e 6f 20 70 6f 69 6e 74   10) ;; no point
3ff0: 20 69 6e 20 72 75 73 68 69 6e 67 20 74 68 69 6e   in rushing thin
4000: 67 73 20 61 74 20 74 68 69 73 20 73 74 61 67 65  gs at this stage
4010: 3f 0a 09 28 6c 6f 6f 70 20 28 68 61 73 68 2d 74  ?..(loop (hash-t
4020: 61 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69  able-keys *waiti
4030: 6e 67 2d 71 75 65 75 65 2a 29 29 29 29 29 29 29  ng-queue*)))))))
4040: 0a 0a 20 20 0a 3b 3b 20 52 65 6d 6f 76 65 20 72  ..  .;; Remove r
4050: 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72  uns.;; fields ar
4060: 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72  e passing in thr
4070: 6f 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28 72  ough .(define (r
4080: 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20  uns:remove-runs 
4090: 64 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74  db runnamepatt t
40a0: 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74  estpatt itempatt
40b0: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73  ).  (let* ((keys
40c0: 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d          (db-get-
40d0: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e  keys db)).. (run
40e0: 64 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a 67  dat      (runs:g
40f0: 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20  et-runs-by-patt 
4100: 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70  db keys runnamep
4110: 61 74 74 29 29 0a 09 20 28 68 65 61 64 65 72 20  att)).. (header 
4120: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
4130: 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72   rundat 0)).. (r
4140: 75 6e 73 20 20 20 20 20 20 20 20 28 76 65 63 74  uns        (vect
4150: 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29  or-ref rundat 1)
4160: 29 29 0a 20 20 20 20 28 70 72 69 6e 74 20 22 48  )).    (print "H
4170: 65 61 64 65 72 3a 20 22 20 68 65 61 64 65 72 29  eader: " header)
4180: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20  .    (for-each. 
4190: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e      (lambda (run
41a0: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ).       (let ((
41b0: 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69  runkey (string-i
41c0: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
41d0: 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09  (lambda (k).....
41e0: 09 09 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d  ..(db-get-value-
41f0: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
4200: 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66  ader (vector-ref
4210: 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f   k 0))) keys) "/
4220: 22 29 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 72  "))).. (let* ((r
4230: 75 6e 2d 69 64 20 28 64 62 2d 67 65 74 2d 76 61  un-id (db-get-va
4240: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
4250: 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20 29  n header "id") )
4260: 0a 09 09 28 74 65 73 74 73 20 20 28 64 62 2d 67  ...(tests  (db-g
4270: 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e  et-tests-for-run
4280: 20 64 62 20 28 64 62 2d 67 65 74 2d 76 61 6c 75   db (db-get-valu
4290: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
42a0: 68 65 61 64 65 72 20 22 69 64 22 29 20 74 65 73  header "id") tes
42b0: 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29 29  tpatt itempatt))
42c0: 29 0a 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28  )..   (if (not (
42d0: 6e 75 6c 6c 3f 20 74 65 73 74 73 29 29 0a 09 20  null? tests)).. 
42e0: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 20        (begin... 
42f0: 28 70 72 69 6e 74 20 22 52 65 6d 6f 76 69 6e 67  (print "Removing
4300: 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e 3a 20   tests for run: 
4310: 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28 64 62  " runkey " " (db
4320: 2d 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  -get-value-by-he
4330: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
4340: 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09 20 28  "runname"))... (
4350: 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 28 6c 61  for-each...  (la
4360: 6d 62 64 61 20 28 74 65 73 74 29 0a 09 09 20 20  mbda (test)...  
4370: 20 20 28 70 72 69 6e 74 20 22 20 20 22 20 28 64    (print "  " (d
4380: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
4390: 61 6d 65 20 74 65 73 74 29 20 22 20 69 64 3a 20  ame test) " id: 
43a0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
43b0: 64 20 74 65 73 74 29 20 22 20 22 20 28 64 62 3a  d test) " " (db:
43c0: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
43d0: 74 68 20 74 65 73 74 29 29 0a 09 09 20 20 20 20  th test))...    
43e0: 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d  (db:delete-test-
43f0: 72 65 63 6f 72 64 73 20 64 62 20 28 64 62 3a 74  records db (db:t
4400: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29  est-get-id test)
4410: 29 0a 09 09 20 20 20 20 28 69 66 20 28 3e 20 28  )...    (if (> (
4420: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 28 64  string-length (d
4430: 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69  b:test-get-rundi
4440: 72 20 74 65 73 74 29 29 20 35 29 20 3b 3b 20 62  r test)) 5) ;; b
4450: 61 64 20 68 65 75 72 69 73 74 69 63 20 62 75 74  ad heuristic but
4460: 20 73 68 6f 75 6c 64 20 70 72 65 76 65 6e 74 20   should prevent 
4470: 2f 74 6d 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a  /tmp /home etc..
4480: 09 09 09 28 6c 65 74 20 28 28 66 75 6c 6c 70 61  ...(let ((fullpa
4490: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
44a0: 72 75 6e 64 69 72 20 74 65 73 74 29 29 29 20 3b  rundir test))) ;
44b0: 3b 20 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67  ; "/" (db:test-g
44c0: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
44d0: 74 29 29 29 29 0a 09 09 09 20 20 28 70 72 69 6e  t))))....  (prin
44e0: 74 20 22 72 6d 20 2d 72 66 20 22 20 66 75 6c 6c  t "rm -rf " full
44f0: 70 61 74 68 29 0a 09 09 09 20 20 28 73 79 73 74  path)....  (syst
4500: 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66  em (conc "rm -rf
4510: 20 22 20 66 75 6c 6c 70 61 74 68 29 29 29 29 29   " fullpath)))))
4520: 0a 09 09 20 20 74 65 73 74 73 29 0a 09 09 20 28  ...  tests)... (
4530: 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28  let ((remtests (
4540: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db-get-tests-for
4550: 2d 72 75 6e 20 64 62 20 28 64 62 2d 67 65 74 2d  -run db (db-get-
4560: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
4570: 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29  run header "id")
4580: 29 29 29 0a 09 09 20 20 20 28 69 66 20 28 6e 75  )))...   (if (nu
4590: 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b  ll? remtests) ;;
45a0: 20 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72   no more tests r
45b0: 65 6d 61 69 6e 69 6e 67 0a 09 09 20 20 20 20 20  emaining...     
45c0: 20 20 28 62 65 67 69 6e 0a 09 09 09 20 28 70 72    (begin.... (pr
45d0: 69 6e 74 20 22 52 65 6d 6f 76 69 6e 67 20 72 75  int "Removing ru
45e0: 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20  n: " runkey " " 
45f0: 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db-get-value-by
4600: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
4610: 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09  er "runname"))..
4620: 09 09 20 28 64 62 3a 64 65 6c 65 74 65 2d 72 75  .. (db:delete-ru
4630: 6e 20 64 62 20 72 75 6e 2d 69 64 29 29 29 29 0a  n db run-id)))).
4640: 09 09 20 29 29 29 29 29 0a 20 20 20 20 20 72 75  .. ))))).     ru
4650: 6e 73 29 29 29 0a                                ns))).