Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -1,9 +1,9 @@ PREFIX=. CSCOPTS= - +INSTALL=install SRCFILES = common.scm items.scm launch.scm \ ods.scm runconfig.scm server.scm configf.scm \ db.scm keys.scm margs.scm megatest-version.scm \ process.scm runs.scm tasks.scm tests.scm @@ -34,27 +34,27 @@ %.o : %.scm csc $(CSCOPTS) -c $< $(PREFIX)/bin/megatest : megatest @echo Installing to PREFIX=$(PREFIX) - cp megatest $(PREFIX)/bin/megatest + $(INSTALL) megatest $(PREFIX)/bin/megatest $(HELPERS) : utils/mt_* - cp $< $@ + $(INSTALL) $< $@ chmod a+x $@ $(PREFIX)/bin/nbfake : utils/nbfake - cp $< $@ + $(INSTALL) $< $@ chmod a+x $@ $(PREFIX)/bin/nbfind : utils/nbfind - cp $< $@ + $(INSTALL) $< $@ chmod a+x $@ # install dashboard as dboard so wrapper script can be called dashboard $(PREFIX)/bin/dboard : dboard $(FILES) - cp dboard $(PREFIX)/bin/dboard + $(INSTALL) dboard $(PREFIX)/bin/dboard utils/mk_dashboard_wrapper $(PREFIX) > $(PREFIX)/bin/dashboard chmod a+x $(PREFIX)/bin/dashboard install : bin $(PREFIX)/bin/megatest $(PREFIX)/bin/dboard $(PREFIX)/bin/dashboard $(HELPERS) $(PREFIX)/bin/nbfake $(PREFIX)/bin/nbfind Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -32,18 +32,19 @@ ;; global gletches (define *configinfo* #f) (define *configdat* #f) (define *toppath* #f) (define *already-seen-runconfig-info* #f) -(define *waiting-queue* (make-hash-table)) +(define *waiting-queue* (make-hash-table)) (define *test-meta-updated* (make-hash-table)) -(define *globalexitstatus* 0) ;; attempt to work around possible thread issues -(define *passnum* 0) ;; when running track calls to run-tests or similar -(define *verbosity* 1) -(define *rpc:listener* #f) ;; if set up for server communication this will hold the tcp port -(define *runremote* #f) ;; if set up for server communication this will hold -(define *last-db-access* 0) ;; update when db is accessed via server +(define *globalexitstatus* 0) ;; attempt to work around possible thread issues +(define *passnum* 0) ;; when running track calls to run-tests or similar +(define *verbosity* 1) +(define *rpc:listener* #f) ;; if set up for server communication this will hold the tcp port +(define *runremote* #f) ;; if set up for server communication this will hold +(define *last-db-access* 0) ;; update when db is accessed via server +(define *target* #f) ;; cache the target here; target is keyval1/keyval2/.../keyvalN (define (get-with-default val default) (let ((val (args:get-arg val))) (if val val default))) Index: configf.scm ================================================================== --- configf.scm +++ configf.scm @@ -116,18 +116,20 @@ ;; read a config file, returns hash table of alists ;; adds to ht if given (must be #f otherwise) ;; envion-patt is a regex spec that identifies sections that will be eval'd ;; in the environment on the fly -(define (read-config path ht allow-system #!key (environ-patt #f)) - (debug:print 4 "INFO: read-config " path " allow-system " allow-system " environ-patt " environ-patt) +(define (read-config path ht allow-system #!key (environ-patt #f)(curr-section #f)) + (debug:print 4 "INFO: read-config " path " allow-system " allow-system " environ-patt " environ-patt " curr-section: " curr-section) (if (not (file-exists? path)) - (if (not ht)(make-hash-table) ht) + (begin + (debug:print 4 "INFO: read-config - file not found " path " current path: " (current-directory)) + (if (not ht)(make-hash-table) ht)) (let ((inp (open-input-file path)) (res (if (not ht)(make-hash-table) ht))) (let loop ((inl (configf:read-line inp res)) ;; (read-line inp)) - (curr-section-name "default") + (curr-section-name (if curr-section curr-section "default")) (var-flag #f);; turn on for key-var-pr and cont-ln-rx, turn off elsewhere (lead #f)) (if (eof-object? inl) (begin (close-input-port inp) @@ -134,13 +136,15 @@ res) (regex-case inl (configf:comment-rx _ (loop (configf:read-line inp res) curr-section-name #f #f)) (configf:blank-l-rx _ (loop (configf:read-line inp res) curr-section-name #f #f)) - (configf:include-rx ( x include-file ) (begin - (read-config include-file res allow-system environ-patt: environ-patt) - (loop (configf:read-line inp res) curr-section-name #f #f))) + (configf:include-rx ( x include-file ) (let ((curr-dir (current-directory))) + (change-directory (pathname-directory path)) + (read-config include-file res allow-system environ-patt: environ-patt curr-section: curr-section-name) + (change-directory curr-dir) + (loop (configf:read-line inp res) curr-section-name #f #f))) (configf:section-rx ( x section-name ) (loop (configf:read-line inp res) section-name #f #f)) (configf:key-sys-pr ( x key cmd ) (if allow-system (let ((alist (hash-table-ref/default res curr-section-name '())) (val-proc (lambda () (let* ((cmdres (cmd-run->list cmd)) @@ -161,21 +165,22 @@ ((return-string) cmd) (else (val-proc))))) (loop (configf:read-line inp res) curr-section-name #f #f)) (loop (configf:read-line inp res) curr-section-name #f #f))) (configf:key-val-pr ( x key val ) (let* ((alist (hash-table-ref/default res curr-section-name '())) - (envar (and environ-patt (string-match (regexp environ-patt) curr-section-name))) - (realval (if envar - (config:eval-string-in-environment val) - val))) - (if envar - (begin - (debug:print 4 "INFO: read-config key=" key ", val=" val ", realval=" realval) - (setenv key realval))) - (hash-table-set! res curr-section-name - (config:assoc-safe-add alist key realval)) - (loop (configf:read-line inp res) curr-section-name key #f))) + (envar (and environ-patt (string-search (regexp environ-patt) curr-section-name))) + (realval (if envar + (config:eval-string-in-environment val) + val))) + (debug:print 6 "INFO: read-config env setting, envar: " envar " realval: " realval " val: " val " key: " key " curr-section-name: " curr-section-name) + (if envar + (begin + ;; (debug:print 4 "INFO: read-config key=" key ", val=" val ", realval=" realval) + (setenv key realval))) + (hash-table-set! res curr-section-name + (config:assoc-safe-add alist key realval)) + (loop (configf:read-line inp res) curr-section-name key #f))) ;; if a continued line (configf:cont-ln-rx ( x whsp val ) (let ((alist (hash-table-ref/default res curr-section-name '()))) (if var-flag ;; if set to a string then we have a continued var (let ((newval (conc (config-lookup res curr-section-name var-flag) "\n" Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -407,10 +407,19 @@ (lambda (key-val) (set! res (cons key-val res))) db qry run-id))) keys) (reverse res))) + +;; The target is keyval1/keyval2..., cached in *target* as it is used often +(define (db:get-target db run-id) + (if *target* + *target* + (let* ((keyvals (rdb:get-key-vals db run-id)) + (thekey (string-intersperse (map (lambda (x)(if x x "-na-")) keyvals) "/"))) + (set! *target* thekey) + thekey))) ;;====================================================================== ;; T E S T S ;;====================================================================== Index: runconfig.scm ================================================================== --- runconfig.scm +++ runconfig.scm @@ -7,18 +7,23 @@ (declare (unit runconfig)) (declare (uses common)) (include "common_records.scm") + + (define (setup-env-defaults db fname run-id already-seen #!key (environ-patt #f)) (let* ((keys (rdb:get-keys db)) (keyvals (rdb:get-key-vals db run-id)) (thekey (string-intersperse (map (lambda (x)(if x x "-na-")) keyvals) "/")) - (confdat (read-config fname #f #f environ-patt: environ-patt)) + ;; Why was system disallowed in the reading of the runconfigs file? + ;; NOTE: Should be setting env vars based on (target|default) + (confdat (read-config fname #f #t environ-patt: environ-patt)) (whatfound (make-hash-table)) (sections (list "default" thekey))) + (if (not *target*)(set! *target* thekey)) ;; may save a db access or two but repeats db:get-target code (debug:print 4 "Using key=\"" thekey "\"") (for-each (lambda (key val) (setenv (vector-ref key 0) val)) @@ -42,10 +47,16 @@ sections) (debug:print 2 "---") (set! *already-seen-runconfig-info* #t))))) (define (set-run-config-vars db run-id) - (let ((runconfigf (conc *toppath* "/runconfigs.config"))) + (let ((runconfigf (conc *toppath* "/runconfigs.config")) + (targ (or (args:get-arg "-target") + (args:get-arg "-reqtarg") + (db:get-target db run-id)))) (if (file-exists? runconfigf) - (setup-env-defaults db runconfigf run-id #f environ-patt: ".*") + (setup-env-defaults db runconfigf run-id #t environ-patt: (conc "(default" + (if targ + (conc "|" targ ")") + ")"))) (debug:print 0 "WARNING: You do not have a run config file: " runconfigf)))) Index: tests/runconfigs.config ================================================================== --- tests/runconfigs.config +++ tests/runconfigs.config @@ -1,14 +1,10 @@ [include common_runconfigs.config] -# Can do: -# get section var -# scheme expr -# shell cmd -# system cmd -# getenv var -# runconfigs-get var WACKYVAR0 #{get ubuntu/nfs/none CURRENT} + WACKYVAR1 #{scheme (args:get-arg "-target")} + +[default/ubuntu/nfs] WACKYVAR2 #{runconfigs-get CURRENT} ADDED tests/tests/test_mt_vars/bogousnotset.sh Index: tests/tests/test_mt_vars/bogousnotset.sh ================================================================== --- /dev/null +++ tests/tests/test_mt_vars/bogousnotset.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +! grep BOGOUS megatest.sh ADDED tests/tests/test_mt_vars/currentisblah.sh Index: tests/tests/test_mt_vars/currentisblah.sh ================================================================== --- /dev/null +++ tests/tests/test_mt_vars/currentisblah.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +grep CURRENT megatest.sh | grep /tmp/nada Index: tests/tests/test_mt_vars/testconfig ================================================================== --- tests/tests/test_mt_vars/testconfig +++ tests/tests/test_mt_vars/testconfig @@ -1,10 +1,15 @@ [setup] [ezsteps] lookittmp ls /tmp lookithome ls /home +# $CURRENT should be /tmp/nada +currentisblah currentisblah.sh + +# $BOGOUS should NOT be set +bogousnotset bogousnotset.sh [requirements] waiton runfirst priority 0