Index: common_records.scm ================================================================== --- common_records.scm +++ common_records.scm @@ -32,22 +32,37 @@ (define (debug:debug-mode n) (or (and (number? *verbosity*) (<= n *verbosity*)) (and (list? *verbosity*) (member n *verbosity*)))) + +(define (debug:setup) + (let ((debugstr (or (args:get-arg "-debug") + (getenv "MT_DEBUG_MODE")))) + (set! *verbosity* (debug:calc-verbosity debugstr)) + (debug:check-verbosity *verbosity* debugstr) + (if (or (args:get-arg "-debug") + (not (getenv "MT_DEBUG_MODE"))) + (setenv "MT_DEBUG_MODE" (if (list? *verbosity*) + (string-intersperse (map conc *verbosity*) ",") + (conc *verbosity*)))))) + (define (debug:print n . params) (if (debug:debug-mode n) - (begin - (apply print params) - (if *logging* (apply db:log-event params))))) + (with-output-to-port (current-error-port) + (lambda () + (apply print params) + (if *logging* (apply db:log-event params)))))) (define (debug:print-info n . params) (if (debug:debug-mode n) - (let ((res (format#format #f "INFO:~2d ~a" n (apply conc params)))) - (print res) - (if *logging* (db:log-event res))))) + (with-output-to-port (current-error-port) + (lambda () + (let ((res (format#format #f "INFO:~2d ~a" n (apply conc params)))) + (print res) + (if *logging* (db:log-event res))))))) ;; if a value is printable (i.e. string or number) return the value ;; else return an empty string (define-inline (printable val) (if (or (number? val)(string? val)) val "")) Index: dashboard.scm ================================================================== --- dashboard.scm +++ dashboard.scm @@ -114,12 +114,11 @@ (define *db-file-path* (conc *toppath* "/megatest.db")) (define *tests-sort-reverse* #f) (define *hide-empty-runs* #f) -(set! *verbosity* (debug:calc-verbosity (args:get-arg "-debug"))) -(debug:check-verbosity *verbosity* (args:get-arg "-debug")) +(debug:setup) (define uidat #f) (define-inline (dboard:uidat-get-keycol vec)(vector-ref vec 0)) (define-inline (dboard:uidat-get-lftcol vec)(vector-ref vec 1)) Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -244,11 +244,11 @@ 136000)))) (sqlite3:set-busy-handler! db handler) (if (not dbexists) (begin (sqlite3:execute db "PRAGMA synchronous = FULL;") - (debug:print 0 "Initialized test database " dbpath) + (debug:print-info 11 "Initialized test database " dbpath) (db:testdb-initialize db))) ;; (sqlite3:execute db "PRAGMA synchronous = 0;") (debug:print-info 11 "open-test-db END (sucessful)" testpath) db) (begin @@ -318,18 +318,18 @@ (string->number (args:get-arg "-override-timeout")) 136000)))) ;; 136000))) (sqlite3:set-busy-handler! db handler) (if (not dbexists) (begin - (sqlite3:execute db "CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY,event_time TIMESTAMP DEFAULT (strftime('%s','now')),logline TEXT);") + (sqlite3:execute db "CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY,event_time TIMESTAMP DEFAULT (strftime('%s','now')),logline TEXT,pwd TEXT,cmdline TEXT,pid INTEGER);") (sqlite3:execute db (conc "PRAGMA synchronous = 0;")))) db)) (define (db:log-event . loglst) (let ((db (open-logging-db)) (logline (apply conc loglst))) - (sqlite3:execute db "INSERT INTO log (logline) VALUES (?);" logline) + (sqlite3:execute db "INSERT INTO log (logline,pwd,cmdline,pid) VALUES (?,?,?,?);" logline (current-directory)(string-intersperse (argv) " ")(current-process-id)) (sqlite3:finalize! db) logline)) ;;====================================================================== ;; TODO: @@ -1394,11 +1394,11 @@ ;; Now rollup the counts to the central megatest.db (rdb:pass-fail-counts test-id fail-count pass-count) ;; (sqlite3:execute db "UPDATE tests SET fail_count=?,pass_count=? WHERE id=?;" ;; fail-count pass-count test-id) - (thread-sleep! 10) ;; play nice with the queue by ensuring the rollup is at least 10s later than the set + (thread-sleep! 1) ;; play nice with the queue by ensuring the rollup is at least 10ms later than the set ;; if the test is not FAIL then set status based on the fail and pass counts. (rdb:test-rollup-test_data-pass-fail test-id) ;; (sqlite3:execute ;; db ;;; NOTE: Should this be WARN,FAIL? A WARN is not a FAIL????? BUG FIXME Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -212,12 +212,11 @@ ;;====================================================================== ;; Misc setup stuff ;;====================================================================== -(set! *verbosity* (debug:calc-verbosity (args:get-arg "-debug"))) -(debug:check-verbosity *verbosity* (args:get-arg "-debug")) +(debug:setup) (if (args:get-arg "-logging")(set! *logging* #t)) (if (debug:debug-mode 3) ;; we are obviously debugging (set! open-run-close open-run-close-no-exception-handling)) Index: server.scm ================================================================== --- server.scm +++ server.scm @@ -80,42 +80,42 @@ ;;====================================================================== ;; remote call to open-run-close (rpc:publish-procedure! 'rdb:open-run-close (lambda (procname . remargs) - (debug:print-info 4 "Remote call of rdb:open-run-close " procname " " remargs) + (debug:print-info 12 "Remote call of rdb:open-run-close " procname " " remargs) (set! *last-db-access* (current-seconds)) (apply open-run-close (eval procname) remargs))) (rpc:publish-procedure! 'cdb:test-set-status-state (lambda (test-id status state msg) - (debug:print-info 4 "Remote call of cdb:test-set-status-state test-id=" test-id ", status=" status ", state=" state ", msg=" msg) + (debug:print-info 12 "Remote call of cdb:test-set-status-state test-id=" test-id ", status=" status ", state=" state ", msg=" msg) (cdb:test-set-status-state test-id status state msg))) (rpc:publish-procedure! 'cdb:test-rollup-test_data-pass-fail (lambda (test-id) - (debug:print-info 4 "Remote call of cdb:test-rollup-test_data-pass-fail " test-id) + (debug:print-info 12 "Remote call of cdb:test-rollup-test_data-pass-fail " test-id) (cdb:test-rollup-test_data-pass-fail test-id))) (rpc:publish-procedure! 'cdb:pass-fail-counts (lambda (test-id fail-count pass-count) - (debug:print-info 4 "Remote call of cdb:pass-fail-counts " test-id " passes: " pass-count " fails: " fail-count) + (debug:print-info 12 "Remote call of cdb:pass-fail-counts " test-id " passes: " pass-count " fails: " fail-count) (cdb:pass-fail-counts test-id fail-count pass-count))) (rpc:publish-procedure! 'cdb:tests-register-test (lambda (db run-id test-name item-path) - (debug:print-info 4 "Remote call of cdb:tests-register-test " run-id " testname: " test-name " item-path: " item-path) + (debug:print-info 12 "Remote call of cdb:tests-register-test " run-id " testname: " test-name " item-path: " item-path) (cdb:tests-register-test db run-id test-name item-path))) (rpc:publish-procedure! 'cdb:flush-queue (lambda () - (debug:print-info 4 "Remote call of cdb:flush-queue") + (debug:print-info 12 "Remote call of cdb:flush-queue") (cdb:flush-queue))) ;;====================================================================== ;; end of publish-procedure section ;;====================================================================== Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -38,11 +38,11 @@ test3 : fullprep cd fullrun;$(MEGATEST) -runtests runfirst -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_b $(SERVER) -debug 10 test4 : fullprep - cd fullrun;$(MEGATEST) $(SERVER) $(LOGGING)& + cd fullrun;$(MEGATEST) $(SERVER) $(LOGGING) -debug $(DEBUG) & cd fullrun;sleep 5;$(MEGATEST) -debug $(DEBUG) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_b -m "This is a comment specific to a run" -v $(LOGGING) # NOTE: Only one instance can be a server test5 : fullprep cd fullrun;$(MEGATEST) $(SERVER) $(LOGGING) &