@@ -795,19 +795,19 @@ ;; side effects: ;; sets; *configdat* (megatest.config info) ;; *runconfigdat* (runconfigs.config info) ;; *configstatus* (status of the read data) ;; -(define (launch:setup #!key (force-reread #f) (areapath #f)) +(define (launch:setup #!key (force-reread #f) (areapath #f)(exit-if-non-megatest-area #t)) (mutex-lock! *launch-setup-mutex*) (if (and *toppath* (eq? *configstatus* 'fulldata) (not force-reread)) ;; got it all (begin (debug:print 2 *default-log-port* "NOTE: skipping launch:setup-body call since we have fulldata") (mutex-unlock! *launch-setup-mutex*) *toppath*) - (let ((res (launch:setup-body force-reread: force-reread areapath: areapath))) + (let ((res (launch:setup-body force-reread: force-reread areapath: areapath exit-if-non-megatest-area: exit-if-non-megatest-area))) (mutex-unlock! *launch-setup-mutex*) res))) ;; return paths depending on what info is available. ;; @@ -834,11 +834,11 @@ "\n cachedir=" cachedir "\n mtcachef=" mtcachef "\n rccachef=" rccachef) (cons mtcachef rccachef))) -(define (launch:setup-body #!key (force-reread #f) (areapath #f)) +(define (launch:setup-body #!key (force-reread #f) (areapath #f)(exit-if-non-megatest-area #t)) (if (and (eq? *configstatus* 'fulldata) *toppath* (not force-reread)) ;; no need to reprocess *toppath* ;; return toppath (let* ((use-cache (common:use-cache?)) ;; BB- use-cache checks *configdat* for use-cache setting. We do not have *configdat*. Bootstrapping problem here. @@ -859,12 +859,11 @@ (set! *configdat* (configf:read-alist mtcachef)) ;;(BB> "launch:setup-body -- 1 set! *configdat*="*configdat*) (set! *runconfigdat* (configf:read-alist rccachef)) (set! *configinfo* (list *configdat* (get-environment-variable "MT_RUN_AREA_HOME"))) (set! *configstatus* 'fulldata) - (set! *toppath* (get-environment-variable "MT_RUN_AREA_HOME")) - *toppath*) + (set! *toppath* (get-environment-variable "MT_RUN_AREA_HOME"))) ;; NOTE: the cond does NOT return the final result ;; we have all the info needed to fully process runconfigs and megatest.config ((and (not force-reread) mtcachef) ;; BB- why are we doing this without asking if caching is desired? ;;(BB> "launch:setup-body -- cond branch 2") (let* ((first-pass (find-and-read-config ;; NB// sets MT_RUN_AREA_HOME as side effect mtconfig @@ -919,14 +918,13 @@ (if rccachef (configf:write-alist runconfigdat rccachef)) (set! *runconfigdat* runconfigdat) (if mtcachef (configf:write-alist *configdat* mtcachef)) (if (and rccachef mtcachef) (set! *configstatus* 'fulldata)))) ;; no configs found? should not happen but let's try to recover gracefully, return an empty hash-table - (begin (set! *configdat* (make-hash-table)) - ;;(BB> "launch:setup-body -- 3 set! *configdat*="*configdat*) - ) - ))) + (if exit-if-non-megatest-area ;; second pass, exit or set configdat to dummy hashtable + (exit 1) + (set! *configdat* (make-hash-table)))))) ;; else read what you can and set the flag accordingly (else ;;(BB> "launch:setup-body -- cond branch 3 - else") (let* ((cfgdat (find-and-read-config (or (args:get-arg "-config") "megatest.config") @@ -976,12 +974,13 @@ (setenv "MT_TESTSUITENAME" (common:get-testsuite-name))) (begin (debug:print-error 0 *default-log-port* "failed to find the top path to your Megatest area.") ;;(exit 1) (set! *toppath* #f) ;; force it to be false so we return #f - #f - )) + (if exit-if-non-megatest-area + (exit 1) + #f))) ;; one more attempt to cache the configs for future reading (let* ((cachefiles (launch:get-cache-file-paths areapath toppath target mtconfig)) (mtcachef (car cachefiles)) (rccachef (cdr cachefiles))) (if (and rccachef *runconfigdat*) (configf:write-alist *runconfigdat* rccachef)) @@ -992,10 +991,15 @@ ;; if have -append-config then read and append here (let ((cfname (args:get-arg "-append-config"))) (if (and cfname (file-read-access? cfname)) (read-config cfname *configdat* #t))) ;; values are added to the hash, no need to do anything special. + (if (and (not *toppath*) + exit-if-non-megatest-area) + (begin + (debug:print-error 0 *default-log-port* "failed to find the top path to your Megatest area.") + (exit 1))) *toppath*))) (define (get-best-disk confdat testconfig) (let* ((disks (or (and testconfig (hash-table-ref/default testconfig "disks" #f)) (hash-table-ref/default confdat "disks" #f)))