Index: configf.scm ================================================================== --- configf.scm +++ configf.scm @@ -457,10 +457,15 @@ '() (map car sectdat)))) (define (configf:get-section cfgdat section) (hash-table-ref/default cfgdat section '())) + +(define (configf:set-section-var cfgdat section var val) + (let ((sectdat (configf:get-section cfgdat section))) + (append (filter (lambda (x)(not (assoc var sectdat))) sectdat) + (list var val)))) (define (setup) (let* ((configf (find-config "megatest.config")) (config (if configf (read-config configf #f #t) #f))) (if config Index: docs/manual/reference.txt ================================================================== --- docs/manual/reference.txt +++ docs/manual/reference.txt @@ -640,20 +640,27 @@ and setup the sub-Megatest run area. In the testconfig: --------------- [subrun] + +# Required: wait for the run or just launch it +# if no then the run will be an automatic PASS irrespective of the actual result +runwait yes|no # Optional: where to execute the run. Default is the current runarea runarea /some/path/to/megatest/area # Optional: method to use to determine pass/fail status of the run # auto (default) - roll up the net state/status of the sub-run -# ;logpro - use the provided logpro rules, the semicolon is required +# logpro - use the provided logpro rules, happens automatically if there is a logpro section # passfail auto|logpro # Example of logpro: -passfail ;logpro +passfail logpro + +# Optional: +logpro ;; if this section exists then logpro is used to determine pass/fail (expect:required in "LogFileBody" >= 1 "At least one pass" #/PASS/) # Optional: target translator, default is to use the parent target target somescript.sh Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -79,13 +79,20 @@ #f))) (define (launch:runstep ezstep run-id test-id exit-info m tal testconfig) (let* ((stepname (car ezstep)) ;; do stuff to run the step (stepinfo (cadr ezstep)) + ;; (let ((info (cadr ezstep))) + ;; (if (proc? info) "" info))) + ;; (stepproc (let ((info (cadr ezstep))) + ;; (if (proc? info) info #f))) (stepparts (string-match (regexp "^(\\{([^\\}]*)\\}\\s*|)(.*)$") stepinfo)) - (stepparms (list-ref stepparts 2)) ;; for future use, {VAR=1,2,3}, run step for each - (paramparts (string-split + (stepparams (list-ref stepparts 2)) ;; for future use, {VAR=1,2,3}, run step for each + (paramparts (if (list? stepparams) + (map (lambda (x)(string-split x "=")) (string-split-fields "[^;]*=[^;]*" stepparams)) + '())) + (subrun (alist-ref "subrun" paramparts equal?)) (stepcmd (list-ref stepparts 3)) (script "") ; "#!/bin/bash\n") ;; yep, we depend on bin/bash FIXME!!!\ (logpro-file (conc stepname ".logpro")) (html-file (conc stepname ".html")) (dat-file (conc stepname ".dat")) @@ -102,11 +109,11 @@ (print tconfig-logpro))) (set! logpro-used #t))) ;; NB// can safely assume we are in test-area directory (debug:print 4 *default-log-port* "ezsteps:\n stepname: " stepname " stepinfo: " stepinfo " stepparts: " stepparts - " stepparms: " stepparms " stepcmd: " stepcmd) + " stepparams: " stepparams " stepcmd: " stepcmd) ;; ;; first source the previous environment ;; (let ((prev-env (conc ".ezsteps/" prevstep (if (string-search (regexp "csh") ;; (get-environment-variable "SHELL")) ".csh" ".sh")))) ;; (if (and prevstep (common:file-exists? prev-env)) @@ -120,12 +127,17 @@ ;; now launch the actual process (call-with-environment-variables (list (cons "PATH" (conc (get-environment-variable "PATH") ":."))) (lambda () ;; (process-run "/bin/bash" "-c" "exec ls -l /tmp/foobar > /tmp/delme-more.log 2>&1") (let* ((cmd (conc stepcmd " > " stepname ".log 2>&1")) ;; >outfile 2>&1 - (pid (process-run "/bin/bash" (list "-c" cmd)))) - + (pid #f)) + (let ((proc (lambda () + (set! pid (process-run "/bin/bash" (list "-c" cmd)))))) + (if subrun + (common:without-vars proc "^MT_.*") + (proc))) + (with-output-to-file "Makefile.ezsteps" (lambda () (print stepname ".log :") (print "\t" cmd) (if (common:file-exists? (conc stepname ".logpro")) @@ -294,10 +306,58 @@ ;; after all that, still no testconfig? Time to abort (if (not testconfig) (begin (debug:print-error 0 *default-log-port* "Failed to resolve megatest.config, runconfigs.config and testconfig issues. Giving up now") (exit 1))) + + ;; create a proc for the subrun if requested, save that proc in the ezsteps table as the last entry + ;; 1. get section [runarun] + ;; 2. unset MT_* vars + ;; 3. fix target + ;; 4. fix runname + ;; 5. fix testpatt or calculate it from contour + ;; 6. launch the run + ;; 7. roll up the run result and or roll up the logpro processed result + (if (configf:lookup testconfig "subrun" "runwait") ;; we use runwait as the flag that a subrun is requested + (let* ((runarea (configf:lookup testconfig "subrun" "runarea")) + (passfail (configf:lookup testconfig "subrun" "passfail")) + (target (configf:lookup testconfig "subrun" "target")) + (runname (configf:lookup testconfig "subrun" "runname")) + (contour (configf:lookup testconfig "subrun" "contour")) + (testpatt (configf:lookup testconfig "subrun" "testpatt")) + (mode-patt (configf:lookup testconfig "subrun" "mode-patt")) + (tag-expr (configf:lookup testconfig "subrun" "tag-expr")) + (run-wait (configf:lookup testconfig "subrun" "runwait")) + (logpro (configf:lookup testconfig "subrun" "logpro")) + (compact-stem (string-substitute "[/*]" "_" (conc target "-" runname "-" (or testpatt mode-patt tag-expr)))) + (log-file (conc compact-stem ".log")) + (mt-cmd (conc "megatest -run -target " target + " -runname " runname + (if runarea (conc " -start-dir " runarea) *toppath*) + (if testpatt (conc " -testpatt " testpatt) "") + (if mode-patt (conc " -modepatt " mode-patt) "") + (if tag-expr (conc " -tag-expr" tag-expr) "") + (if (equal? runwait "yes") " -runwait " "") + " -log " log-file))) + ;; change directory to runarea, create it if needed, we do NOT create the directory + (if runarea + (if (directory-exists? runarea) + (change-directory runarea) + (begin + (debug:print 0 *default-log-port* "ERROR: for sub-megatest run the runarea \"" runarea "\" does not exist! EXITING.") + (exit 1)))) + ;; (let ((subrun (conc *toppath* "/subrun") #t)) + ;; (create-directory subrun) + ;; (change-directory subrun))) + + ;; by this point we are in the right place to run the subrun and we have a Megatest command to run + ;; (filter (lambda (x)(string-match "MT_.*" (car x))) (get-environment-variables)) + (common:without-vars mt-cmd "^MT_.*") + (set! ezsteps (append ezsteps (list "subrun" (conc "{subrun=true} " mt-cmd)))) + (configf:set-section-var testconfig "logpro" "subrun" logpro) ;; append the logpro rules to the logpro section as stepname subrun + )) + ;; process the ezsteps (if ezsteps (begin (if (not (common:file-exists? ".ezsteps"))(create-directory ".ezsteps")) ;; if ezsteps was defined then we are sure to have at least one step but check anyway @@ -319,46 +379,10 @@ (debug:print 4 *default-log-port* "WARNING: step " (car ezstep) " failed. Stopping"))) (debug:print 4 *default-log-port* "WARNING: a prior step failed, stopping at " ezstep)))))) ;; by this point we are done with runtest and ezsteps. we can now check if there is ;; a request for a sub-megatest run and execute it - ;; 1. get section [runarun] - ;; 2. unset MT_* vars - ;; 3. fix target - ;; 4. fix runname - ;; 5. fix testpatt or calculate it from contour - ;; 6. launch the run - ;; 7. roll up the run result and or roll up the logpro processed result - (let* ((runarea (configf:lookup testconfig "subrun" "runarea")) - (passfail (configf:lookup testconfig "subrun" "passfail")) - (target (configf:lookup testconfig "subrun" "target")) - (runname (configf:lookup testconfig "subrun" "runname")) - (contour (configf:lookup testconfig "subrun" "contour")) - (testpatt (configf:lookup testconfig "subrun" "testpatt")) - (mode-patt (configf:lookup testconfig "subrun" "mode-patt")) - (tag-expr (configf:lookup testconfig "subrun" "tag-expr")) - (compact-stem (string-substitute "[/*]" "_" (conc target "-" runname "-" (or testpatt mode-patt tag-expr)))) - (log-file (conc compact-stem ".log")) - (mt-cmd (conc "megatest -run -target " target - " -runname " runname - (if testpatt (conc " -testpatt " testpatt) "") - (if mode-patt (conc " -modepatt " mode-patt) "") - (if tag-expr (conc " -tag-expr" tag-expr) "") - " -log " log-file))) - ;; change directory to runarea, create it if needed, we do NOT create the directory - (if runarea - (if (directory-exists? runarea) - (change-directory runarea) - (begin - (debug:print 0 *default-log-port* "ERROR: for sub-megatest run the runarea \"" runarea "\" does not exist! EXITING.") - (exit 1))) - (let ((subrun (conc *toppath* "/subrun") #t)) - (create-directory subrun) - (change-directory subrun))) - ;; by this point we are in the right place to run the subrun and we have a Megatest command to run - ;; (filter (lambda (x)(string-match "MT_.*" (car x))) (get-environment-variables)) - (common:without-vars mt-cmd "^MT_.*") ))) (define (launch:monitor-job run-id test-id item-path fullrunscript ezsteps test-name tconfigreg exit-info m work-area runtlim misc-flags) (let* ((update-period (string->number (or (configf:lookup *configdat* "setup" "test-stats-update-period") "30"))) @@ -1065,11 +1089,11 @@ ;; 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))) - ;; trap exception due to stale NFS handle -- Error: (open-output-file) cannot open file - Stale NFS file handle: "/p/fdk/gwa/lefkowit/mtTesting/qa/primbeqa/links/p1222/11/PDK_r1.1.1/prim/clean/pcell_testgen/.runconfigs.cfg-1.6427-7d1e789cb3f62f9cde719a4865bb51b3c17ea853" - ticket 220546342 + ;; trap exception due to stale NFS handle -- Error: (open-output-file) cannot open file - Stale NFS file handle: "...somepath.../.runconfigs.cfg-1.6427-7d1e789cb3f62f9cde719a4865bb51b3c17ea853" - ticket 220546342 ;; TODO - consider 1) using simple-lock to bracket cache write ;; 2) cache in hash on server, since need to do rmt: anyway to lock. (if (and rccachef *runconfigdat* (not (common:file-exists? rccachef))) (common:fail-safe (lambda ()