Index: commonmod.scm ================================================================== --- commonmod.scm +++ commonmod.scm @@ -574,12 +574,24 @@ (debug:print-error 0 *default-log-port* "bad value for setenv, key=" key ", value=" val)))) (define home (getenv "HOME")) (define user (getenv "USER")) - -;; returns list of fd count, socket count +;; put any changed environment variables back to how they were - TODO - turn this into some sort of with- +(define (common:set-vars-back all-vars) + (for-each + (lambda (vardat) + (let ((var (car vardat)) + (val (cdr vardat))) + (if (not (equal? (get-environment-variable var) val)) + (handle-exceptions + exn + (debug:print-error 0 *default-log-port* "Failed to set " var " to " val) + (setenv var val))))) + all-vars)) + + ;; returns list of fd count, socket count (define (get-file-descriptor-count #!key (pid (current-process-id ))) (list (length (glob (conc "/proc/" pid "/fd/*"))) (length (filter identity (map socket? (glob (conc "/proc/" pid "/fd/*"))))) ) Index: runs-inc.scm ================================================================== --- runs-inc.scm +++ runs-inc.scm @@ -1715,11 +1715,12 @@ (let* ((test-name (tests:testqueue-get-testname test-record)) (test-waitons (tests:testqueue-get-waitons test-record)) (itemdat (tests:testqueue-get-itemdat test-record)) (item-path "") (db #f) - (full-test-name #f)) + (full-test-name #f) + (all-vars (get-environment-variables))) ;; setting itemdat to a list if it is #f (if (not itemdat)(set! itemdat '())) (set! item-path (item-list->path itemdat)) (set! full-test-name (db:test-make-full-name test-name item-path)) (runs:set-megatest-env-vars run-id inrunname: runname testname: test-name itempath: item-path) ;; these may be needed by the launching process @@ -1861,11 +1862,11 @@ (if (not (null? existing)) ;; (common:file-exists? (configf:lookup test-conf "skip" "fileexists")) (set! skip-test (conc "Skipping due to existance of file(s) " (string-intersperse existing ", ")))))) ;; (configf:lookup test-conf "skip" "fileexists"))))) ((and skip-check (configf:lookup test-conf "skip" "filenotexists")) - (let* ((files (string-split (configf:lookup test-conf "skip" "fileexists"))) + (let* ((files (string-split (configf:lookup test-conf "skip" "filenotexists"))) (existing (filter common:file-exists? files))) (if (null? existing) ;; (common:file-exists? (configf:lookup test-conf "skip" "filenotexists"))) (set! skip-test (conc "Skipping due to non existance of files " (string-intersperse files ", ")))))) ;; (configf:lookup test-conf "skip" "filenotexists"))))) ((and skip-check @@ -1915,11 +1916,24 @@ (debug:print-error 0 *default-log-port* "Failed to launch test " full-test-name ". Unrecognised state " (test:get-state testdat)) (case (string->symbol (test:get-state testdat)) ((COMPLETED INCOMPLETE) (hash-table-set! test-registry (db:test-make-full-name test-name test-path) 'DONOTRUN)) (else - (hash-table-set! test-registry (db:test-make-full-name test-name test-path) 'DONOTRUN))))))))) + (hash-table-set! test-registry (db:test-make-full-name test-name test-path) 'DONOTRUN))))))) + ;; put any changed environment variables back to how they were - TODO - turn this into some sort of with- + (common:set-vars-back all-vars) + #;(for-each + (lambda (vardat) + (let ((var (car vardat)) + (val (cdr vardat))) + (if (not (equal? (get-environment-variable var) val)) + (handle-exceptions + exn + (debug:print-error 0 *default-log-port* "Failed to set " var " to " val) + (setenv var val))))) + all-vars) + )) ;;====================================================================== ;; END OF NEW STUFF ;;======================================================================