Megatest

Hex Artifact Content
Login

Artifact 085cab6512b02b3629196696713253e1aff1e562:


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 3d 3d 3d   PURPOSE...;;===
0150: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0160: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0170: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0180: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0190: 3d 3d 3d 0a 3b 3b 20 6c 61 75 6e 63 68 20 61 20  ===.;; launch a 
01a0: 74 61 73 6b 20 2d 20 74 68 69 73 20 72 75 6e 73  task - this runs
01b0: 20 6f 6e 20 74 68 65 20 6f 72 69 67 69 6e 61 74   on the originat
01c0: 69 6e 67 20 68 6f 73 74 2c 20 74 65 73 74 73 20  ing host, tests 
01d0: 74 68 65 6d 73 65 6c 76 65 73 0a 3b 3b 0a 3b 3b  themselves.;;.;;
01e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
01f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0200: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0210: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0220: 3d 3d 3d 3d 3d 3d 0a 0a 28 75 73 65 20 72 65 67  ======..(use reg
0230: 65 78 20 72 65 67 65 78 2d 63 61 73 65 20 62 61  ex regex-case ba
0240: 73 65 36 34 20 73 71 6c 69 74 65 33 20 73 72 66  se64 sqlite3 srf
0250: 69 2d 31 38 29 0a 28 69 6d 70 6f 72 74 20 28 70  i-18).(import (p
0260: 72 65 66 69 78 20 62 61 73 65 36 34 20 62 61 73  refix base64 bas
0270: 65 36 34 3a 29 29 0a 28 69 6d 70 6f 72 74 20 28  e64:)).(import (
0280: 70 72 65 66 69 78 20 73 71 6c 69 74 65 33 20 73  prefix sqlite3 s
0290: 71 6c 69 74 65 33 3a 29 29 0a 0a 28 64 65 63 6c  qlite3:))..(decl
02a0: 61 72 65 20 28 75 6e 69 74 20 6c 61 75 6e 63 68  are (unit launch
02b0: 29 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65  )).(declare (use
02c0: 73 20 63 6f 6d 6d 6f 6e 29 29 0a 28 64 65 63 6c  s common)).(decl
02d0: 61 72 65 20 28 75 73 65 73 20 63 6f 6e 66 69 67  are (uses config
02e0: 66 29 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73  f)).(declare (us
02f0: 65 73 20 64 62 29 29 0a 0a 28 69 6e 63 6c 75 64  es db))..(includ
0300: 65 20 22 63 6f 6d 6d 6f 6e 5f 72 65 63 6f 72 64  e "common_record
0310: 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65  s.scm").(include
0320: 20 22 6b 65 79 5f 72 65 63 6f 72 64 73 2e 73 63   "key_records.sc
0330: 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20 22 64 62  m").(include "db
0340: 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 0a  _records.scm")..
0350: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
0360: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0370: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0380: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0390: 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 65 7a 73 74  ========.;; ezst
03a0: 65 70 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  eps.;;==========
03b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
03c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
03d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
03e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b  ============..;;
03f0: 20 65 7a 73 74 65 70 73 20 77 65 72 65 20 67 6f   ezsteps were go
0400: 69 6e 67 20 74 6f 20 62 65 20 63 6f 64 65 64 20  ing to be coded 
0410: 61 73 0a 3b 3b 20 73 74 65 70 6e 61 6d 65 5b 2c  as.;; stepname[,
0420: 70 72 65 64 73 74 65 70 31 2c 70 72 65 64 73 74  predstep1,predst
0430: 65 70 32 20 2e 2e 2e 5d 20 5b 7b 56 41 52 31 3d  ep2 ...] [{VAR1=
0440: 66 69 72 73 74 2c 73 65 63 6f 6e 64 2c 74 68 69  first,second,thi
0450: 72 64 7d 5d 20 63 6f 6d 6d 61 6e 64 20 74 6f 20  rd}] command to 
0460: 65 78 65 63 75 74 65 0a 3b 3b 20 20 20 42 55 54  execute.;;   BUT
0470: 0a 3b 3b 20 6e 6f 77 20 61 72 65 0a 3b 3b 20 73  .;; now are.;; s
0480: 74 65 70 6e 61 6d 65 20 7b 56 41 52 3d 66 69 72  tepname {VAR=fir
0490: 73 74 2c 73 65 63 6f 6e 64 2c 74 68 69 72 64 20  st,second,third 
04a0: 2e 2e 2e 7d 20 63 6f 6d 6d 61 6e 64 20 2e 2e 2e  ...} command ...
04b0: 0a 0a 0a 28 64 65 66 69 6e 65 20 28 6c 61 75 6e  ...(define (laun
04c0: 63 68 3a 65 78 65 63 75 74 65 20 65 6e 63 6f 64  ch:execute encod
04d0: 65 64 2d 63 6d 64 29 0a 20 20 28 6c 65 74 2a 20  ed-cmd).  (let* 
04e0: 28 28 63 6d 64 69 6e 66 6f 20 20 20 28 72 65 61  ((cmdinfo   (rea
04f0: 64 20 28 6f 70 65 6e 2d 69 6e 70 75 74 2d 73 74  d (open-input-st
0500: 72 69 6e 67 20 28 62 61 73 65 36 34 3a 62 61 73  ring (base64:bas
0510: 65 36 34 2d 64 65 63 6f 64 65 20 65 6e 63 6f 64  e64-decode encod
0520: 65 64 2d 63 6d 64 29 29 29 29 29 0a 20 20 20 20  ed-cmd))))).    
0530: 28 73 65 74 65 6e 76 20 22 4d 54 5f 43 4d 44 49  (setenv "MT_CMDI
0540: 4e 46 4f 22 20 65 6e 63 6f 64 65 64 2d 63 6d 64  NFO" encoded-cmd
0550: 29 0a 20 20 20 20 28 69 66 20 28 6c 69 73 74 3f  ).    (if (list?
0560: 20 63 6d 64 69 6e 66 6f 29 20 3b 3b 20 28 28 74   cmdinfo) ;; ((t
0570: 65 73 74 70 61 74 68 20 2f 74 6d 70 2f 6d 72 77  estpath /tmp/mrw
0580: 65 6c 6c 61 6e 2f 6a 61 7a 7a 6d 69 6e 64 2f 73  ellan/jazzmind/s
0590: 72 63 2f 65 78 61 6d 70 6c 65 5f 72 75 6e 2f 74  rc/example_run/t
05a0: 65 73 74 73 2f 73 71 6c 69 74 65 73 70 65 65 64  ests/sqlitespeed
05b0: 29 20 28 74 65 73 74 2d 6e 61 6d 65 20 73 71 6c  ) (test-name sql
05c0: 69 74 65 73 70 65 65 64 29 20 28 72 75 6e 73 63  itespeed) (runsc
05d0: 72 69 70 74 20 72 75 6e 73 63 72 69 70 74 2e 72  ript runscript.r
05e0: 62 29 20 28 64 62 2d 68 6f 73 74 20 6c 6f 63 61  b) (db-host loca
05f0: 6c 68 6f 73 74 29 20 28 72 75 6e 2d 69 64 20 31  lhost) (run-id 1
0600: 29 29 0a 09 28 6c 65 74 2a 20 28 28 74 65 73 74  ))..(let* ((test
0610: 70 61 74 68 20 20 28 61 73 73 6f 63 2f 64 65 66  path  (assoc/def
0620: 61 75 6c 74 20 27 74 65 73 74 70 61 74 68 20 20  ault 'testpath  
0630: 63 6d 64 69 6e 66 6f 29 29 0a 09 20 20 20 20 20  cmdinfo))..     
0640: 20 20 28 77 6f 72 6b 2d 61 72 65 61 20 28 61 73    (work-area (as
0650: 73 6f 63 2f 64 65 66 61 75 6c 74 20 27 77 6f 72  soc/default 'wor
0660: 6b 2d 61 72 65 61 20 63 6d 64 69 6e 66 6f 29 29  k-area cmdinfo))
0670: 0a 09 20 20 20 20 20 20 20 28 74 65 73 74 2d 6e  ..       (test-n
0680: 61 6d 65 20 28 61 73 73 6f 63 2f 64 65 66 61 75  ame (assoc/defau
0690: 6c 74 20 27 74 65 73 74 2d 6e 61 6d 65 20 63 6d  lt 'test-name cm
06a0: 64 69 6e 66 6f 29 29 0a 09 20 20 20 20 20 20 20  dinfo))..       
06b0: 28 72 75 6e 73 63 72 69 70 74 20 28 61 73 73 6f  (runscript (asso
06c0: 63 2f 64 65 66 61 75 6c 74 20 27 72 75 6e 73 63  c/default 'runsc
06d0: 72 69 70 74 20 63 6d 64 69 6e 66 6f 29 29 0a 09  ript cmdinfo))..
06e0: 20 20 20 20 20 20 20 28 65 7a 73 74 65 70 73 20         (ezsteps 
06f0: 20 20 28 61 73 73 6f 63 2f 64 65 66 61 75 6c 74    (assoc/default
0700: 20 27 65 7a 73 74 65 70 73 20 20 20 63 6d 64 69   'ezsteps   cmdi
0710: 6e 66 6f 29 29 0a 09 20 20 20 20 20 20 20 28 64  nfo))..       (d
0720: 62 2d 68 6f 73 74 20 20 20 28 61 73 73 6f 63 2f  b-host   (assoc/
0730: 64 65 66 61 75 6c 74 20 27 64 62 2d 68 6f 73 74  default 'db-host
0740: 20 20 20 63 6d 64 69 6e 66 6f 29 29 0a 09 20 20     cmdinfo))..  
0750: 20 20 20 20 20 28 72 75 6e 2d 69 64 20 20 20 20       (run-id    
0760: 28 61 73 73 6f 63 2f 64 65 66 61 75 6c 74 20 27  (assoc/default '
0770: 72 75 6e 2d 69 64 20 20 20 20 63 6d 64 69 6e 66  run-id    cmdinf
0780: 6f 29 29 0a 09 20 20 20 20 20 20 20 28 69 74 65  o))..       (ite
0790: 6d 64 61 74 20 20 20 28 61 73 73 6f 63 2f 64 65  mdat   (assoc/de
07a0: 66 61 75 6c 74 20 27 69 74 65 6d 64 61 74 20 20  fault 'itemdat  
07b0: 20 63 6d 64 69 6e 66 6f 29 29 0a 09 20 20 20 20   cmdinfo))..    
07c0: 20 20 20 28 65 6e 76 2d 6f 76 72 64 20 20 28 61     (env-ovrd  (a
07d0: 73 73 6f 63 2f 64 65 66 61 75 6c 74 20 27 65 6e  ssoc/default 'en
07e0: 76 2d 6f 76 72 64 20 20 63 6d 64 69 6e 66 6f 29  v-ovrd  cmdinfo)
07f0: 29 0a 09 20 20 20 20 20 20 20 28 72 75 6e 6e 61  )..       (runna
0800: 6d 65 20 20 20 28 61 73 73 6f 63 2f 64 65 66 61  me   (assoc/defa
0810: 75 6c 74 20 27 72 75 6e 6e 61 6d 65 20 20 20 63  ult 'runname   c
0820: 6d 64 69 6e 66 6f 29 29 0a 09 20 20 20 20 20 20  mdinfo))..      
0830: 20 28 6d 65 67 61 74 65 73 74 20 20 28 61 73 73   (megatest  (ass
0840: 6f 63 2f 64 65 66 61 75 6c 74 20 27 6d 65 67 61  oc/default 'mega
0850: 74 65 73 74 20 20 63 6d 64 69 6e 66 6f 29 29 0a  test  cmdinfo)).
0860: 09 20 20 20 20 20 20 20 28 6d 74 2d 62 69 6e 64  .       (mt-bind
0870: 69 72 2d 70 61 74 68 20 28 61 73 73 6f 63 2f 64  ir-path (assoc/d
0880: 65 66 61 75 6c 74 20 27 6d 74 2d 62 69 6e 64 69  efault 'mt-bindi
0890: 72 2d 70 61 74 68 20 63 6d 64 69 6e 66 6f 29 29  r-path cmdinfo))
08a0: 0a 09 20 20 20 20 20 20 20 28 66 75 6c 6c 72 75  ..       (fullru
08b0: 6e 73 63 72 69 70 74 20 28 69 66 20 72 75 6e 73  nscript (if runs
08c0: 63 72 69 70 74 20 28 63 6f 6e 63 20 74 65 73 74  cript (conc test
08d0: 70 61 74 68 20 22 2f 22 20 72 75 6e 73 63 72 69  path "/" runscri
08e0: 70 74 29 20 23 66 29 29 0a 09 20 20 20 20 20 20  pt) #f))..      
08f0: 20 28 64 62 20 20 20 20 20 20 20 20 23 66 29 29   (db        #f))
0900: 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
0910: 20 32 20 22 45 78 65 63 74 75 69 6e 67 20 22 20   2 "Exectuing " 
0920: 74 65 73 74 2d 6e 61 6d 65 20 22 20 6f 6e 20 22  test-name " on "
0930: 20 28 67 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29   (get-host-name)
0940: 29 0a 09 20 20 28 63 68 61 6e 67 65 2d 64 69 72  )..  (change-dir
0950: 65 63 74 6f 72 79 20 74 65 73 74 70 61 74 68 29  ectory testpath)
0960: 0a 09 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f  ..  (setenv "MT_
0970: 54 45 53 54 5f 52 55 4e 5f 44 49 52 22 20 77 6f  TEST_RUN_DIR" wo
0980: 72 6b 2d 61 72 65 61 29 0a 09 20 20 28 73 65 74  rk-area)..  (set
0990: 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d  env "MT_TEST_NAM
09a0: 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20  E" test-name).. 
09b0: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 49 54 45   (setenv "MT_ITE
09c0: 4d 5f 49 4e 46 4f 22 20 28 63 6f 6e 63 20 69 74  M_INFO" (conc it
09d0: 65 6d 64 61 74 29 29 0a 09 20 20 28 73 65 74 65  emdat))..  (sete
09e0: 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20  nv "MT_RUNNAME" 
09f0: 20 20 72 75 6e 6e 61 6d 65 29 0a 09 20 20 28 73    runname)..  (s
0a00: 65 74 65 6e 76 20 22 4d 54 5f 4d 45 47 41 54 45  etenv "MT_MEGATE
0a10: 53 54 22 20 20 6d 65 67 61 74 65 73 74 29 0a 09  ST"  megatest)..
0a20: 20 20 28 69 66 20 6d 74 2d 62 69 6e 64 69 72 2d    (if mt-bindir-
0a30: 70 61 74 68 20 28 73 65 74 65 6e 76 20 22 50 41  path (setenv "PA
0a40: 54 48 22 20 28 63 6f 6e 63 20 28 67 65 74 65 6e  TH" (conc (geten
0a50: 76 20 22 50 41 54 48 22 29 20 22 3a 22 20 6d 74  v "PATH") ":" mt
0a60: 2d 62 69 6e 64 69 72 2d 70 61 74 68 29 29 29 0a  -bindir-path))).
0a70: 09 20 20 0a 09 20 20 28 69 66 20 28 6e 6f 74 20  .  ..  (if (not 
0a80: 28 73 65 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29  (setup-for-run))
0a90: 0a 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  ..      (begin..
0aa0: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
0ab0: 22 46 61 69 6c 65 64 20 74 6f 20 73 65 74 75 70  "Failed to setup
0ac0: 2c 20 65 78 69 74 69 6e 67 22 29 20 0a 09 09 28  , exiting") ...(
0ad0: 65 78 69 74 20 31 29 29 29 0a 09 20 20 3b 3b 20  exit 1)))..  ;; 
0ae0: 6e 6f 77 20 63 61 6e 20 66 69 6e 64 20 6f 75 72  now can find our
0af0: 20 64 62 0a 09 20 20 28 73 65 74 21 20 64 62 20   db..  (set! db 
0b00: 28 6f 70 65 6e 2d 64 62 29 29 0a 09 20 20 28 63  (open-db))..  (c
0b10: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20  hange-directory 
0b20: 77 6f 72 6b 2d 61 72 65 61 29 20 0a 09 20 20 28  work-area) ..  (
0b30: 73 65 74 2d 72 75 6e 2d 63 6f 6e 66 69 67 2d 76  set-run-config-v
0b40: 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a 09  ars db run-id)..
0b50: 20 20 3b 3b 20 65 6e 76 69 72 6f 6e 6d 65 6e 74    ;; environment
0b60: 20 6f 76 65 72 72 69 64 65 73 20 61 72 65 20 64   overrides are d
0b70: 6f 6e 65 20 2a 62 65 66 6f 72 65 2a 20 74 68 65  one *before* the
0b80: 20 72 65 6d 61 69 6e 69 6e 67 20 63 72 69 74 69   remaining criti
0b90: 63 61 6c 20 65 6e 76 61 72 73 2e 0a 09 20 20 28  cal envars...  (
0ba0: 61 6c 69 73 74 2d 3e 65 6e 76 2d 76 61 72 73 20  alist->env-vars 
0bb0: 65 6e 76 2d 6f 76 72 64 29 0a 09 20 20 28 73 65  env-ovrd)..  (se
0bc0: 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76  t-megatest-env-v
0bd0: 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a 09  ars db run-id)..
0be0: 20 20 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d    (set-item-env-
0bf0: 76 61 72 73 20 69 74 65 6d 64 61 74 29 0a 09 20  vars itemdat).. 
0c00: 20 28 73 61 76 65 2d 65 6e 76 69 72 6f 6e 6d 65   (save-environme
0c10: 6e 74 2d 61 73 2d 66 69 6c 65 73 20 22 6d 65 67  nt-as-files "meg
0c20: 61 74 65 73 74 22 29 0a 09 20 20 28 74 65 73 74  atest")..  (test
0c30: 2d 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64  -set-meta-info d
0c40: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
0c50: 6d 65 20 69 74 65 6d 64 61 74 29 0a 09 20 20 28  me itemdat)..  (
0c60: 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21  test-set-status!
0c70: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
0c80: 6e 61 6d 65 20 22 52 45 4d 4f 54 45 48 4f 53 54  name "REMOTEHOST
0c90: 53 54 41 52 54 22 20 22 6e 2f 61 22 20 69 74 65  START" "n/a" ite
0ca0: 6d 64 61 74 20 28 61 72 67 73 3a 67 65 74 2d 61  mdat (args:get-a
0cb0: 72 67 20 22 2d 6d 22 29 20 23 66 29 0a 09 20 20  rg "-m") #f)..  
0cc0: 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72  (if (args:get-ar
0cd0: 67 20 22 2d 78 74 65 72 6d 22 29 0a 09 20 20 20  g "-xterm")..   
0ce0: 20 20 20 28 73 65 74 21 20 66 75 6c 6c 72 75 6e     (set! fullrun
0cf0: 73 63 72 69 70 74 20 22 78 74 65 72 6d 22 29 0a  script "xterm").
0d00: 09 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20  .      (if (and 
0d10: 66 75 6c 6c 72 75 6e 73 63 72 69 70 74 20 28 6e  fullrunscript (n
0d20: 6f 74 20 28 66 69 6c 65 2d 65 78 65 63 75 74 65  ot (file-execute
0d30: 2d 61 63 63 65 73 73 3f 20 66 75 6c 6c 72 75 6e  -access? fullrun
0d40: 73 63 72 69 70 74 29 29 29 0a 09 09 20 20 28 73  script)))...  (s
0d50: 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 63 68 6d  ystem (conc "chm
0d60: 6f 64 20 75 67 2b 78 20 22 20 66 75 6c 6c 72 75  od ug+x " fullru
0d70: 6e 73 63 72 69 70 74 29 29 29 29 0a 09 20 20 3b  nscript))))..  ;
0d80: 3b 20 57 65 20 61 72 65 20 61 62 6f 75 74 20 74  ; We are about t
0d90: 6f 20 61 63 74 75 61 6c 6c 79 20 6b 69 63 6b 20  o actually kick 
0da0: 6f 66 66 20 74 68 65 20 74 65 73 74 0a 09 20 20  off the test..  
0db0: 3b 3b 20 73 6f 20 74 68 69 73 20 69 73 20 61 20  ;; so this is a 
0dc0: 67 6f 6f 64 20 70 6c 61 63 65 20 74 6f 20 72 65  good place to re
0dd0: 6d 6f 76 65 20 74 68 65 20 72 65 63 6f 72 64 73  move the records
0de0: 20 66 6f 72 20 0a 09 20 20 3b 3b 20 61 6e 79 20   for ..  ;; any 
0df0: 70 72 65 76 69 6f 75 73 20 72 75 6e 73 0a 09 20  previous runs.. 
0e00: 20 3b 3b 20 28 64 62 3a 74 65 73 74 2d 72 65 6d   ;; (db:test-rem
0e10: 6f 76 65 2d 73 74 65 70 73 20 64 62 20 72 75 6e  ove-steps db run
0e20: 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65  -id testname ite
0e30: 6d 64 61 74 29 0a 09 20 20 0a 09 20 20 3b 3b 20  mdat)..  ..  ;; 
0e40: 66 72 6f 6d 20 68 65 72 65 20 6f 6e 20 6f 75 74  from here on out
0e50: 20 77 65 20 77 69 6c 6c 20 6f 70 65 6e 20 61 6e   we will open an
0e60: 64 20 63 6c 6f 73 65 20 74 68 65 20 64 62 0a 09  d close the db..
0e70: 20 20 3b 3b 20 6f 6e 20 65 76 65 72 79 20 61 63    ;; on every ac
0e80: 63 65 73 73 20 74 6f 20 72 65 64 75 63 65 20 74  cess to reduce t
0e90: 68 65 20 70 72 6f 62 61 62 6c 69 74 69 79 20 6f  he probablitiy o
0ea0: 66 20 0a 09 20 20 3b 3b 20 63 6f 6e 74 65 6e 74  f ..  ;; content
0eb0: 69 6f 6e 20 6f 72 20 73 74 75 63 6b 20 61 63 63  ion or stuck acc
0ec0: 65 73 73 20 6f 6e 20 6e 66 73 2e 0a 09 20 20 28  ess on nfs...  (
0ed0: 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65  sqlite3:finalize
0ee0: 21 20 64 62 29 0a 0a 09 20 20 28 6c 65 74 2a 20  ! db)...  (let* 
0ef0: 28 28 6d 20 20 20 20 20 20 20 20 20 20 20 20 28  ((m            (
0f00: 6d 61 6b 65 2d 6d 75 74 65 78 29 29 0a 09 09 20  make-mutex))... 
0f10: 28 6b 69 6c 6c 2d 6a 6f 62 3f 20 20 20 20 23 66  (kill-job?    #f
0f20: 29 0a 09 09 20 28 65 78 69 74 2d 69 6e 66 6f 20  )... (exit-info 
0f30: 20 20 20 28 76 65 63 74 6f 72 20 23 74 20 23 74     (vector #t #t
0f40: 20 23 74 29 29 0a 09 09 20 28 6a 6f 62 2d 74 68   #t))... (job-th
0f50: 72 65 61 64 20 20 20 23 66 29 0a 09 09 20 28 72  read   #f)... (r
0f60: 75 6e 69 74 20 20 20 20 20 20 20 20 28 6c 61 6d  unit        (lam
0f70: 62 64 61 20 28 29 0a 09 09 09 09 20 3b 3b 20 28  bda ()..... ;; (
0f80: 6c 65 74 2d 76 61 6c 75 65 73 0a 09 09 09 09 20  let-values..... 
0f90: 3b 3b 20 20 28 28 28 70 69 64 20 65 78 69 74 2d  ;;  (((pid exit-
0fa0: 73 74 61 74 75 73 20 65 78 69 74 2d 63 6f 64 65  status exit-code
0fb0: 29 0a 09 09 09 09 20 3b 3b 20 20 20 20 28 72 75  )..... ;;    (ru
0fc0: 6e 2d 6e 2d 77 61 69 74 20 66 75 6c 6c 72 75 6e  n-n-wait fullrun
0fd0: 73 63 72 69 70 74 29 29 29 0a 09 09 09 09 20 0a  script)))..... .
0fe0: 09 09 09 09 20 3b 3b 20 69 66 20 74 68 65 72 65  .... ;; if there
0ff0: 20 69 73 20 61 20 72 75 6e 73 63 72 69 70 74 20   is a runscript 
1000: 64 6f 20 69 74 20 66 69 72 73 74 0a 09 09 09 09  do it first.....
1010: 20 28 69 66 20 66 75 6c 6c 72 75 6e 73 63 72 69   (if fullrunscri
1020: 70 74 0a 09 09 09 09 20 20 20 20 20 28 6c 65 74  pt.....     (let
1030: 20 28 28 70 69 64 20 28 70 72 6f 63 65 73 73 2d   ((pid (process-
1040: 72 75 6e 20 66 75 6c 6c 72 75 6e 73 63 72 69 70  run fullrunscrip
1050: 74 29 29 29 0a 09 09 09 09 20 20 20 20 20 20 20  t))).....       
1060: 28 6c 65 74 20 6c 6f 6f 70 20 28 28 69 20 30 29  (let loop ((i 0)
1070: 29 0a 09 09 09 09 09 20 28 6c 65 74 2d 76 61 6c  )...... (let-val
1080: 75 65 73 0a 09 09 09 09 09 20 20 28 28 28 70 69  ues......  (((pi
1090: 64 2d 76 61 6c 20 65 78 69 74 2d 73 74 61 74 75  d-val exit-statu
10a0: 73 20 65 78 69 74 2d 63 6f 64 65 29 20 28 70 72  s exit-code) (pr
10b0: 6f 63 65 73 73 2d 77 61 69 74 20 70 69 64 20 23  ocess-wait pid #
10c0: 74 29 29 29 0a 09 09 09 09 09 20 20 28 6d 75 74  t)))......  (mut
10d0: 65 78 2d 6c 6f 63 6b 21 20 6d 29 0a 09 09 09 09  ex-lock! m).....
10e0: 09 20 20 28 76 65 63 74 6f 72 2d 73 65 74 21 20  .  (vector-set! 
10f0: 65 78 69 74 2d 69 6e 66 6f 20 30 20 70 69 64 29  exit-info 0 pid)
1100: 0a 09 09 09 09 09 20 20 28 76 65 63 74 6f 72 2d  ......  (vector-
1110: 73 65 74 21 20 65 78 69 74 2d 69 6e 66 6f 20 31  set! exit-info 1
1120: 20 65 78 69 74 2d 73 74 61 74 75 73 29 0a 09 09   exit-status)...
1130: 09 09 09 20 20 28 76 65 63 74 6f 72 2d 73 65 74  ...  (vector-set
1140: 21 20 65 78 69 74 2d 69 6e 66 6f 20 32 20 65 78  ! exit-info 2 ex
1150: 69 74 2d 63 6f 64 65 29 0a 09 09 09 09 09 20 20  it-code)......  
1160: 28 6d 75 74 65 78 2d 75 6e 6c 6f 63 6b 21 20 6d  (mutex-unlock! m
1170: 29 0a 09 09 09 09 09 20 20 28 69 66 20 28 65 71  )......  (if (eq
1180: 3f 20 70 69 64 2d 76 61 6c 20 30 29 0a 09 09 09  ? pid-val 0)....
1190: 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  ..      (begin..
11a0: 09 09 09 09 09 28 74 68 72 65 61 64 2d 73 6c 65  .....(thread-sle
11b0: 65 70 21 20 32 29 0a 09 09 09 09 09 09 28 6c 6f  ep! 2).......(lo
11c0: 6f 70 20 28 2b 20 69 20 31 29 29 29 0a 09 09 09  op (+ i 1)))....
11d0: 09 09 20 20 20 20 20 20 29 29 29 29 29 0a 09 09  ..      )))))...
11e0: 09 09 20 3b 3b 20 74 68 65 6e 2c 20 69 66 20 72  .. ;; then, if r
11f0: 75 6e 73 63 72 69 70 74 20 72 61 6e 20 6f 6b 20  unscript ran ok 
1200: 28 6f 72 20 64 69 64 20 6e 6f 74 20 67 65 74 20  (or did not get 
1210: 63 61 6c 6c 65 64 29 0a 09 09 09 09 20 3b 3b 20  called)..... ;; 
1220: 64 6f 20 61 6c 6c 20 74 68 65 20 65 7a 73 74 65  do all the ezste
1230: 70 73 20 28 69 66 20 61 6e 79 29 0a 09 09 09 09  ps (if any).....
1240: 20 28 69 66 20 65 7a 73 74 65 70 73 0a 09 09 09   (if ezsteps....
1250: 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65  .     (let* ((te
1260: 73 74 63 6f 6e 66 69 67 20 28 72 65 61 64 2d 63  stconfig (read-c
1270: 6f 6e 66 69 67 20 28 63 6f 6e 63 20 77 6f 72 6b  onfig (conc work
1280: 2d 61 72 65 61 20 22 2f 74 65 73 74 63 6f 6e 66  -area "/testconf
1290: 69 67 22 29 20 23 66 20 23 74 29 29 20 3b 3b 20  ig") #f #t)) ;; 
12a0: 46 49 58 4d 45 3f 3f 3f 20 69 73 20 61 6c 6c 6f  FIXME??? is allo
12b0: 77 2d 73 79 73 74 65 6d 20 6f 6b 20 68 65 72 65  w-system ok here
12c0: 3f 0a 09 09 09 09 09 20 20 20 20 28 65 7a 73 74  ?......    (ezst
12d0: 65 70 73 6c 73 74 20 28 68 61 73 68 2d 74 61 62  epslst (hash-tab
12e0: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74  le-ref/default t
12f0: 65 73 74 63 6f 6e 66 69 67 20 22 65 7a 73 74 65  estconfig "ezste
1300: 70 73 22 20 27 28 29 29 29 29 0a 09 09 09 09 20  ps" '())))..... 
1310: 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28        (if (not (
1320: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 22 2e 65  file-exists? ".e
1330: 7a 73 74 65 70 73 22 29 29 28 63 72 65 61 74 65  zsteps"))(create
1340: 2d 64 69 72 65 63 74 6f 72 79 20 22 2e 65 7a 73  -directory ".ezs
1350: 74 65 70 73 22 29 29 0a 09 09 09 09 20 20 20 20  teps")).....    
1360: 20 20 20 3b 3b 20 69 66 20 65 7a 73 74 65 70 73     ;; if ezsteps
1370: 20 77 61 73 20 64 65 66 69 6e 65 64 20 74 68 65   was defined the
1380: 6e 20 77 65 20 61 72 65 20 73 75 72 65 20 74 6f  n we are sure to
1390: 20 68 61 76 65 20 61 74 20 6c 65 61 73 74 20 6f   have at least o
13a0: 6e 65 20 73 74 65 70 20 62 75 74 20 63 68 65 63  ne step but chec
13b0: 6b 20 61 6e 79 77 61 79 0a 09 09 09 09 20 20 20  k anyway.....   
13c0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 3e 20      (if (not (> 
13d0: 28 6c 65 6e 67 74 68 20 65 7a 73 74 65 70 73 6c  (length ezstepsl
13e0: 73 74 29 20 30 29 29 0a 09 09 09 09 09 20 20 20  st) 0))......   
13f0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
1400: 45 52 52 4f 52 3a 20 65 7a 73 74 65 70 73 20 64  ERROR: ezsteps d
1410: 65 66 69 6e 65 64 20 62 75 74 20 65 7a 73 74 65  efined but ezste
1420: 70 73 6c 73 74 20 69 73 20 7a 65 72 6f 20 6c 65  pslst is zero le
1430: 6e 67 74 68 22 29 0a 09 09 09 09 09 20 20 20 28  ngth")......   (
1440: 6c 65 74 20 6c 6f 6f 70 20 28 28 65 7a 73 74 65  let loop ((ezste
1450: 70 20 28 63 61 72 20 65 7a 73 74 65 70 73 6c 73  p (car ezstepsls
1460: 74 29 29 0a 09 09 09 09 09 09 20 20 20 20 20 20  t)).......      
1470: 28 74 61 6c 20 20 20 20 28 63 64 72 20 65 7a 73  (tal    (cdr ezs
1480: 74 65 70 73 6c 73 74 29 29 0a 09 09 09 09 09 09  tepslst)).......
1490: 20 20 20 20 20 20 28 70 72 65 76 73 74 65 70 20        (prevstep 
14a0: 23 66 29 29 0a 09 09 09 09 09 20 20 20 20 20 3b  #f))......     ;
14b0: 3b 20 63 68 65 63 6b 20 65 78 69 74 2d 69 6e 66  ; check exit-inf
14c0: 6f 20 28 76 65 63 74 6f 72 2d 72 65 66 20 65 78  o (vector-ref ex
14d0: 69 74 2d 69 6e 66 6f 20 31 29 0a 09 09 09 09 09  it-info 1)......
14e0: 20 20 20 20 20 28 69 66 20 28 76 65 63 74 6f 72       (if (vector
14f0: 2d 72 65 66 20 65 78 69 74 2d 69 6e 66 6f 20 31  -ref exit-info 1
1500: 29 0a 09 09 09 09 09 09 20 28 6c 65 74 2a 20 28  )....... (let* (
1510: 28 73 74 65 70 6e 61 6d 65 20 20 28 63 61 72 20  (stepname  (car 
1520: 65 7a 73 74 65 70 29 29 20 20 3b 3b 20 64 6f 20  ezstep))  ;; do 
1530: 73 74 75 66 66 20 74 6f 20 72 75 6e 20 74 68 65  stuff to run the
1540: 20 73 74 65 70 0a 09 09 09 09 09 09 09 28 73 74   step........(st
1550: 65 70 69 6e 66 6f 20 20 28 63 61 64 72 20 65 7a  epinfo  (cadr ez
1560: 73 74 65 70 29 29 0a 09 09 09 09 09 09 09 28 73  step))........(s
1570: 74 65 70 70 61 72 74 73 20 28 73 74 72 69 6e 67  tepparts (string
1580: 2d 6d 61 74 63 68 20 28 72 65 67 65 78 70 20 22  -match (regexp "
1590: 5e 28 5c 5c 7b 28 5b 5e 5c 5c 7d 5d 2a 29 5c 5c  ^(\\{([^\\}]*)\\
15a0: 7d 5c 5c 73 2a 7c 29 28 2e 2a 29 24 22 29 20 73  }\\s*|)(.*)$") s
15b0: 74 65 70 69 6e 66 6f 29 29 0a 09 09 09 09 09 09  tepinfo)).......
15c0: 09 28 73 74 65 70 70 61 72 6d 73 20 28 6c 69 73  .(stepparms (lis
15d0: 74 2d 72 65 66 20 73 74 65 70 70 61 72 74 73 20  t-ref stepparts 
15e0: 32 29 29 20 3b 3b 20 66 6f 72 20 66 75 74 75 72  2)) ;; for futur
15f0: 65 20 75 73 65 2c 20 7b 56 41 52 3d 31 2c 32 2c  e use, {VAR=1,2,
1600: 33 7d 2c 20 72 75 6e 20 73 74 65 70 20 66 6f 72  3}, run step for
1610: 20 65 61 63 68 20 0a 09 09 09 09 09 09 09 28 73   each ........(s
1620: 74 65 70 63 6d 64 20 20 20 28 6c 69 73 74 2d 72  tepcmd   (list-r
1630: 65 66 20 73 74 65 70 70 61 72 74 73 20 33 29 29  ef stepparts 3))
1640: 0a 09 09 09 09 09 09 09 28 73 63 72 69 70 74 20  ........(script 
1650: 20 20 22 23 21 2f 62 69 6e 2f 62 61 73 68 5c 6e    "#!/bin/bash\n
1660: 22 29 29 20 3b 3b 20 79 65 70 2c 20 77 65 20 64  ")) ;; yep, we d
1670: 65 70 65 6e 64 20 6f 6e 20 62 69 6e 2f 62 61 73  epend on bin/bas
1680: 68 20 46 49 58 4d 45 21 21 21 0a 09 09 09 09 09  h FIXME!!!......
1690: 09 20 20 20 3b 3b 20 4e 42 2f 2f 20 63 61 6e 20  .   ;; NB// can 
16a0: 73 61 66 65 6c 79 20 61 73 73 75 6d 65 20 77 65  safely assume we
16b0: 20 61 72 65 20 69 6e 20 74 65 73 74 2d 61 72 65   are in test-are
16c0: 61 20 64 69 72 65 63 74 6f 72 79 0a 09 09 09 09  a directory.....
16d0: 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ..   (debug:prin
16e0: 74 20 34 20 22 65 7a 73 74 65 70 73 3a 5c 6e 20  t 4 "ezsteps:\n 
16f0: 73 74 65 70 6e 61 6d 65 3a 20 22 20 73 74 65 70  stepname: " step
1700: 6e 61 6d 65 20 22 20 73 74 65 70 69 6e 66 6f 3a  name " stepinfo:
1710: 20 22 20 73 74 65 70 69 6e 66 6f 20 22 20 73 74   " stepinfo " st
1720: 65 70 70 61 72 74 73 3a 20 22 20 73 74 65 70 70  epparts: " stepp
1730: 61 72 74 73 0a 09 09 09 09 09 09 09 09 22 20 73  arts........." s
1740: 74 65 70 70 61 72 6d 73 3a 20 22 20 73 74 65 70  tepparms: " step
1750: 70 61 72 6d 73 20 22 20 73 74 65 70 63 6d 64 3a  parms " stepcmd:
1760: 20 22 20 73 74 65 70 63 6d 64 29 0a 09 09 09 09   " stepcmd).....
1770: 09 09 20 20 20 0a 09 09 09 09 09 09 20 20 20 3b  ..   .......   ;
1780: 3b 20 66 69 72 73 74 20 73 6f 75 72 63 65 20 74  ; first source t
1790: 68 65 20 70 72 65 76 69 6f 75 73 20 65 6e 76 69  he previous envi
17a0: 72 6f 6e 6d 65 6e 74 0a 09 09 09 09 09 09 20 20  ronment.......  
17b0: 20 28 69 66 20 28 61 6e 64 20 70 72 65 76 73 74   (if (and prevst
17c0: 65 70 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  ep (file-exists?
17d0: 20 70 72 65 76 73 74 65 70 29 29 0a 09 09 09 09   prevstep)).....
17e0: 09 09 20 20 20 20 20 20 20 28 73 65 74 21 20 73  ..       (set! s
17f0: 63 72 69 70 74 20 28 63 6f 6e 63 20 73 63 72 69  cript (conc scri
1800: 70 74 20 22 73 6f 75 72 63 65 20 2e 65 7a 73 74  pt "source .ezst
1810: 65 70 73 2f 22 20 70 72 65 76 73 74 65 70 20 22  eps/" prevstep "
1820: 2e 73 68 22 29 29 29 0a 09 09 09 09 09 09 20 20  .sh"))).......  
1830: 20 0a 09 09 09 09 09 09 20 20 20 3b 3b 20 63 61   .......   ;; ca
1840: 6c 6c 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20 75  ll the command u
1850: 73 69 6e 67 20 6d 74 5f 65 7a 73 74 65 70 0a 09  sing mt_ezstep..
1860: 09 09 09 09 09 20 20 20 28 73 65 74 21 20 73 63  .....   (set! sc
1870: 72 69 70 74 20 28 63 6f 6e 63 20 73 63 72 69 70  ript (conc scrip
1880: 74 20 22 6d 74 5f 65 7a 73 74 65 70 20 22 20 73  t "mt_ezstep " s
1890: 74 65 70 6e 61 6d 65 20 22 20 22 20 73 74 65 70  tepname " " step
18a0: 63 6d 64 20 22 5c 6e 22 29 29 0a 0a 09 09 09 09  cmd "\n"))......
18b0: 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ..   (debug:prin
18c0: 74 20 34 20 22 73 63 72 69 70 74 3a 20 22 20 73  t 4 "script: " s
18d0: 63 72 69 70 74 29 0a 0a 09 09 09 09 09 09 20 20  cript)........  
18e0: 20 3b 3b 20 6e 6f 77 20 6c 61 75 6e 63 68 0a 09   ;; now launch..
18f0: 09 09 09 09 09 20 20 20 28 6c 65 74 20 28 28 70  .....   (let ((p
1900: 69 64 20 28 70 72 6f 63 65 73 73 2d 72 75 6e 20  id (process-run 
1910: 73 63 72 69 70 74 29 29 29 0a 09 09 09 09 09 09  script))).......
1920: 20 20 20 20 20 28 6c 65 74 20 70 72 6f 63 65 73       (let proces
1930: 73 6c 6f 6f 70 20 28 28 69 20 30 29 29 0a 09 09  sloop ((i 0))...
1940: 09 09 09 09 20 20 20 20 20 20 20 28 6c 65 74 2d  ....       (let-
1950: 76 61 6c 75 65 73 20 28 28 28 70 69 64 2d 76 61  values (((pid-va
1960: 6c 20 65 78 69 74 2d 73 74 61 74 75 73 20 65 78  l exit-status ex
1970: 69 74 2d 63 6f 64 65 29 28 70 72 6f 63 65 73 73  it-code)(process
1980: 2d 77 61 69 74 20 70 69 64 20 23 74 29 29 29 0a  -wait pid #t))).
1990: 09 09 09 09 09 09 09 09 20 20 20 28 6d 75 74 65  ........   (mute
19a0: 78 2d 6c 6f 63 6b 21 20 6d 29 0a 09 09 09 09 09  x-lock! m)......
19b0: 09 09 09 20 20 20 28 76 65 63 74 6f 72 2d 73 65  ...   (vector-se
19c0: 74 21 20 65 78 69 74 2d 69 6e 66 6f 20 30 20 70  t! exit-info 0 p
19d0: 69 64 29 0a 09 09 09 09 09 09 09 09 20 20 20 28  id).........   (
19e0: 76 65 63 74 6f 72 2d 73 65 74 21 20 65 78 69 74  vector-set! exit
19f0: 2d 69 6e 66 6f 20 31 20 65 78 69 74 2d 73 74 61  -info 1 exit-sta
1a00: 74 75 73 29 0a 09 09 09 09 09 09 09 09 20 20 20  tus).........   
1a10: 28 76 65 63 74 6f 72 2d 73 65 74 21 20 65 78 69  (vector-set! exi
1a20: 74 2d 69 6e 66 6f 20 32 20 65 78 69 74 2d 63 6f  t-info 2 exit-co
1a30: 64 65 29 0a 09 09 09 09 09 09 09 09 20 20 20 28  de).........   (
1a40: 6d 75 74 65 78 2d 75 6e 6c 6f 63 6b 21 20 6d 29  mutex-unlock! m)
1a50: 0a 09 09 09 09 09 09 09 09 20 20 20 28 69 66 20  .........   (if 
1a60: 28 65 71 3f 20 70 69 64 2d 76 61 6c 20 30 29 0a  (eq? pid-val 0).
1a70: 09 09 09 09 09 09 09 09 20 20 20 20 20 20 20 28  ........       (
1a80: 62 65 67 69 6e 0a 09 09 09 09 09 09 09 09 09 20  begin.......... 
1a90: 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 32  (thread-sleep! 2
1aa0: 29 0a 09 09 09 09 09 09 09 09 09 20 28 70 72 6f  ).......... (pro
1ab0: 63 65 73 73 6c 6f 6f 70 20 28 2b 20 69 20 31 29  cessloop (+ i 1)
1ac0: 29 29 29 0a 09 09 09 09 09 09 09 09 20 20 20 29  ))).........   )
1ad0: 29 29 0a 09 09 09 09 09 09 20 20 20 28 69 66 20  )).......   (if 
1ae0: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29  (not (null? tal)
1af0: 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20 28  ).......       (
1b00: 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 20 28  loop (car tal) (
1b10: 63 64 72 20 74 61 6c 29 20 73 74 65 70 6e 61 6d  cdr tal) stepnam
1b20: 65 29 29 29 0a 09 09 09 09 09 20 20 20 20 20 28  e)))......     (
1b30: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 57  debug:print 4 "W
1b40: 41 52 4e 49 4e 47 3a 20 61 20 70 72 69 6f 72 20  ARNING: a prior 
1b50: 73 74 65 70 20 66 61 69 6c 65 64 2c 20 73 74 6f  step failed, sto
1b60: 70 70 69 6e 67 20 61 74 20 22 20 65 7a 73 74 65  pping at " ezste
1b70: 70 29 29 29 29 29 29 29 29 0a 09 09 20 28 6d 6f  p))))))))... (mo
1b80: 6e 69 74 6f 72 6a 6f 62 20 20 20 28 6c 61 6d 62  nitorjob   (lamb
1b90: 64 61 20 28 29 0a 09 09 09 09 20 28 6c 65 74 2a  da ()..... (let*
1ba0: 20 28 28 73 74 61 72 74 2d 73 65 63 6f 6e 64 73   ((start-seconds
1bb0: 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64   (current-second
1bc0: 73 29 29 0a 09 09 09 09 09 28 63 61 6c 63 2d 6d  s))......(calc-m
1bd0: 69 6e 75 74 65 73 20 20 28 6c 61 6d 62 64 61 20  inutes  (lambda 
1be0: 28 29 0a 09 09 09 09 09 09 09 20 28 69 6e 65 78  ()........ (inex
1bf0: 61 63 74 2d 3e 65 78 61 63 74 20 0a 09 09 09 09  act->exact .....
1c00: 09 09 09 20 20 28 72 6f 75 6e 64 20 0a 09 09 09  ...  (round ....
1c10: 09 09 09 09 20 20 20 28 2d 20 0a 09 09 09 09 09  ....   (- ......
1c20: 09 09 20 20 20 20 28 63 75 72 72 65 6e 74 2d 73  ..    (current-s
1c30: 65 63 6f 6e 64 73 29 20 0a 09 09 09 09 09 09 09  econds) ........
1c40: 20 20 20 20 73 74 61 72 74 2d 73 65 63 6f 6e 64      start-second
1c50: 73 29 29 29 29 29 0a 09 09 09 09 09 28 6b 69 6c  s)))))......(kil
1c60: 6c 2d 74 72 69 65 73 20 30 29 29 0a 09 09 09 09  l-tries 0)).....
1c70: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 6d     (let loop ((m
1c80: 69 6e 75 74 65 73 20 20 20 28 63 61 6c 63 2d 6d  inutes   (calc-m
1c90: 69 6e 75 74 65 73 29 29 29 0a 09 09 09 09 20 20  inutes))).....  
1ca0: 20 20 20 28 6c 65 74 2a 20 28 28 64 62 20 20 20     (let* ((db   
1cb0: 20 20 20 20 28 6f 70 65 6e 2d 64 62 29 29 0a 09      (open-db))..
1cc0: 09 09 09 09 20 20 20 20 28 63 70 75 6c 6f 61 64  ....    (cpuload
1cd0: 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64 29    (get-cpu-load)
1ce0: 29 0a 09 09 09 09 09 20 20 20 20 28 64 69 73 6b  )......    (disk
1cf0: 66 72 65 65 20 28 67 65 74 2d 64 66 20 28 63 75  free (get-df (cu
1d00: 72 72 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 29  rrent-directory)
1d10: 29 29 0a 09 09 09 09 09 20 20 20 20 28 74 6d 70  ))......    (tmp
1d20: 66 72 65 65 20 20 28 67 65 74 2d 64 66 20 22 2f  free  (get-df "/
1d30: 74 6d 70 22 29 29 29 0a 09 09 09 09 20 20 20 20  tmp"))).....    
1d40: 20 20 20 28 69 66 20 28 6e 6f 74 20 63 70 75 6c     (if (not cpul
1d50: 6f 61 64 29 20 20 28 62 65 67 69 6e 20 28 64 65  oad)  (begin (de
1d60: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
1d70: 4e 49 4e 47 3a 20 43 50 55 4c 4f 41 44 20 6e 6f  NING: CPULOAD no
1d80: 74 20 66 6f 75 6e 64 2e 22 29 20 20 28 73 65 74  t found.")  (set
1d90: 21 20 63 70 75 6c 6f 61 64 20 22 6e 2f 61 22 29  ! cpuload "n/a")
1da0: 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 69  )).....       (i
1db0: 66 20 28 6e 6f 74 20 64 69 73 6b 66 72 65 65 29  f (not diskfree)
1dc0: 20 28 62 65 67 69 6e 20 28 64 65 62 75 67 3a 70   (begin (debug:p
1dd0: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
1de0: 20 44 49 53 4b 46 52 45 45 20 6e 6f 74 20 66 6f   DISKFREE not fo
1df0: 75 6e 64 2e 22 29 20 28 73 65 74 21 20 64 69 73  und.") (set! dis
1e00: 6b 66 72 65 65 20 22 6e 2f 61 22 29 29 29 0a 09  kfree "n/a")))..
1e10: 09 09 09 20 20 20 20 20 20 20 28 73 65 74 21 20  ...       (set! 
1e20: 6b 69 6c 6c 2d 6a 6f 62 3f 20 28 74 65 73 74 2d  kill-job? (test-
1e30: 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65 73 74  get-kill-request
1e40: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
1e50: 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 29 0a 09  name itemdat))..
1e60: 09 09 09 20 20 20 20 20 20 20 28 74 65 73 74 2d  ...       (test-
1e70: 75 70 64 61 74 65 2d 6d 65 74 61 2d 69 6e 66 6f  update-meta-info
1e80: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
1e90: 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6d 69 6e  name itemdat min
1ea0: 75 74 65 73 20 63 70 75 6c 6f 61 64 20 64 69 73  utes cpuload dis
1eb0: 6b 66 72 65 65 20 74 6d 70 66 72 65 65 29 0a 09  kfree tmpfree)..
1ec0: 09 09 09 20 20 20 20 20 20 20 28 69 66 20 6b 69  ...       (if ki
1ed0: 6c 6c 2d 6a 6f 62 3f 20 0a 09 09 09 09 09 20 20  ll-job? ......  
1ee0: 20 28 62 65 67 69 6e 0a 09 09 09 09 09 20 20 20   (begin......   
1ef0: 20 20 28 6d 75 74 65 78 2d 6c 6f 63 6b 21 20 6d    (mutex-lock! m
1f00: 29 0a 09 09 09 09 09 20 20 20 20 20 28 6c 65 74  )......     (let
1f10: 2a 20 28 28 70 69 64 20 28 76 65 63 74 6f 72 2d  * ((pid (vector-
1f20: 72 65 66 20 65 78 69 74 2d 69 6e 66 6f 20 30 29  ref exit-info 0)
1f30: 29 29 0a 09 09 09 09 09 20 20 20 20 20 20 20 28  ))......       (
1f40: 69 66 20 28 6e 75 6d 62 65 72 3f 20 70 69 64 29  if (number? pid)
1f50: 0a 09 09 09 09 09 09 20 20 20 28 62 65 67 69 6e  .......   (begin
1f60: 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 65 62  .......     (deb
1f70: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
1f80: 49 4e 47 3a 20 52 65 71 75 65 73 74 20 72 65 63  ING: Request rec
1f90: 65 69 76 65 64 20 74 6f 20 6b 69 6c 6c 20 6a 6f  eived to kill jo
1fa0: 62 20 28 61 74 74 65 6d 70 74 20 23 20 22 20 6b  b (attempt # " k
1fb0: 69 6c 6c 2d 74 72 69 65 73 20 22 29 22 29 0a 09  ill-tries ")")..
1fc0: 09 09 09 09 09 20 20 20 20 20 28 6c 65 74 20 28  .....     (let (
1fd0: 28 70 72 6f 63 65 73 73 65 73 20 28 63 6d 64 2d  (processes (cmd-
1fe0: 72 75 6e 2d 3e 6c 69 73 74 20 28 63 6f 6e 63 20  run->list (conc 
1ff0: 22 70 67 72 65 70 20 2d 6c 20 2d 50 20 22 20 70  "pgrep -l -P " p
2000: 69 64 29 29 29 29 0a 09 09 09 09 09 09 20 20 20  id)))).......   
2010: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 09      (for-each ..
2020: 09 09 09 09 09 09 28 6c 61 6d 62 64 61 20 28 70  ......(lambda (p
2030: 29 0a 09 09 09 09 09 09 09 20 20 28 6c 65 74 2a  )........  (let*
2040: 20 28 28 70 61 72 74 73 20 20 28 73 74 72 69 6e   ((parts  (strin
2050: 67 2d 73 70 6c 69 74 20 70 29 29 0a 09 09 09 09  g-split p)).....
2060: 09 09 09 09 20 28 70 2d 69 64 20 20 20 28 69 66  .... (p-id   (if
2070: 20 28 3e 20 28 6c 65 6e 67 74 68 20 70 61 72 74   (> (length part
2080: 73 29 20 30 29 0a 09 09 09 09 09 09 09 09 09 20  s) 0).......... 
2090: 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d      (string->num
20a0: 62 65 72 20 28 63 61 72 20 70 61 72 74 73 29 29  ber (car parts))
20b0: 0a 09 09 09 09 09 09 09 09 09 20 20 20 20 20 23  ..........     #
20c0: 66 29 29 29 0a 09 09 09 09 09 09 09 20 20 20 20  f)))........    
20d0: 28 69 66 20 70 2d 69 64 0a 09 09 09 09 09 09 09  (if p-id........
20e0: 09 28 62 65 67 69 6e 0a 09 09 09 09 09 09 09 09  .(begin.........
20f0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
2100: 20 22 4b 69 6c 6c 69 6e 67 20 22 20 28 63 61 64   "Killing " (cad
2110: 72 20 70 61 72 74 73 29 20 22 3b 20 6b 69 6c 6c  r parts) "; kill
2120: 20 2d 39 20 20 22 20 70 2d 69 64 29 0a 09 09 09   -9  " p-id)....
2130: 09 09 09 09 09 20 20 28 73 79 73 74 65 6d 20 28  .....  (system (
2140: 63 6f 6e 63 20 22 6b 69 6c 6c 20 2d 39 20 22 20  conc "kill -9 " 
2150: 70 2d 69 64 29 29 29 29 29 29 0a 09 09 09 09 09  p-id))))))......
2160: 09 09 28 63 61 72 20 70 72 6f 63 65 73 73 65 73  ..(car processes
2170: 29 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20  )).......       
2180: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 6b  (system (conc "k
2190: 69 6c 6c 20 2d 39 20 22 20 70 69 64 29 29 29 29  ill -9 " pid))))
21a0: 0a 09 09 09 09 09 09 20 20 20 28 62 65 67 69 6e  .......   (begin
21b0: 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 65 62  .......     (deb
21c0: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
21d0: 49 4e 47 3a 20 52 65 71 75 65 73 74 20 72 65 63  ING: Request rec
21e0: 65 69 76 65 64 20 74 6f 20 6b 69 6c 6c 20 6a 6f  eived to kill jo
21f0: 62 20 62 75 74 20 70 72 6f 62 6c 65 6d 20 77 69  b but problem wi
2200: 74 68 20 70 72 6f 63 65 73 73 2c 20 61 74 74 65  th process, atte
2210: 6d 70 74 69 6e 67 20 74 6f 20 6b 69 6c 6c 20 6d  mpting to kill m
2220: 61 6e 61 67 65 72 20 70 72 6f 63 65 73 73 22 29  anager process")
2230: 0a 09 09 09 09 09 09 20 20 20 20 20 28 74 65 73  .......     (tes
2240: 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62  t-set-status! db
2250: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2260: 65 20 22 4b 49 4c 4c 45 44 22 20 20 22 46 41 49  e "KILLED"  "FAI
2270: 4c 22 0a 09 09 09 09 09 09 09 09 20 20 20 20 20  L".........     
2280: 20 20 69 74 65 6d 64 61 74 20 28 61 72 67 73 3a    itemdat (args:
2290: 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 20 23 66  get-arg "-m") #f
22a0: 29 0a 09 09 09 09 09 09 20 20 20 20 20 28 73 71  ).......     (sq
22b0: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20  lite3:finalize! 
22c0: 64 62 29 0a 09 09 09 09 09 09 20 20 20 20 20 28  db).......     (
22d0: 65 78 69 74 20 31 29 29 29 29 0a 09 09 09 09 09  exit 1))))......
22e0: 20 20 20 20 20 28 73 65 74 21 20 6b 69 6c 6c 2d       (set! kill-
22f0: 74 72 69 65 73 20 28 2b 20 31 20 6b 69 6c 6c 2d  tries (+ 1 kill-
2300: 74 72 69 65 73 29 29 0a 09 09 09 09 09 20 20 20  tries))......   
2310: 20 20 28 6d 75 74 65 78 2d 75 6e 6c 6f 63 6b 21    (mutex-unlock!
2320: 20 6d 29 29 29 0a 09 09 09 09 20 20 20 20 20 20   m))).....      
2330: 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69   (sqlite3:finali
2340: 7a 65 21 20 64 62 29 0a 09 09 09 09 20 20 20 20  ze! db).....    
2350: 20 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70     (thread-sleep
2360: 21 20 28 2b 20 38 20 28 72 61 6e 64 6f 6d 20 34  ! (+ 8 (random 4
2370: 29 29 29 20 3b 3b 20 61 64 64 20 73 6f 6d 65 20  ))) ;; add some 
2380: 6a 69 74 74 65 72 20 74 6f 20 74 68 65 20 63 61  jitter to the ca
2390: 6c 6c 20 68 6f 6d 65 20 74 69 6d 65 20 74 6f 20  ll home time to 
23a0: 73 70 72 65 61 64 20 6f 75 74 20 74 68 65 20 64  spread out the d
23b0: 62 20 61 63 63 65 73 73 65 73 0a 09 09 09 09 20  b accesses..... 
23c0: 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 6c        (loop (cal
23d0: 63 2d 6d 69 6e 75 74 65 73 29 29 29 29 29 29 29  c-minutes)))))))
23e0: 0a 09 09 20 28 74 68 31 20 20 20 20 20 20 20 20  ... (th1        
23f0: 20 20 28 6d 61 6b 65 2d 74 68 72 65 61 64 20 6d    (make-thread m
2400: 6f 6e 69 74 6f 72 6a 6f 62 29 29 0a 09 09 20 28  onitorjob))... (
2410: 74 68 32 20 20 20 20 20 20 20 20 20 20 28 6d 61  th2          (ma
2420: 6b 65 2d 74 68 72 65 61 64 20 72 75 6e 69 74 29  ke-thread runit)
2430: 29 29 0a 09 20 20 20 20 28 73 65 74 21 20 6a 6f  ))..    (set! jo
2440: 62 2d 74 68 72 65 61 64 20 74 68 32 29 0a 09 20  b-thread th2).. 
2450: 20 20 20 28 74 68 72 65 61 64 2d 73 74 61 72 74     (thread-start
2460: 21 20 74 68 31 29 0a 09 20 20 20 20 28 74 68 72  ! th1)..    (thr
2470: 65 61 64 2d 73 74 61 72 74 21 20 74 68 32 29 0a  ead-start! th2).
2480: 09 20 20 20 20 28 74 68 72 65 61 64 2d 6a 6f 69  .    (thread-joi
2490: 6e 21 20 74 68 32 29 0a 09 20 20 20 20 28 6d 75  n! th2)..    (mu
24a0: 74 65 78 2d 6c 6f 63 6b 21 20 6d 29 0a 09 20 20  tex-lock! m)..  
24b0: 20 20 28 73 65 74 21 20 64 62 20 28 6f 70 65 6e    (set! db (open
24c0: 2d 64 62 29 29 0a 09 20 20 20 20 28 6c 65 74 2a  -db))..    (let*
24d0: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74   ((item-path (it
24e0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
24f0: 65 6d 64 61 74 29 29 0a 09 09 20 20 20 28 74 65  emdat))...   (te
2500: 73 74 69 6e 66 6f 20 20 28 64 62 3a 67 65 74 2d  stinfo  (db:get-
2510: 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e  test-info db run
2520: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
2530: 65 6d 2d 70 61 74 68 29 29 29 0a 09 20 20 20 20  em-path)))..    
2540: 20 20 28 69 66 20 28 6e 6f 74 20 28 65 71 75 61    (if (not (equa
2550: 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  l? (db:test-get-
2560: 73 74 61 74 65 20 74 65 73 74 69 6e 66 6f 29 20  state testinfo) 
2570: 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a 09 09  "COMPLETED"))...
2580: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28    (begin...    (
2590: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 54  debug:print 2 "T
25a0: 65 73 74 20 4e 4f 54 20 6c 6f 67 67 65 64 20 61  est NOT logged a
25b0: 73 20 43 4f 4d 50 4c 45 54 45 44 2c 20 28 73 74  s COMPLETED, (st
25c0: 61 74 65 3d 22 20 28 64 62 3a 74 65 73 74 2d 67  ate=" (db:test-g
25d0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 69 6e 66  et-state testinf
25e0: 6f 29 20 22 29 2c 20 75 70 64 61 74 69 6e 67 20  o) "), updating 
25f0: 72 65 73 75 6c 74 22 29 0a 09 09 20 20 20 20 28  result")...    (
2600: 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21  test-set-status!
2610: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
2620: 6e 61 6d 65 0a 09 09 09 09 20 20 20 20 20 20 28  name.....      (
2630: 69 66 20 6b 69 6c 6c 2d 6a 6f 62 3f 20 22 4b 49  if kill-job? "KI
2640: 4c 4c 45 44 22 20 22 43 4f 4d 50 4c 45 54 45 44  LLED" "COMPLETED
2650: 22 29 0a 09 09 09 09 20 20 20 20 20 20 28 69 66  ").....      (if
2660: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 65 78 69   (vector-ref exi
2670: 74 2d 69 6e 66 6f 20 31 29 20 3b 3b 20 6c 6f 6f  t-info 1) ;; loo
2680: 6b 20 61 74 20 74 68 65 20 65 78 69 74 2d 73 74  k at the exit-st
2690: 61 74 75 73 0a 09 09 09 09 09 20 20 28 69 66 20  atus......  (if 
26a0: 28 61 6e 64 20 28 6e 6f 74 20 6b 69 6c 6c 2d 6a  (and (not kill-j
26b0: 6f 62 3f 29 20 0a 09 09 09 09 09 09 20 20 20 28  ob?) .......   (
26c0: 65 71 3f 20 28 76 65 63 74 6f 72 2d 72 65 66 20  eq? (vector-ref 
26d0: 65 78 69 74 2d 69 6e 66 6f 20 32 29 20 30 29 29  exit-info 2) 0))
26e0: 0a 09 09 09 09 09 20 20 20 20 20 20 22 50 41 53  ......      "PAS
26f0: 53 22 0a 09 09 09 09 09 20 20 20 20 20 20 22 46  S"......      "F
2700: 41 49 4c 22 29 0a 09 09 09 09 09 20 20 22 46 41  AIL")......  "FA
2710: 49 4c 22 29 20 69 74 65 6d 64 61 74 20 28 61 72  IL") itemdat (ar
2720: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29  gs:get-arg "-m")
2730: 20 23 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b   #f)))..      ;;
2740: 20 66 6f 72 20 61 75 74 6f 6d 61 74 65 64 20 63   for automated c
2750: 72 65 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 72  reation of the r
2760: 6f 6c 6c 75 70 20 68 74 6d 6c 20 66 69 6c 65 20  ollup html file 
2770: 74 68 69 73 20 69 73 20 61 20 67 6f 6f 64 20 70  this is a good p
2780: 6c 61 63 65 2e 2e 2e 0a 09 20 20 20 20 20 20 28  lace.....      (
2790: 69 66 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20  if (not (equal? 
27a0: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 0a 09  item-path ""))..
27b0: 09 20 20 28 74 65 73 74 73 3a 73 75 6d 6d 61 72  .  (tests:summar
27c0: 69 7a 65 2d 69 74 65 6d 73 20 64 62 20 72 75 6e  ize-items db run
27d0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 23 66  -id test-name #f
27e0: 29 29 20 3b 3b 20 64 6f 6e 27 74 20 66 6f 72 63  )) ;; don't forc
27f0: 65 20 2d 20 6a 75 73 74 20 75 70 64 61 74 65 20  e - just update 
2800: 69 66 20 6e 6f 0a 09 20 20 20 20 20 20 29 0a 09  if no..      )..
2810: 20 20 20 20 28 6d 75 74 65 78 2d 75 6e 6c 6f 63      (mutex-unloc
2820: 6b 21 20 6d 29 0a 09 20 20 20 20 3b 3b 20 28 65  k! m)..    ;; (e
2830: 78 65 63 2d 72 65 73 75 6c 74 73 20 28 63 6d 64  xec-results (cmd
2840: 2d 72 75 6e 2d 3e 6c 69 73 74 20 66 75 6c 6c 72  -run->list fullr
2850: 75 6e 73 63 72 69 70 74 29 29 20 3b 3b 20 20 28  unscript)) ;;  (
2860: 6c 69 73 74 20 22 3e 22 20 28 63 6f 6e 63 20 74  list ">" (conc t
2870: 65 73 74 2d 6e 61 6d 65 20 22 2d 72 75 6e 2e 6c  est-name "-run.l
2880: 6f 67 22 29 29 29 29 0a 09 20 20 20 20 3b 3b 20  og"))))..    ;; 
2890: 28 73 75 63 63 65 73 73 20 20 20 20 20 20 65 78  (success      ex
28a0: 65 63 2d 72 65 73 75 6c 74 73 29 29 20 3b 3b 20  ec-results)) ;; 
28b0: 28 65 71 3f 20 28 63 61 64 72 20 65 78 65 63 2d  (eq? (cadr exec-
28c0: 72 65 73 75 6c 74 73 29 20 30 29 29 29 0a 09 20  results) 0))).. 
28d0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
28e0: 32 20 22 4f 75 74 70 75 74 20 66 72 6f 6d 20 72  2 "Output from r
28f0: 75 6e 6e 69 6e 67 20 22 20 66 75 6c 6c 72 75 6e  unning " fullrun
2900: 73 63 72 69 70 74 20 22 2c 20 70 69 64 20 22 20  script ", pid " 
2910: 28 76 65 63 74 6f 72 2d 72 65 66 20 65 78 69 74  (vector-ref exit
2920: 2d 69 6e 66 6f 20 30 29 20 22 20 69 6e 20 77 6f  -info 0) " in wo
2930: 72 6b 20 61 72 65 61 20 22 20 0a 09 09 09 20 77  rk area " .... w
2940: 6f 72 6b 2d 61 72 65 61 20 22 3a 5c 6e 3d 3d 3d  ork-area ":\n===
2950: 3d 5c 6e 20 65 78 69 74 20 63 6f 64 65 20 22 20  =\n exit code " 
2960: 28 76 65 63 74 6f 72 2d 72 65 66 20 65 78 69 74  (vector-ref exit
2970: 2d 69 6e 66 6f 20 32 29 20 22 5c 6e 22 20 22 3d  -info 2) "\n" "=
2980: 3d 3d 3d 5c 6e 22 29 0a 09 20 20 20 20 28 73 71  ===\n")..    (sq
2990: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20  lite3:finalize! 
29a0: 64 62 29 0a 09 20 20 20 20 28 69 66 20 28 6e 6f  db)..    (if (no
29b0: 74 20 28 76 65 63 74 6f 72 2d 72 65 66 20 65 78  t (vector-ref ex
29c0: 69 74 2d 69 6e 66 6f 20 31 29 29 0a 09 09 28 65  it-info 1))...(e
29d0: 78 69 74 20 34 29 29 29 29 29 29 29 0a 0a 28 64  xit 4)))))))..(d
29e0: 65 66 69 6e 65 20 28 73 65 74 75 70 2d 66 6f 72  efine (setup-for
29f0: 2d 72 75 6e 29 0a 20 20 28 73 65 74 21 20 2a 63  -run).  (set! *c
2a00: 6f 6e 66 69 67 69 6e 66 6f 2a 20 28 66 69 6e 64  onfiginfo* (find
2a10: 2d 61 6e 64 2d 72 65 61 64 2d 63 6f 6e 66 69 67  -and-read-config
2a20: 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61   (if (args:get-a
2a30: 72 67 20 22 2d 63 6f 6e 66 69 67 22 29 28 61 72  rg "-config")(ar
2a40: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 63 6f 6e  gs:get-arg "-con
2a50: 66 69 67 22 29 20 22 6d 65 67 61 74 65 73 74 2e  fig") "megatest.
2a60: 63 6f 6e 66 69 67 22 29 29 29 0a 20 20 28 73 65  config"))).  (se
2a70: 74 21 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 20  t! *configdat*  
2a80: 28 69 66 20 28 63 61 72 20 2a 63 6f 6e 66 69 67  (if (car *config
2a90: 69 6e 66 6f 2a 29 28 63 61 72 20 2a 63 6f 6e 66  info*)(car *conf
2aa0: 69 67 69 6e 66 6f 2a 29 20 23 66 29 29 0a 20 20  iginfo*) #f)).  
2ab0: 28 73 65 74 21 20 2a 74 6f 70 70 61 74 68 2a 20  (set! *toppath* 
2ac0: 20 20 20 28 69 66 20 28 63 61 72 20 2a 63 6f 6e     (if (car *con
2ad0: 66 69 67 69 6e 66 6f 2a 29 28 63 61 64 72 20 2a  figinfo*)(cadr *
2ae0: 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 20 23 66 29  configinfo*) #f)
2af0: 29 0a 20 20 28 69 66 20 2a 74 6f 70 70 61 74 68  ).  (if *toppath
2b00: 2a 0a 20 20 20 20 20 20 28 73 65 74 65 6e 76 20  *.      (setenv 
2b10: 22 4d 54 5f 52 55 4e 5f 41 52 45 41 5f 48 4f 4d  "MT_RUN_AREA_HOM
2b20: 45 22 20 2a 74 6f 70 70 61 74 68 2a 29 20 3b 3b  E" *toppath*) ;;
2b30: 20 74 6f 20 62 65 20 64 65 70 72 65 63 61 74 65   to be deprecate
2b40: 64 0a 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  d.      (debug:p
2b50: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 66  rint 0 "ERROR: f
2b60: 61 69 6c 65 64 20 74 6f 20 66 69 6e 64 20 74 68  ailed to find th
2b70: 65 20 74 6f 70 20 70 61 74 68 20 74 6f 20 79 6f  e top path to yo
2b80: 75 72 20 72 75 6e 20 73 65 74 75 70 2e 22 29 29  ur run setup."))
2b90: 0a 20 20 2a 74 6f 70 70 61 74 68 2a 29 0a 0a 28  .  *toppath*)..(
2ba0: 64 65 66 69 6e 65 20 28 67 65 74 2d 62 65 73 74  define (get-best
2bb0: 2d 64 69 73 6b 20 63 6f 6e 66 64 61 74 29 0a 20  -disk confdat). 
2bc0: 20 28 6c 65 74 2a 20 28 28 64 69 73 6b 73 20 20   (let* ((disks  
2bd0: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
2be0: 66 2f 64 65 66 61 75 6c 74 20 63 6f 6e 66 64 61  f/default confda
2bf0: 74 20 22 64 69 73 6b 73 22 20 23 66 29 29 0a 09  t "disks" #f))..
2c00: 20 28 62 65 73 74 20 20 20 20 20 23 66 29 0a 09   (best     #f)..
2c10: 20 28 62 65 73 74 73 69 7a 65 20 30 29 29 0a 20   (bestsize 0)). 
2c20: 20 20 20 28 69 66 20 64 69 73 6b 73 20 0a 09 28     (if disks ..(
2c30: 66 6f 72 2d 65 61 63 68 20 0a 09 20 28 6c 61 6d  for-each .. (lam
2c40: 62 64 61 20 28 64 69 73 6b 2d 6e 75 6d 29 0a 09  bda (disk-num)..
2c50: 20 20 20 28 6c 65 74 2a 20 28 28 64 69 72 70 61     (let* ((dirpa
2c60: 74 68 20 20 20 20 28 63 61 64 72 20 28 61 73 73  th    (cadr (ass
2c70: 6f 63 20 64 69 73 6b 2d 6e 75 6d 20 64 69 73 6b  oc disk-num disk
2c80: 73 29 29 29 0a 09 09 20 20 28 66 72 65 65 73 70  s)))...  (freesp
2c90: 63 20 20 20 20 28 69 66 20 28 64 69 72 65 63 74  c    (if (direct
2ca0: 6f 72 79 3f 20 64 69 72 70 61 74 68 29 0a 09 09  ory? dirpath)...
2cb0: 09 09 20 20 28 67 65 74 2d 64 66 20 64 69 72 70  ..  (get-df dirp
2cc0: 61 74 68 29 0a 09 09 09 09 20 20 28 62 65 67 69  ath).....  (begi
2cd0: 6e 0a 09 09 09 09 20 20 20 20 28 64 65 62 75 67  n.....    (debug
2ce0: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
2cf0: 47 3a 20 70 61 74 68 20 22 20 64 69 72 70 61 74  G: path " dirpat
2d00: 68 20 22 20 69 6e 20 5b 64 69 73 6b 73 5d 20 73  h " in [disks] s
2d10: 65 63 74 69 6f 6e 20 6e 6f 74 20 76 61 6c 69 64  ection not valid
2d20: 22 29 0a 09 09 09 09 20 20 20 20 30 29 29 29 29  ").....    0))))
2d30: 0a 09 20 20 20 20 20 28 69 66 20 28 3e 20 66 72  ..     (if (> fr
2d40: 65 65 73 70 63 20 62 65 73 74 73 69 7a 65 29 0a  eespc bestsize).
2d50: 09 09 20 28 62 65 67 69 6e 0a 09 09 20 20 20 28  .. (begin...   (
2d60: 73 65 74 21 20 62 65 73 74 20 20 20 20 20 64 69  set! best     di
2d70: 72 70 61 74 68 29 0a 09 09 20 20 20 28 73 65 74  rpath)...   (set
2d80: 21 20 62 65 73 74 73 69 7a 65 20 66 72 65 65 73  ! bestsize frees
2d90: 70 63 29 29 29 29 29 0a 09 20 28 6d 61 70 20 63  pc))))).. (map c
2da0: 61 72 20 64 69 73 6b 73 29 29 29 0a 20 20 20 20  ar disks))).    
2db0: 28 69 66 20 62 65 73 74 0a 09 62 65 73 74 0a 09  (if best..best..
2dc0: 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67  (begin..  (debug
2dd0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
2de0: 20 4e 6f 20 76 61 6c 69 64 20 64 69 73 6b 73 20   No valid disks 
2df0: 66 6f 75 6e 64 20 69 6e 20 6d 65 67 61 74 65 73  found in megates
2e00: 74 2e 63 6f 6e 66 69 67 2e 20 50 6c 65 61 73 65  t.config. Please
2e10: 20 61 64 64 20 73 6f 6d 65 20 74 6f 20 79 6f 75   add some to you
2e20: 72 20 5b 64 69 73 6b 73 5d 20 73 65 63 74 69 6f  r [disks] sectio
2e30: 6e 22 29 0a 09 20 20 28 65 78 69 74 20 31 29 29  n")..  (exit 1))
2e40: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 63 72  )))..(define (cr
2e50: 65 61 74 65 2d 77 6f 72 6b 2d 61 72 65 61 20 64  eate-work-area d
2e60: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 70 61  b run-id test-pa
2e70: 74 68 20 64 69 73 6b 2d 70 61 74 68 20 74 65 73  th disk-path tes
2e80: 74 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a 20  tname itemdat). 
2e90: 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 6e 66   (let* ((run-inf
2ea0: 6f 20 28 64 62 3a 67 65 74 2d 72 75 6e 2d 69 6e  o (db:get-run-in
2eb0: 66 6f 20 64 62 20 72 75 6e 2d 69 64 29 29 0a 09  fo db run-id))..
2ec0: 20 28 69 74 65 6d 2d 70 61 74 68 20 28 6c 65 74   (item-path (let
2ed0: 20 28 28 69 70 20 28 69 74 65 6d 2d 6c 69 73 74   ((ip (item-list
2ee0: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  ->path itemdat))
2ef0: 29 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 65  )...      (if (e
2f00: 71 75 61 6c 3f 20 69 70 20 22 22 29 20 22 22 20  qual? ip "") "" 
2f10: 28 63 6f 6e 63 20 22 2f 22 20 69 70 29 29 29 29  (conc "/" ip))))
2f20: 0a 09 20 28 72 75 6e 6e 61 6d 65 20 20 28 64 62  .. (runname  (db
2f30: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
2f40: 61 64 65 72 20 28 64 62 3a 67 65 74 2d 72 6f 77  ader (db:get-row
2f50: 20 72 75 6e 2d 69 6e 66 6f 29 0a 09 09 09 09 09   run-info)......
2f60: 20 20 20 28 64 62 3a 67 65 74 2d 68 65 61 64 65     (db:get-heade
2f70: 72 20 72 75 6e 2d 69 6e 66 6f 29 0a 09 09 09 09  r run-info).....
2f80: 09 20 20 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a  .   "runname")).
2f90: 09 20 28 6b 65 79 2d 76 61 6c 73 20 28 67 65 74  . (key-vals (get
2fa0: 2d 6b 65 79 2d 76 61 6c 73 20 64 62 20 72 75 6e  -key-vals db run
2fb0: 2d 69 64 29 29 0a 09 20 28 6b 65 79 2d 73 74 72  -id)).. (key-str
2fc0: 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73    (string-inters
2fd0: 70 65 72 73 65 20 6b 65 79 2d 76 61 6c 73 20 22  perse key-vals "
2fe0: 2f 22 29 29 0a 09 20 28 64 66 75 6c 6c 70 20 20  /")).. (dfullp  
2ff0: 20 28 63 6f 6e 63 20 64 69 73 6b 2d 70 61 74 68   (conc disk-path
3000: 20 22 2f 22 20 6b 65 79 2d 73 74 72 20 22 2f 22   "/" key-str "/"
3010: 20 72 75 6e 6e 61 6d 65 20 22 2f 22 20 74 65 73   runname "/" tes
3020: 74 6e 61 6d 65 0a 09 09 09 20 69 74 65 6d 2d 70  tname.... item-p
3030: 61 74 68 29 29 0a 09 20 28 74 6f 70 74 65 73 74  ath)).. (toptest
3040: 2d 70 61 74 68 20 28 63 6f 6e 63 20 64 69 73 6b  -path (conc disk
3050: 2d 70 61 74 68 20 22 2f 22 20 6b 65 79 2d 73 74  -path "/" key-st
3060: 72 20 22 2f 22 20 72 75 6e 6e 61 6d 65 20 22 2f  r "/" runname "/
3070: 22 20 74 65 73 74 6e 61 6d 65 29 29 0a 09 20 28  " testname)).. (
3080: 72 75 6e 73 64 69 72 20 20 28 63 6f 6e 66 69 67  runsdir  (config
3090: 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64  -lookup *configd
30a0: 61 74 2a 20 22 73 65 74 75 70 22 20 22 72 75 6e  at* "setup" "run
30b0: 73 64 69 72 22 29 29 0a 09 20 28 6c 6e 6b 70 61  sdir")).. (lnkpa
30c0: 74 68 20 20 28 63 6f 6e 63 20 28 69 66 20 72 75  th  (conc (if ru
30d0: 6e 73 64 69 72 20 72 75 6e 73 64 69 72 20 28 63  nsdir runsdir (c
30e0: 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  onc *toppath* "/
30f0: 72 75 6e 73 22 29 29 0a 09 09 09 20 22 2f 22 20  runs")).... "/" 
3100: 6b 65 79 2d 73 74 72 20 22 2f 22 20 72 75 6e 6e  key-str "/" runn
3110: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ame item-path)))
3120: 0a 20 20 20 20 3b 3b 20 73 69 6e 63 65 20 74 68  .    ;; since th
3130: 69 73 20 69 73 20 61 6e 20 69 74 65 72 61 74 65  is is an iterate
3140: 64 20 74 65 73 74 20 74 68 69 73 20 69 73 20 61  d test this is a
3150: 73 20 67 6f 6f 64 20 61 20 70 6c 61 63 65 20 61  s good a place a
3160: 73 20 61 6e 79 20 74 6f 0a 20 20 20 20 3b 3b 20  s any to.    ;; 
3170: 75 70 64 61 74 65 20 74 68 65 20 74 6f 70 74 65  update the topte
3180: 73 74 20 72 65 63 6f 72 64 20 77 69 74 68 20 69  st record with i
3190: 74 73 20 6c 6f 63 61 74 69 6f 6e 20 72 75 6e 64  ts location rund
31a0: 69 72 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20  ir.    (if (not 
31b0: 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74  (equal? item-pat
31c0: 68 20 22 22 29 29 0a 09 28 64 62 3a 74 65 73 74  h ""))..(db:test
31d0: 2d 73 65 74 2d 72 75 6e 64 69 72 21 20 64 62 20  -set-rundir! db 
31e0: 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20  run-id testname 
31f0: 22 22 20 74 6f 70 74 65 73 74 2d 70 61 74 68 29  "" toptest-path)
3200: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
3210: 6e 74 20 32 20 22 53 65 74 74 69 6e 67 20 75 70  nt 2 "Setting up
3220: 20 74 65 73 74 20 72 75 6e 20 61 72 65 61 22 29   test run area")
3230: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
3240: 74 20 32 20 22 20 2d 20 63 72 65 61 74 69 6e 67  t 2 " - creating
3250: 20 72 75 6e 20 61 72 65 61 20 69 6e 20 22 20 64   run area in " d
3260: 66 75 6c 6c 70 29 0a 20 20 20 20 28 73 79 73 74  fullp).    (syst
3270: 65 6d 20 20 28 63 6f 6e 63 20 22 6d 6b 64 69 72  em  (conc "mkdir
3280: 20 2d 70 20 22 20 64 66 75 6c 6c 70 29 29 0a 20   -p " dfullp)). 
3290: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
32a0: 32 20 22 20 2d 20 63 72 65 61 74 69 6e 67 20 6c  2 " - creating l
32b0: 69 6e 6b 20 66 72 6f 6d 20 22 20 64 66 75 6c 6c  ink from " dfull
32c0: 70 20 22 2f 22 20 74 65 73 74 6e 61 6d 65 20 22  p "/" testname "
32d0: 20 74 6f 20 22 20 6c 6e 6b 70 61 74 68 29 0a 20   to " lnkpath). 
32e0: 20 20 20 28 73 79 73 74 65 6d 20 20 28 63 6f 6e     (system  (con
32f0: 63 20 22 6d 6b 64 69 72 20 2d 70 20 22 20 6c 6e  c "mkdir -p " ln
3300: 6b 70 61 74 68 29 29 0a 0a 3b 3b 20 49 20 73 75  kpath))..;; I su
3310: 73 70 65 63 74 20 74 68 69 73 20 73 65 63 74 69  spect this secti
3320: 6f 6e 20 77 61 73 20 64 65 6c 65 74 69 6e 67 20  on was deleting 
3330: 74 65 73 74 20 64 69 72 65 63 74 6f 72 69 65 73  test directories
3340: 20 75 6e 64 65 72 20 73 6f 6d 65 20 0a 3b 3b 20   under some .;; 
3350: 77 69 65 72 64 20 73 69 74 61 74 69 6f 6e 73 0a  wierd sitations.
3360: 0a 3b 3b 20 20 20 20 28 69 66 20 28 66 69 6c 65  .;;    (if (file
3370: 2d 65 78 69 73 74 73 3f 20 28 63 6f 6e 63 20 6c  -exists? (conc l
3380: 6e 6b 70 61 74 68 20 22 2f 22 20 74 65 73 74 6e  nkpath "/" testn
3390: 61 6d 65 29 29 0a 3b 3b 09 28 73 79 73 74 65 6d  ame)).;;.(system
33a0: 20 28 63 6f 6e 63 20 22 72 6d 20 2d 66 20 22 20   (conc "rm -f " 
33b0: 6c 6e 6b 70 61 74 68 20 22 2f 22 20 74 65 73 74  lnkpath "/" test
33c0: 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 73 79 73  name))).    (sys
33d0: 74 65 6d 20 20 28 63 6f 6e 63 20 22 6c 6e 20 2d  tem  (conc "ln -
33e0: 73 66 20 22 20 64 66 75 6c 6c 70 20 22 20 22 20  sf " dfullp " " 
33f0: 6c 6e 6b 70 61 74 68 20 22 2f 22 20 74 65 73 74  lnkpath "/" test
3400: 6e 61 6d 65 29 29 0a 20 20 20 20 28 69 66 20 28  name)).    (if (
3410: 64 69 72 65 63 74 6f 72 79 3f 20 64 66 75 6c 6c  directory? dfull
3420: 70 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 6c  p)..(begin..  (l
3430: 65 74 2a 20 28 28 63 6d 64 20 20 20 20 28 63 6f  et* ((cmd    (co
3440: 6e 63 20 22 72 73 79 6e 63 20 2d 61 76 22 20 28  nc "rsync -av" (
3450: 69 66 20 28 3e 20 2a 76 65 72 62 6f 73 69 74 79  if (> *verbosity
3460: 2a 20 31 29 20 22 22 20 22 71 22 29 20 22 20 22  * 1) "" "q") " "
3470: 20 74 65 73 74 2d 70 61 74 68 20 22 2f 20 22 20   test-path "/ " 
3480: 64 66 75 6c 6c 70 20 22 2f 22 29 29 0a 09 09 20  dfullp "/"))... 
3490: 28 73 74 61 74 75 73 20 28 73 79 73 74 65 6d 20  (status (system 
34a0: 63 6d 64 29 29 29 0a 09 20 20 20 20 28 69 66 20  cmd)))..    (if 
34b0: 28 6e 6f 74 20 28 65 71 3f 20 73 74 61 74 75 73  (not (eq? status
34c0: 20 30 29 29 0a 09 09 28 64 65 62 75 67 3a 70 72   0))...(debug:pr
34d0: 69 6e 74 20 32 20 22 45 52 52 4f 52 3a 20 70 72  int 2 "ERROR: pr
34e0: 6f 62 6c 65 6d 20 77 69 74 68 20 72 75 6e 6e 69  oblem with runni
34f0: 6e 67 20 5c 22 22 20 63 6d 64 20 22 5c 22 22 29  ng \"" cmd "\"")
3500: 29 29 0a 09 20 20 28 6c 69 73 74 20 64 66 75 6c  ))..  (list dful
3510: 6c 70 20 74 6f 70 74 65 73 74 2d 70 61 74 68 29  lp toptest-path)
3520: 29 0a 09 28 6c 69 73 74 20 23 66 20 23 66 29 29  )..(list #f #f))
3530: 29 29 0a 0a 3b 3b 20 31 2e 20 6c 6f 6f 6b 20 74  ))..;; 1. look t
3540: 68 6f 75 67 68 20 64 69 73 6b 73 20 6c 69 73 74  hough disks list
3550: 20 66 6f 72 20 64 69 73 6b 20 77 69 74 68 20 6d   for disk with m
3560: 6f 73 74 20 73 70 61 63 65 0a 3b 3b 20 32 2e 20  ost space.;; 2. 
3570: 63 72 65 61 74 65 20 72 75 6e 20 64 69 72 20 6f  create run dir o
3580: 6e 20 64 69 73 6b 2c 20 70 61 74 68 20 6e 61 6d  n disk, path nam
3590: 65 20 69 73 20 6d 65 61 6e 69 6e 67 66 75 6c 0a  e is meaningful.
35a0: 3b 3b 20 33 2e 20 63 72 65 61 74 65 20 6c 69 6e  ;; 3. create lin
35b0: 6b 20 66 72 6f 6d 20 72 75 6e 20 64 69 72 20 74  k from run dir t
35c0: 6f 20 6d 65 67 61 74 65 73 74 20 72 75 6e 73 20  o megatest runs 
35d0: 61 72 65 61 20 0a 3b 3b 20 34 2e 20 72 65 6d 6f  area .;; 4. remo
35e0: 74 65 6c 79 20 72 75 6e 20 74 68 65 20 74 65 73  tely run the tes
35f0: 74 20 6f 6e 20 61 6c 6c 6f 63 61 74 65 64 20 68  t on allocated h
3600: 6f 73 74 0a 3b 3b 20 20 20 20 2d 20 63 6f 75 6c  ost.;;    - coul
3610: 64 20 62 65 20 73 73 68 20 74 6f 20 68 6f 73 74  d be ssh to host
3620: 20 66 72 6f 6d 20 68 6f 73 74 73 20 74 61 62 6c   from hosts tabl
3630: 65 20 28 75 70 64 61 74 65 20 72 65 67 75 6c 61  e (update regula
3640: 72 6c 79 20 77 69 74 68 20 6c 6f 61 64 29 0a 3b  rly with load).;
3650: 3b 20 20 20 20 2d 20 63 6f 75 6c 64 20 62 65 20  ;    - could be 
3660: 6e 65 74 62 61 74 63 68 0a 3b 3b 20 20 20 20 20  netbatch.;;     
3670: 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62   (launch-test db
3680: 20 28 63 61 64 72 20 73 74 61 74 75 73 29 20 74   (cadr status) t
3690: 65 73 74 2d 63 6f 6e 66 29 29 0a 28 64 65 66 69  est-conf)).(defi
36a0: 6e 65 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20  ne (launch-test 
36b0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 63  db run-id test-c
36c0: 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 65  onf keyvallst te
36d0: 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 74  st-name test-pat
36e0: 68 20 69 74 65 6d 64 61 74 29 0a 20 20 28 63 68  h itemdat).  (ch
36f0: 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 2a  ange-directory *
3700: 74 6f 70 70 61 74 68 2a 29 0a 20 20 28 6c 65 74  toppath*).  (let
3710: 20 28 28 75 73 65 73 68 65 6c 6c 20 20 20 28 63   ((useshell   (c
3720: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f  onfig-lookup *co
3730: 6e 66 69 67 64 61 74 2a 20 22 6a 6f 62 74 6f 6f  nfigdat* "jobtoo
3740: 6c 73 22 20 20 20 20 20 22 75 73 65 73 68 65 6c  ls"     "useshel
3750: 6c 22 29 29 0a 09 28 6c 61 75 6e 63 68 65 72 20  l"))..(launcher 
3760: 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70    (config-lookup
3770: 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 6a 6f   *configdat* "jo
3780: 62 74 6f 6f 6c 73 22 20 20 20 20 20 22 6c 61 75  btools"     "lau
3790: 6e 63 68 65 72 22 29 29 0a 09 28 72 75 6e 73 63  ncher"))..(runsc
37a0: 72 69 70 74 20 20 28 63 6f 6e 66 69 67 2d 6c 6f  ript  (config-lo
37b0: 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 20  okup test-conf  
37c0: 20 22 73 65 74 75 70 22 20 20 20 20 20 20 20 20   "setup"        
37d0: 22 72 75 6e 73 63 72 69 70 74 22 29 29 0a 09 28  "runscript"))..(
37e0: 65 7a 73 74 65 70 73 20 20 20 20 28 3e 20 28 6c  ezsteps    (> (l
37f0: 65 6e 67 74 68 20 28 68 61 73 68 2d 74 61 62 6c  ength (hash-tabl
3800: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74 65  e-ref/default te
3810: 73 74 2d 63 6f 6e 66 20 22 65 7a 73 74 65 70 73  st-conf "ezsteps
3820: 22 20 27 28 29 29 29 20 30 29 29 20 3b 3b 20 64  " '())) 0)) ;; d
3830: 6f 6e 27 74 20 73 65 6e 64 20 61 6c 6c 20 74 68  on't send all th
3840: 65 20 73 74 65 70 73 2c 20 63 6f 75 6c 64 20 62  e steps, could b
3850: 65 20 62 69 67 0a 09 28 64 69 73 6b 73 70 61 63  e big..(diskspac
3860: 65 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75  e  (config-looku
3870: 70 20 74 65 73 74 2d 63 6f 6e 66 20 20 20 22 72  p test-conf   "r
3880: 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 64 69  equirements" "di
3890: 73 6b 73 70 61 63 65 22 29 29 0a 09 28 6d 65 6d  skspace"))..(mem
38a0: 6f 72 79 20 20 20 20 20 28 63 6f 6e 66 69 67 2d  ory     (config-
38b0: 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66  lookup test-conf
38c0: 20 20 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73     "requirements
38d0: 22 20 22 6d 65 6d 6f 72 79 22 29 29 0a 09 28 68  " "memory"))..(h
38e0: 6f 73 74 73 20 20 20 20 20 20 28 63 6f 6e 66 69  osts      (confi
38f0: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
3900: 64 61 74 2a 20 22 6a 6f 62 74 6f 6f 6c 73 22 20  dat* "jobtools" 
3910: 20 20 20 20 22 77 6f 72 6b 68 6f 73 74 73 22 29      "workhosts")
3920: 29 0a 09 28 72 65 6d 6f 74 65 2d 6d 65 67 61 74  )..(remote-megat
3930: 65 73 74 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  est (config-look
3940: 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22  up *configdat* "
3950: 73 65 74 75 70 22 20 22 65 78 65 63 75 74 61 62  setup" "executab
3960: 6c 65 22 29 29 0a 09 28 6c 6f 63 61 6c 2d 6d 65  le"))..(local-me
3970: 67 61 74 65 73 74 20 20 28 63 61 72 20 28 61 72  gatest  (car (ar
3980: 67 76 29 29 29 0a 09 28 74 65 73 74 2d 73 69 67  gv)))..(test-sig
3990: 20 20 20 28 63 6f 6e 63 20 22 3d 22 20 74 65 73     (conc "=" tes
39a0: 74 2d 6e 61 6d 65 20 22 3a 22 20 28 69 74 65 6d  t-name ":" (item
39b0: 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d  -list->path item
39c0: 64 61 74 29 20 22 3d 22 29 29 20 3b 3b 20 74 65  dat) "=")) ;; te
39d0: 73 74 2d 70 61 74 68 20 69 73 20 74 68 65 20 66  st-path is the f
39e0: 75 6c 6c 20 70 61 74 68 20 69 6e 63 6c 75 64 69  ull path includi
39f0: 6e 67 20 74 68 65 20 69 74 65 6d 2d 70 61 74 68  ng the item-path
3a00: 0a 09 28 77 6f 72 6b 2d 61 72 65 61 20 20 23 66  ..(work-area  #f
3a10: 29 0a 09 28 74 6f 70 74 65 73 74 2d 77 6f 72 6b  )..(toptest-work
3a20: 2d 61 72 65 61 20 23 66 29 20 3b 3b 20 66 6f 72  -area #f) ;; for
3a30: 20 69 74 65 72 61 74 65 64 20 74 65 73 74 73 20   iterated tests 
3a40: 74 68 65 20 74 6f 70 20 74 65 73 74 20 63 6f 6e  the top test con
3a50: 74 61 69 6e 73 20 64 61 74 61 20 72 65 6c 65 76  tains data relev
3a60: 61 6e 74 20 66 6f 72 20 61 6c 6c 0a 09 28 64 69  ant for all..(di
3a70: 73 6b 70 61 74 68 20 20 20 23 66 29 0a 09 28 63  skpath   #f)..(c
3a80: 6d 64 70 61 72 6d 73 20 20 20 23 66 29 0a 09 28  mdparms   #f)..(
3a90: 66 75 6c 6c 63 6d 64 20 20 20 20 23 66 29 20 3b  fullcmd    #f) ;
3aa0: 3b 20 28 64 65 66 69 6e 65 20 61 20 28 77 69 74  ; (define a (wit
3ab0: 68 2d 6f 75 74 70 75 74 2d 74 6f 2d 73 74 72 69  h-output-to-stri
3ac0: 6e 67 20 28 6c 61 6d 62 64 61 20 28 29 28 77 72  ng (lambda ()(wr
3ad0: 69 74 65 20 78 29 29 29 29 0a 09 28 6d 74 2d 62  ite x))))..(mt-b
3ae0: 69 6e 64 69 72 2d 70 61 74 68 20 23 66 29 29 0a  indir-path #f)).
3af0: 20 20 20 20 28 69 66 20 68 6f 73 74 73 20 28 73      (if hosts (s
3b00: 65 74 21 20 68 6f 73 74 73 20 28 73 74 72 69 6e  et! hosts (strin
3b10: 67 2d 73 70 6c 69 74 20 68 6f 73 74 73 29 29 29  g-split hosts)))
3b20: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 72 65  .    (if (not re
3b30: 6d 6f 74 65 2d 6d 65 67 61 74 65 73 74 29 28 73  mote-megatest)(s
3b40: 65 74 21 20 72 65 6d 6f 74 65 2d 6d 65 67 61 74  et! remote-megat
3b50: 65 73 74 20 6c 6f 63 61 6c 2d 6d 65 67 61 74 65  est local-megate
3b60: 73 74 29 29 20 3b 3b 20 22 6d 65 67 61 74 65 73  st)) ;; "megates
3b70: 74 22 29 29 0a 20 20 20 20 28 73 65 74 21 20 6d  t")).    (set! m
3b80: 74 2d 62 69 6e 64 69 72 2d 70 61 74 68 20 28 70  t-bindir-path (p
3b90: 61 74 68 6e 61 6d 65 2d 64 69 72 65 63 74 6f 72  athname-director
3ba0: 79 20 72 65 6d 6f 74 65 2d 6d 65 67 61 74 65 73  y remote-megates
3bb0: 74 29 29 0a 20 20 20 20 28 69 66 20 6c 61 75 6e  t)).    (if laun
3bc0: 63 68 65 72 20 28 73 65 74 21 20 6c 61 75 6e 63  cher (set! launc
3bd0: 68 65 72 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  her (string-spli
3be0: 74 20 6c 61 75 6e 63 68 65 72 29 29 29 0a 20 20  t launcher))).  
3bf0: 20 20 3b 3b 20 73 65 74 20 75 70 20 74 68 65 20    ;; set up the 
3c00: 72 75 6e 20 77 6f 72 6b 20 61 72 65 61 20 66 6f  run work area fo
3c10: 72 20 74 68 69 73 20 74 65 73 74 0a 20 20 20 20  r this test.    
3c20: 28 73 65 74 21 20 64 69 73 6b 70 61 74 68 20 28  (set! diskpath (
3c30: 67 65 74 2d 62 65 73 74 2d 64 69 73 6b 20 2a 63  get-best-disk *c
3c40: 6f 6e 66 69 67 64 61 74 2a 29 29 0a 20 20 20 20  onfigdat*)).    
3c50: 28 69 66 20 64 69 73 6b 70 61 74 68 0a 09 28 6c  (if diskpath..(l
3c60: 65 74 20 28 28 64 61 74 20 20 28 63 72 65 61 74  et ((dat  (creat
3c70: 65 2d 77 6f 72 6b 2d 61 72 65 61 20 64 62 20 72  e-work-area db r
3c80: 75 6e 2d 69 64 20 74 65 73 74 2d 70 61 74 68 20  un-id test-path 
3c90: 64 69 73 6b 70 61 74 68 20 74 65 73 74 2d 6e 61  diskpath test-na
3ca0: 6d 65 20 69 74 65 6d 64 61 74 29 29 29 0a 09 20  me itemdat))).. 
3cb0: 20 28 73 65 74 21 20 77 6f 72 6b 2d 61 72 65 61   (set! work-area
3cc0: 20 28 63 61 72 20 64 61 74 29 29 0a 09 20 20 28   (car dat))..  (
3cd0: 73 65 74 21 20 74 6f 70 74 65 73 74 2d 77 6f 72  set! toptest-wor
3ce0: 6b 2d 61 72 65 61 20 28 63 61 64 72 20 64 61 74  k-area (cadr dat
3cf0: 29 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28  )))..(begin..  (
3d00: 73 65 74 21 20 77 6f 72 6b 2d 61 72 65 61 20 74  set! work-area t
3d10: 65 73 74 2d 70 61 74 68 29 0a 09 20 20 28 64 65  est-path)..  (de
3d20: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
3d30: 4e 49 4e 47 3a 20 4e 6f 20 64 69 73 6b 20 77 6f  NING: No disk wo
3d40: 72 6b 20 61 72 65 61 20 73 70 65 63 69 66 69 65  rk area specifie
3d50: 64 20 2d 20 72 75 6e 6e 69 6e 67 20 69 6e 20 74  d - running in t
3d60: 68 65 20 74 65 73 74 20 64 69 72 65 63 74 6f 72  he test director
3d70: 79 22 29 29 29 0a 20 20 20 20 28 73 65 74 21 20  y"))).    (set! 
3d80: 63 6d 64 70 61 72 6d 73 20 28 62 61 73 65 36 34  cmdparms (base64
3d90: 3a 62 61 73 65 36 34 2d 65 6e 63 6f 64 65 20 28  :base64-encode (
3da0: 77 69 74 68 2d 6f 75 74 70 75 74 2d 74 6f 2d 73  with-output-to-s
3db0: 74 72 69 6e 67 0a 09 09 09 09 20 20 20 20 28 6c  tring.....    (l
3dc0: 61 6d 62 64 61 20 28 29 20 3b 3b 20 28 6c 69 73  ambda () ;; (lis
3dd0: 74 20 27 68 6f 73 74 73 20 20 20 20 20 68 6f 73  t 'hosts     hos
3de0: 74 73 29 0a 09 09 09 09 20 20 20 20 20 20 28 77  ts).....      (w
3df0: 72 69 74 65 20 28 6c 69 73 74 20 28 6c 69 73 74  rite (list (list
3e00: 20 27 74 65 73 74 70 61 74 68 20 20 74 65 73 74   'testpath  test
3e10: 2d 70 61 74 68 29 0a 09 09 09 09 09 09 20 20 20  -path).......   
3e20: 28 6c 69 73 74 20 27 77 6f 72 6b 2d 61 72 65 61  (list 'work-area
3e30: 20 77 6f 72 6b 2d 61 72 65 61 29 0a 09 09 09 09   work-area).....
3e40: 09 09 20 20 20 28 6c 69 73 74 20 27 74 65 73 74  ..   (list 'test
3e50: 2d 6e 61 6d 65 20 74 65 73 74 2d 6e 61 6d 65 29  -name test-name)
3e60: 20 0a 09 09 09 09 09 09 20 20 20 28 6c 69 73 74   .......   (list
3e70: 20 27 72 75 6e 73 63 72 69 70 74 20 72 75 6e 73   'runscript runs
3e80: 63 72 69 70 74 29 20 0a 09 09 09 09 09 09 20 20  cript) .......  
3e90: 20 28 6c 69 73 74 20 27 72 75 6e 2d 69 64 20 20   (list 'run-id  
3ea0: 20 20 72 75 6e 2d 69 64 20 20 20 29 0a 09 09 09    run-id   )....
3eb0: 09 09 09 20 20 20 28 6c 69 73 74 20 27 69 74 65  ...   (list 'ite
3ec0: 6d 64 61 74 20 20 20 69 74 65 6d 64 61 74 20 20  mdat   itemdat  
3ed0: 29 0a 09 09 09 09 09 09 20 20 20 28 6c 69 73 74  ).......   (list
3ee0: 20 27 6d 65 67 61 74 65 73 74 20 20 72 65 6d 6f   'megatest  remo
3ef0: 74 65 2d 6d 65 67 61 74 65 73 74 29 0a 09 09 09  te-megatest)....
3f00: 09 09 09 20 20 20 28 6c 69 73 74 20 27 65 7a 73  ...   (list 'ezs
3f10: 74 65 70 73 20 20 20 65 7a 73 74 65 70 73 29 0a  teps   ezsteps).
3f20: 09 09 09 09 09 09 20 20 20 28 6c 69 73 74 20 27  ......   (list '
3f30: 65 6e 76 2d 6f 76 72 64 20 20 28 68 61 73 68 2d  env-ovrd  (hash-
3f40: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
3f50: 74 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 65  t *configdat* "e
3f60: 6e 76 2d 6f 76 65 72 72 69 64 65 22 20 27 28 29  nv-override" '()
3f70: 29 29 0a 09 09 09 09 09 09 20 20 20 28 6c 69 73  )).......   (lis
3f80: 74 20 27 72 75 6e 6e 61 6d 65 20 20 20 28 61 72  t 'runname   (ar
3f90: 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e  gs:get-arg ":run
3fa0: 6e 61 6d 65 22 29 29 0a 09 09 09 09 09 09 20 20  name")).......  
3fb0: 20 28 6c 69 73 74 20 27 6d 74 2d 62 69 6e 64 69   (list 'mt-bindi
3fc0: 72 2d 70 61 74 68 20 6d 74 2d 62 69 6e 64 69 72  r-path mt-bindir
3fd0: 2d 70 61 74 68 29 29 29 29 29 29 29 20 3b 3b 20  -path))))))) ;; 
3fe0: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
3ff0: 72 73 65 20 6b 65 79 76 61 6c 6c 73 74 20 22 20  rse keyvallst " 
4000: 22 29 29 29 29 0a 20 20 20 20 3b 3b 20 63 6c 65  ")))).    ;; cle
4010: 61 6e 20 6f 75 74 20 73 74 65 70 20 72 65 63 6f  an out step reco
4020: 72 64 73 20 66 72 6f 6d 20 70 72 65 76 69 6f 75  rds from previou
4030: 73 20 72 75 6e 20 69 66 20 74 68 65 79 20 65 78  s run if they ex
4040: 69 73 74 0a 20 20 20 20 28 64 62 3a 64 65 6c 65  ist.    (db:dele
4050: 74 65 2d 74 65 73 74 2d 73 74 65 70 2d 72 65 63  te-test-step-rec
4060: 6f 72 64 73 20 64 62 20 72 75 6e 2d 69 64 20 74  ords db run-id t
4070: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74  est-name itemdat
4080: 29 0a 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69  ).    (change-di
4090: 72 65 63 74 6f 72 79 20 77 6f 72 6b 2d 61 72 65  rectory work-are
40a0: 61 29 20 3b 3b 20 73 6f 20 74 68 61 74 20 6c 6f  a) ;; so that lo
40b0: 67 20 66 69 6c 65 73 20 66 72 6f 6d 20 74 68 65  g files from the
40c0: 20 6c 61 75 6e 63 68 20 70 72 6f 63 65 73 73 20   launch process 
40d0: 64 6f 6e 27 74 20 63 6c 75 74 74 65 72 20 74 68  don't clutter th
40e0: 65 20 74 65 73 74 20 64 69 72 0a 20 20 20 20 28  e test dir.    (
40f0: 63 6f 6e 64 0a 20 20 20 20 20 28 28 61 6e 64 20  cond.     ((and 
4100: 6c 61 75 6e 63 68 65 72 20 68 6f 73 74 73 29 20  launcher hosts) 
4110: 3b 3b 20 6d 75 73 74 20 62 65 20 75 73 69 6e 67  ;; must be using
4120: 20 73 73 68 20 68 6f 73 74 6e 61 6d 65 0a 20 20   ssh hostname.  
4130: 20 20 20 20 28 73 65 74 21 20 66 75 6c 6c 63 6d      (set! fullcm
4140: 64 20 28 61 70 70 65 6e 64 20 6c 61 75 6e 63 68  d (append launch
4150: 65 72 20 28 63 61 72 20 68 6f 73 74 73 29 28 6c  er (car hosts)(l
4160: 69 73 74 20 72 65 6d 6f 74 65 2d 6d 65 67 61 74  ist remote-megat
4170: 65 73 74 20 74 65 73 74 2d 73 69 67 20 22 2d 65  est test-sig "-e
4180: 78 65 63 75 74 65 22 20 63 6d 64 70 61 72 6d 73  xecute" cmdparms
4190: 29 29 29 29 0a 20 20 20 20 20 28 6c 61 75 6e 63  )))).     (launc
41a0: 68 65 72 0a 20 20 20 20 20 20 28 73 65 74 21 20  her.      (set! 
41b0: 66 75 6c 6c 63 6d 64 20 28 61 70 70 65 6e 64 20  fullcmd (append 
41c0: 6c 61 75 6e 63 68 65 72 20 28 6c 69 73 74 20 72  launcher (list r
41d0: 65 6d 6f 74 65 2d 6d 65 67 61 74 65 73 74 20 74  emote-megatest t
41e0: 65 73 74 2d 73 69 67 20 22 2d 65 78 65 63 75 74  est-sig "-execut
41f0: 65 22 20 63 6d 64 70 61 72 6d 73 29 29 29 29 0a  e" cmdparms)))).
4200: 20 20 20 20 20 28 65 6c 73 65 0a 20 20 20 20 20       (else.     
4210: 20 28 69 66 20 28 6e 6f 74 20 75 73 65 73 68 65   (if (not useshe
4220: 6c 6c 29 28 64 65 62 75 67 3a 70 72 69 6e 74 20  ll)(debug:print 
4230: 30 20 22 57 41 52 4e 49 4e 47 3a 20 69 6e 74 65  0 "WARNING: inte
4240: 72 6e 61 6c 20 6c 61 75 6e 63 68 69 6e 67 20 77  rnal launching w
4250: 69 6c 6c 20 6e 6f 74 20 77 6f 72 6b 20 77 65 6c  ill not work wel
4260: 6c 20 77 69 74 68 6f 75 74 20 5c 22 75 73 65 73  l without \"uses
4270: 68 65 6c 6c 20 79 65 73 5c 22 20 69 6e 20 79 6f  hell yes\" in yo
4280: 75 72 20 5b 6a 6f 62 74 6f 6f 6c 73 5d 20 73 65  ur [jobtools] se
4290: 63 74 69 6f 6e 22 29 29 0a 20 20 20 20 20 20 28  ction")).      (
42a0: 73 65 74 21 20 66 75 6c 6c 63 6d 64 20 28 6c 69  set! fullcmd (li
42b0: 73 74 20 72 65 6d 6f 74 65 2d 6d 65 67 61 74 65  st remote-megate
42c0: 73 74 20 74 65 73 74 2d 73 69 67 20 22 2d 65 78  st test-sig "-ex
42d0: 65 63 75 74 65 22 20 63 6d 64 70 61 72 6d 73 20  ecute" cmdparms 
42e0: 28 69 66 20 75 73 65 73 68 65 6c 6c 20 22 26 22  (if useshell "&"
42f0: 20 22 22 29 29 29 29 29 0a 20 20 20 20 28 69 66   ""))))).    (if
4300: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
4310: 2d 78 74 65 72 6d 22 29 28 73 65 74 21 20 66 75  -xterm")(set! fu
4320: 6c 6c 63 6d 64 20 28 61 70 70 65 6e 64 20 66 75  llcmd (append fu
4330: 6c 6c 63 6d 64 20 28 6c 69 73 74 20 22 2d 78 74  llcmd (list "-xt
4340: 65 72 6d 22 29 29 29 29 0a 20 20 20 20 28 64 65  erm")))).    (de
4350: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75  bug:print 1 "Lau
4360: 6e 63 68 69 6e 67 20 6d 65 67 61 74 65 73 74 20  nching megatest 
4370: 66 6f 72 20 74 65 73 74 20 22 20 74 65 73 74 2d  for test " test-
4380: 6e 61 6d 65 20 22 20 69 6e 20 22 20 77 6f 72 6b  name " in " work
4390: 2d 61 72 65 61 22 20 2e 2e 2e 22 29 0a 20 20 20  -area" ...").   
43a0: 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75   (test-set-statu
43b0: 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  s! db run-id tes
43c0: 74 2d 6e 61 6d 65 20 22 4c 41 55 4e 43 48 45 44  t-name "LAUNCHED
43d0: 22 20 22 6e 2f 61 22 20 69 74 65 6d 64 61 74 20  " "n/a" itemdat 
43e0: 23 66 20 23 66 29 20 3b 3b 20 28 69 66 20 6c 61  #f #f) ;; (if la
43f0: 75 6e 63 68 2d 72 65 73 75 6c 74 73 20 6c 61 75  unch-results lau
4400: 6e 63 68 2d 72 65 73 75 6c 74 73 20 22 46 41 49  nch-results "FAI
4410: 4c 45 44 22 29 29 0a 20 20 20 20 3b 3b 20 73 65  LED")).    ;; se
4420: 74 20 0a 20 20 20 20 3b 3b 20 73 65 74 20 70 72  t .    ;; set pr
4430: 65 2d 6c 61 75 6e 63 68 2d 65 6e 76 2d 76 61 72  e-launch-env-var
4440: 73 20 62 65 66 6f 72 65 20 6c 61 75 6e 63 68 69  s before launchi
4450: 6e 67 2c 20 6b 65 65 70 20 74 68 65 20 76 61 72  ng, keep the var
4460: 73 20 69 6e 20 70 72 65 76 76 61 6c 73 20 61 6e  s in prevvals an
4470: 64 20 70 75 74 20 74 68 65 20 65 6e 76 69 6f 6e  d put the envion
4480: 6d 65 6e 74 20 62 61 63 6b 20 77 68 65 6e 20 64  ment back when d
4490: 6f 6e 65 0a 20 20 20 20 28 64 65 62 75 67 3a 70  one.    (debug:p
44a0: 72 69 6e 74 20 34 20 22 66 75 6c 6c 63 6d 64 3a  rint 4 "fullcmd:
44b0: 20 22 20 66 75 6c 6c 63 6d 64 29 0a 20 20 20 20   " fullcmd).    
44c0: 28 6c 65 74 2a 20 28 28 63 6f 6d 6d 6f 6e 70 72  (let* ((commonpr
44d0: 65 76 76 61 6c 73 20 28 61 6c 69 73 74 2d 3e 65  evvals (alist->e
44e0: 6e 76 2d 76 61 72 73 0a 09 09 09 20 20 20 20 28  nv-vars....    (
44f0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
4500: 65 66 61 75 6c 74 20 2a 63 6f 6e 66 69 67 64 61  efault *configda
4510: 74 2a 20 22 65 6e 76 2d 6f 76 65 72 72 69 64 65  t* "env-override
4520: 22 20 27 28 29 29 29 29 0a 09 20 20 20 28 74 65  " '())))..   (te
4530: 73 74 70 72 65 76 76 61 6c 73 20 20 20 28 61 6c  stprevvals   (al
4540: 69 73 74 2d 3e 65 6e 76 2d 76 61 72 73 0a 09 09  ist->env-vars...
4550: 09 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  .    (hash-table
4560: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73  -ref/default tes
4570: 74 2d 63 6f 6e 66 20 22 70 72 65 2d 6c 61 75 6e  t-conf "pre-laun
4580: 63 68 2d 65 6e 76 2d 6f 76 65 72 72 69 64 65 73  ch-env-overrides
4590: 22 20 27 28 29 29 29 29 0a 09 20 20 20 28 6d 69  " '())))..   (mi
45a0: 73 63 70 72 65 76 76 61 6c 73 20 20 20 28 61 6c  scprevvals   (al
45b0: 69 73 74 2d 3e 65 6e 76 2d 76 61 72 73 20 3b 3b  ist->env-vars ;;
45c0: 20 63 6f 6e 73 6f 6c 69 64 61 74 65 20 74 68 69   consolidate thi
45d0: 73 20 63 6f 64 65 20 77 69 74 68 20 74 68 65 20  s code with the 
45e0: 63 6f 64 65 20 69 6e 20 6d 65 67 61 74 65 73 74  code in megatest
45f0: 2e 73 63 6d 20 66 6f 72 20 22 2d 65 78 65 63 75  .scm for "-execu
4600: 74 65 22 0a 09 09 09 20 20 20 20 28 61 70 70 65  te"....    (appe
4610: 6e 64 20 28 6c 69 73 74 20 28 6c 69 73 74 20 22  nd (list (list "
4620: 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74 65  MT_TEST_NAME" te
4630: 73 74 2d 6e 61 6d 65 29 0a 09 09 09 09 09 20 20  st-name)......  
4640: 28 6c 69 73 74 20 22 4d 54 5f 49 54 45 4d 5f 49  (list "MT_ITEM_I
4650: 4e 46 4f 22 20 28 63 6f 6e 63 20 69 74 65 6d 64  NFO" (conc itemd
4660: 61 74 29 29 20 0a 09 09 09 09 09 20 20 28 6c 69  at)) ......  (li
4670: 73 74 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20  st "MT_RUNNAME" 
4680: 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20    (args:get-arg 
4690: 22 3a 72 75 6e 6e 61 6d 65 22 29 29 29 0a 09 09  ":runname")))...
46a0: 09 09 20 20 20 20 69 74 65 6d 64 61 74 29 29 29  ..    itemdat)))
46b0: 0a 09 20 20 20 28 6c 61 75 6e 63 68 2d 72 65 73  ..   (launch-res
46c0: 75 6c 74 73 20 28 61 70 70 6c 79 20 63 6d 64 2d  ults (apply cmd-
46d0: 72 75 6e 2d 70 72 6f 63 2d 65 61 63 68 2d 6c 69  run-proc-each-li
46e0: 6e 65 0a 09 09 09 09 20 20 28 69 66 20 75 73 65  ne.....  (if use
46f0: 73 68 65 6c 6c 0a 09 09 09 09 20 20 20 20 20 20  shell.....      
4700: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
4710: 72 73 65 20 66 75 6c 6c 63 6d 64 20 22 20 22 29  rse fullcmd " ")
4720: 0a 09 09 09 09 20 20 20 20 20 20 28 63 61 72 20  .....      (car 
4730: 66 75 6c 6c 63 6d 64 29 29 0a 09 09 09 09 20 20  fullcmd)).....  
4740: 70 72 69 6e 74 0a 09 09 09 09 20 20 28 69 66 20  print.....  (if 
4750: 75 73 65 73 68 65 6c 6c 0a 09 09 09 09 20 20 20  useshell.....   
4760: 20 20 20 27 28 29 0a 09 09 09 09 20 20 20 20 20     '().....     
4770: 20 28 63 64 72 20 66 75 6c 6c 63 6d 64 29 29 29   (cdr fullcmd)))
4780: 29 29 20 3b 3b 20 20 6c 61 75 6e 63 68 65 72 20  )) ;;  launcher 
4790: 66 75 6c 6c 63 6d 64 29 29 29 3b 3b 20 28 61 70  fullcmd)));; (ap
47a0: 70 6c 79 20 63 6d 64 2d 72 75 6e 2d 70 72 6f 63  ply cmd-run-proc
47b0: 2d 65 61 63 68 2d 6c 69 6e 65 20 6c 61 75 6e 63  -each-line launc
47c0: 68 65 72 20 70 72 69 6e 74 20 66 75 6c 6c 63 6d  her print fullcm
47d0: 64 29 29 29 20 3b 3b 20 28 63 6d 64 2d 72 75 6e  d))) ;; (cmd-run
47e0: 2d 3e 6c 69 73 74 20 66 75 6c 6c 63 6d 64 29 29  ->list fullcmd))
47f0: 0a 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
4800: 69 6e 74 20 32 20 22 4c 61 75 6e 63 68 69 6e 67  int 2 "Launching
4810: 20 63 6f 6d 70 6c 65 74 65 64 2c 20 75 70 64 61   completed, upda
4820: 74 69 6e 67 20 64 62 22 29 0a 20 20 20 20 20 20  ting db").      
4830: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
4840: 4c 61 75 6e 63 68 20 72 65 73 75 6c 74 73 3a 20  Launch results: 
4850: 22 20 6c 61 75 6e 63 68 2d 72 65 73 75 6c 74 73  " launch-results
4860: 29 0a 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74  ).      (if (not
4870: 20 6c 61 75 6e 63 68 2d 72 65 73 75 6c 74 73 29   launch-results)
4880: 0a 09 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20  ..  (begin..    
4890: 28 70 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 46  (print "ERROR: F
48a0: 61 69 6c 65 64 20 74 6f 20 72 75 6e 20 22 20 28  ailed to run " (
48b0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
48c0: 73 65 20 66 75 6c 6c 63 6d 64 20 22 20 22 29 20  se fullcmd " ") 
48d0: 22 2c 20 65 78 69 74 69 6e 67 20 6e 6f 77 22 29  ", exiting now")
48e0: 0a 09 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66  ..    (sqlite3:f
48f0: 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a 09 20 20  inalize! db)..  
4900: 20 20 3b 3b 20 67 6f 6f 64 20 6f 6c 65 20 22 65    ;; good ole "e
4910: 78 69 74 22 20 73 65 65 6d 73 20 6e 6f 74 20 74  xit" seems not t
4920: 6f 20 77 6f 72 6b 0a 09 20 20 20 20 3b 3b 20 28  o work..    ;; (
4930: 5f 65 78 69 74 20 39 29 0a 09 20 20 20 20 3b 3b  _exit 9)..    ;;
4940: 20 62 75 74 20 74 68 69 73 20 68 61 63 6b 20 77   but this hack w
4950: 69 6c 6c 20 77 6f 72 6b 21 20 54 68 61 6e 6b 73  ill work! Thanks
4960: 20 67 6f 20 74 6f 20 41 6c 61 6e 20 50 6f 73 74   go to Alan Post
4970: 20 6f 66 20 74 68 65 20 43 68 69 63 6b 65 6e 20   of the Chicken 
4980: 65 6d 61 69 6c 20 6c 69 73 74 0a 09 20 20 20 20  email list..    
4990: 3b 3b 20 4e 42 2f 2f 20 49 73 20 74 68 69 73 20  ;; NB// Is this 
49a0: 73 74 69 6c 6c 20 6e 65 65 64 65 64 3f 20 53 68  still needed? Sh
49b0: 6f 75 6c 64 20 62 65 20 73 61 66 65 20 74 6f 20  ould be safe to 
49c0: 67 6f 20 62 61 63 6b 20 74 6f 20 22 65 78 69 74  go back to "exit
49d0: 22 20 6e 6f 77 3f 0a 09 20 20 20 20 28 70 72 6f  " now?..    (pro
49e0: 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72  cess-signal (cur
49f0: 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29  rent-process-id)
4a00: 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 20   signal/kill).. 
4a10: 20 20 20 29 29 0a 20 20 20 20 20 20 28 61 6c 69     )).      (ali
4a20: 73 74 2d 3e 65 6e 76 2d 76 61 72 73 20 6d 69 73  st->env-vars mis
4a30: 63 70 72 65 76 76 61 6c 73 29 0a 20 20 20 20 20  cprevvals).     
4a40: 20 28 61 6c 69 73 74 2d 3e 65 6e 76 2d 76 61 72   (alist->env-var
4a50: 73 20 74 65 73 74 70 72 65 76 76 61 6c 73 29 0a  s testprevvals).
4a60: 20 20 20 20 20 20 28 61 6c 69 73 74 2d 3e 65 6e        (alist->en
4a70: 76 2d 76 61 72 73 20 63 6f 6d 6d 6f 6e 70 72 65  v-vars commonpre
4a80: 76 76 61 6c 73 29 0a 20 20 20 20 20 20 6c 61 75  vvals).      lau
4a90: 6e 63 68 2d 72 65 73 75 6c 74 73 29 29 29 0a 0a  nch-results)))..