14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
;;======================================================================
(define (setup-for-run)
(set! *configinfo* (find-and-read-config (if (args:get-arg "-config")(args:get-arg "-config") "megatest.config")))
(set! *configdat* (if (car *configinfo*)(car *configinfo*) #f))
(set! *toppath* (if (car *configinfo*)(cadr *configinfo*) #f))
(if *toppath*
(setenv "MT_RUN_AREA_HOME" *toppath*)
(print "ERROR: failed to find the top path to your run setup."))
*toppath*)
(define (setup-env-defaults db fname run-id . already-seen)
(let* ((keys (get-keys db))
(keyvals (get-key-vals db run-id))
(thekey (string-intersperse (map (lambda (x)(if x x "-na-")) keyvals) "/"))
|
|
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
;;======================================================================
(define (setup-for-run)
(set! *configinfo* (find-and-read-config (if (args:get-arg "-config")(args:get-arg "-config") "megatest.config")))
(set! *configdat* (if (car *configinfo*)(car *configinfo*) #f))
(set! *toppath* (if (car *configinfo*)(cadr *configinfo*) #f))
(if *toppath*
(setenv "MT_RUN_AREA_HOME" *toppath*) ;; to be deprecated
(print "ERROR: failed to find the top path to your run setup."))
*toppath*)
(define (setup-env-defaults db fname run-id . already-seen)
(let* ((keys (get-keys db))
(keyvals (get-key-vals db run-id))
(thekey (string-intersperse (map (lambda (x)(if x x "-na-")) keyvals) "/"))
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
(hosts (config-lookup *configdat* "jobtools" "workhosts"))
(remote-megatest (config-lookup *configdat* "setup" "executable"))
(local-megatest (car (argv)))
;; (item-path (item-list->path itemdat)) test-path is the full path including the item-path
(work-area #f)
(diskpath #f)
(cmdparms #f)
(fullcmd #f));; (define a (with-output-to-string (lambda ()(write x))))
(if hosts (set! hosts (string-split hosts)))
(if (not remote-megatest)(set! remote-megatest "megatest"))
(if launcher (set! launcher (string-split launcher)))
;; set up the run work area for this test
(set! diskpath (get-best-disk *configdat*))
(if diskpath
(set! work-area (create-work-area db run-id test-path diskpath test-name itemdat))
(begin
(set! work-area test-path)
(print "WARNING: No disk work area specified - running in the test directory")))
(set! cmdparms (base64:base64-encode (with-output-to-string
(lambda () ;; (list 'hosts hosts)
(write (list (list 'testpath test-path)
(list 'work-area work-area)
(list 'test-name test-name)
(list 'runscript runscript)
(list 'run-id run-id )
(list 'itemdat itemdat))))))) ;; (string-intersperse keyvallst " "))))
(change-directory work-area) ;; so that log files from the launch process don't clutter the test dir
(cond
((and launcher hosts) ;; must be using ssh hostname
(set! fullcmd (append launcher (car hosts)(list remote-megatest "-execute" cmdparms))))
(launcher
(set! fullcmd (append launcher (list remote-megatest "-execute" cmdparms))))
(else
(set! fullcmd (list remote-megatest "-execute" cmdparms))))
(if (args:get-arg "-xterm")(set! fullcmd (append fullcmd (list "-xterm"))))
(print "Launching megatest for test " test-name " in " work-area" ...")
(test-set-status! db run-id test-name "LAUNCHED" "n/a" itemdat) ;; (if launch-results launch-results "FAILED"))
;; set "pre-launch-env-vars
(let* ((prevvals (alist->env-vars
(hash-table-ref/default test-conf "pre-launch-env-overrides" '())))
(launch-results (apply cmd-run-proc-each-line
(car fullcmd)
print
(cdr fullcmd)))) ;; launcher fullcmd)));; (apply cmd-run-proc-each-line launcher print fullcmd))) ;; (cmd-run->list fullcmd))
(print "Launching completed, updating db")
(alist->env-vars prevvals))))
|
|
>
|
>
|
>
|
>
>
>
|
|
>
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
(hosts (config-lookup *configdat* "jobtools" "workhosts"))
(remote-megatest (config-lookup *configdat* "setup" "executable"))
(local-megatest (car (argv)))
;; (item-path (item-list->path itemdat)) test-path is the full path including the item-path
(work-area #f)
(diskpath #f)
(cmdparms #f)
(fullcmd #f) ;; (define a (with-output-to-string (lambda ()(write x))))
(mt-bindir-path #f))
(if hosts (set! hosts (string-split hosts)))
(if (not remote-megatest)(set! remote-megatest local-megatest)) ;; "megatest"))
(set! mt-bindir-path (pathname-directory remote-megatest))
(if launcher (set! launcher (string-split launcher)))
;; set up the run work area for this test
(set! diskpath (get-best-disk *configdat*))
(if diskpath
(set! work-area (create-work-area db run-id test-path diskpath test-name itemdat))
(begin
(set! work-area test-path)
(print "WARNING: No disk work area specified - running in the test directory")))
(set! cmdparms (base64:base64-encode (with-output-to-string
(lambda () ;; (list 'hosts hosts)
(write (list (list 'testpath test-path)
(list 'work-area work-area)
(list 'test-name test-name)
(list 'runscript runscript)
(list 'run-id run-id )
(list 'itemdat itemdat)
(list 'mt-bindir-path mt-bindir-path))))))) ;; (string-intersperse keyvallst " "))))
(change-directory work-area) ;; so that log files from the launch process don't clutter the test dir
(cond
((and launcher hosts) ;; must be using ssh hostname
(set! fullcmd (append launcher (car hosts)(list remote-megatest "-execute" cmdparms))))
(launcher
(set! fullcmd (append launcher (list remote-megatest "-execute" cmdparms))))
(else
(set! fullcmd (list remote-megatest "-execute" cmdparms))))
(if (args:get-arg "-xterm")(set! fullcmd (append fullcmd (list "-xterm"))))
(print "Launching megatest for test " test-name " in " work-area" ...")
(test-set-status! db run-id test-name "LAUNCHED" "n/a" itemdat) ;; (if launch-results launch-results "FAILED"))
;; set
;; set pre-launch-env-vars before launching, keep the vars in prevvals and put the envionment back when done
(let* ((commonprevvals (alist->env-vars
(hash-table-ref/default *configdat* "env-override" '())))
(testprevvals (alist->env-vars
(hash-table-ref/default test-conf "pre-launch-env-overrides" '())))
(launch-results (apply cmd-run-proc-each-line
(car fullcmd)
print
(cdr fullcmd)))) ;; launcher fullcmd)));; (apply cmd-run-proc-each-line launcher print fullcmd))) ;; (cmd-run->list fullcmd))
(print "Launching completed, updating db")
(alist->env-vars testprevvals)
(alist->env-vars commonprevvals))))
|