Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -37,11 +37,11 @@ (define *already-seen-runconfig-info* #f) (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* (current-seconds)) ;; update when db is accessed via server (define *max-cache-size* 0) (define *target* (make-hash-table)) ;; cache the target here; target is keyval1/keyval2/.../keyvalN @@ -52,10 +52,14 @@ (define *test-ids* (make-hash-table)) ;; cache run-id, testname, and item-path => test-id (define *test-info* (make-hash-table)) ;; cache the test info records, update the state, status, run_duration etc. from testdat.db (define *run-info-cache* (make-hash-table)) ;; run info is stable, no need to reget +;; Debugging stuff +(define *verbosity* 1) +(define *logging* #f) + (define (get-with-default val default) (let ((val (args:get-arg val))) (if val val default))) (define (assoc/default key lst . default) Index: common_records.scm ================================================================== --- common_records.scm +++ common_records.scm @@ -8,12 +8,15 @@ ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;;====================================================================== (define-inline (debug:print n . params) - (if (<= n *verbosity*) - (apply print params))) + (begin + (if (<= n *verbosity*) + (apply print params)) + (if *logging* + (apply db:log-event params)))) ;; 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: db.scm ================================================================== --- db.scm +++ db.scm @@ -218,10 +218,14 @@ CONSTRAINT test_data_constraint UNIQUE (test_id,category,variable));") ;; Must do this *after* running patch db !! No more. (db:set-var db "MEGATEST_VERSION" megatest-version) )) +;;====================================================================== +;; T E S T S P E C I F I C D B +;;====================================================================== + ;; Create the sqlite db for the individual test(s) (define (open-test-db testpath) (if (and (directory? testpath) (file-read-access? testpath)) (let* ((dbpath (conc testpath "/testdat.db")) @@ -287,10 +291,35 @@ id INTEGER PRIMARY KEY, var TEXT, val TEXT, ackstate INTEGER DEFAULT 0, CONSTRAINT metadat_constraint UNIQUE (var));"))) + +;;====================================================================== +;; L O G G I N G D B +;;====================================================================== + +(define (open-logging-db) ;; (conc *toppath* "/megatest.db") (car *configinfo*))) + (let* ((dbpath (conc (if *toppath* (conc *toppath* "/") "") "logging.db")) ;; fname) + (dbexists (file-exists? dbpath)) + (db (sqlite3:open-database dbpath)) ;; (never-give-up-open-db dbpath)) + (handler (make-busy-timeout (if (args:get-arg "-override-timeout") + (string->number (args:get-arg "-override-timeout")) + 36000)))) ;; 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 (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:finalize! db) + logline)) ;;====================================================================== ;; TODO: ;; put deltas into an assoc list with version numbers ;; apply all from last to current Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -605,15 +605,15 @@ (list "MT_ITEM_INFO" (conc itemdat)) (list "MT_RUNNAME" runname) (list "MT_TARGET" mt_target) ) itemdat))) - (launch-results (apply cmd-run-proc-each-line + (launch-results (apply cmd-run-with-stderr->list ;; cmd-run-proc-each-line (if useshell (string-intersperse fullcmd " ") (car fullcmd)) - print + ;; conc (if useshell '() (cdr fullcmd))))) ;; launcher fullcmd)));; (apply cmd-run-proc-each-line launcher print fullcmd))) ;; (cmd-run->list fullcmd)) (with-output-to-file "mt_launch.log" (lambda () Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -96,10 +96,12 @@ -setvars VAR1=val1,VAR2=val2 : Add environment variables to a run NB// these are overwritten by values set in config files. -server -|hostname : start the server (reduces contention on megatest.db), use - to automatically figure out hostname -repl : start a repl (useful for extending megatest) + -debug N : increase verbosity to N. (try 10 for lots of noise) + -logging : turn on logging all debug output to logging.db Spreadsheet generation -extract-ods fname.ods : extract an open document spreadsheet from the database -pathmod path : insert path, i.e. path/runame/itempath/logfile.html will clear the field if no rundir/testname/itempath/logfile @@ -190,10 +192,11 @@ "-update-meta" "-gen-megatest-area" "-v" ;; verbose 2, more than normal (normal is 1) "-q" ;; quiet 0, errors/warnings only + "-logging" ) args:arg-hash 0)) (if (args:get-arg "-h") @@ -215,10 +218,12 @@ (if (not (number? *verbosity*)) (begin (print "ERROR: Invalid debug value " (args:get-arg "-debug")) (exit))) + +(if (args:get-arg "-logging")(set! *logging* #t)) ;;====================================================================== ;; Misc general calls ;;====================================================================== Index: process.scm ================================================================== --- process.scm +++ process.scm @@ -13,10 +13,41 @@ ;; Process convience utils ;;====================================================================== (declare (unit process)) (declare (uses common)) + +(define (conservative-read port) + (let loop ((res "")) + (if (not (eof-object? (peek-char port))) + (loop (conc res (read-char port))) + res))) + +(define (cmd-run-with-stderr->list cmd . params) + ;; (print "Called with cmd=" cmd ", proc=" proc ", params=" params) +;; (handle-exceptions +;; exn +;; (begin +;; (print "ERROR: Failed to run command: " cmd " " (string-intersperse params " ")) +;; (print " " ((condition-property-accessor 'exn 'message) exn)) +;; #f) + (let-values (((fh fho pid fhe) (if (null? params) + (process* cmd) + (process* cmd params)))) + (let loop ((curr (read-line fh)) + (result '())) + (let ((errstr (conservative-read fhe))) + (if (not (string=? errstr "")) + (set! result (append result (list errstr))))) + (if (not (eof-object? curr)) + (loop (read-line fh) + (append result (list curr))) + (begin + (close-input-port fh) + (close-input-port fhe) + (close-output-port fho) + result))))) ;; ) (define (cmd-run-proc-each-line cmd proc . params) ;; (print "Called with cmd=" cmd ", proc=" proc ", params=" params) (handle-exceptions exn @@ -24,17 +55,18 @@ (print "ERROR: Failed to run command: " cmd " " (string-intersperse params " ")) #f) (let-values (((fh fho pid) (if (null? params) (process cmd) (process cmd params)))) - (let loop ((curr (read-line fh)) + (let loop ((curr (read-line fh)) (result '())) (if (not (eof-object? curr)) (loop (read-line fh) (append result (list (proc curr)))) (begin (close-input-port fh) + (close-input-port fhe) (close-output-port fho) result)))))) (define (cmd-run-proc-each-line-alt cmd proc) (let* ((fh (open-input-pipe cmd)) Index: server.scm ================================================================== --- server.scm +++ server.scm @@ -53,10 +53,11 @@ hostn)) (ipaddrstr (if (string=? "-" hostn) (string-intersperse (map number->string (u8vector->list (hostname->ip hostname))) ".") #f)) (host:port (conc (if ipaddrstr ipaddrstr hostname) ":" (rpc:default-server-port)))) + (debug:print 0 "Server started on " host:port) (db:set-var db "SERVER" host:port) (set! *cache-on* #t) ;; can use this to run most anything at the remote (rpc:publish-procedure! @@ -136,11 +137,11 @@ (begin (debug:print 0 "INFO: Queue not flushed, waiting ...") (loop (+ n 1))))) ))) (thread-start! th1) - (debug:print 0 "Server started...") + ;; (debug:print 0 "Server started on port " (rpc:default-server-port) "...") (thread-start! th2) ;; (thread-join! th2) ;; return th2 for the calling process to do a join with th2 )))) ;; rpc:server))) @@ -170,12 +171,12 @@ exn (begin (print "Failed to bind to port " (rpc:default-server-port) ", trying next port") (server:find-free-port-and-open (+ port 1))) (rpc:default-server-port port) - (tcp-read-timeout 120000) - (tcp-listen (rpc:default-server-port) ))) + (tcp-read-timeout 240000) + (tcp-listen (rpc:default-server-port) 10000))) (define (server:client-setup) (if *runremote* (begin (debug:print 0 "ERROR: Attempt to connect to server but already connected") Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -24,30 +24,31 @@ test3 : fullprep cd fullrun;$(MEGATEST) -runtests runfirst -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_b $(SERVER) -debug 10 test4 : fullprep cd fullrun;$(MEGATEST) $(SERVER) & - 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 + 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) & - cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_aa -debug $(DEBUG) > aa.log 2> aa.log & - cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ab -debug $(DEBUG) > ab.log 2> ab.log & - cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ac -debug $(DEBUG) > ac.log 2> ac.log & - cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ad -debug $(DEBUG) > ad.log 2> ad.log & -# cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ae -debug $(DEBUG) > ae.log 2> ae.log & -# cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_af -debug $(DEBUG) > af.log 2> af.log & + cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_aa -debug $(DEBUG) -logging > aa.log 2> aa.log & + cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ab -debug $(DEBUG) -logging > ab.log 2> ab.log & + cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ac -debug $(DEBUG) -logging > ac.log 2> ac.log & + cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ad -debug $(DEBUG) -logging > ad.log 2> ad.log & +# cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ae -debug $(DEBUG) -logging > ae.log 2> ae.log & +# cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_af -debug $(DEBUG) -logging > af.log 2> af.log & test6: fullprep cd fullrun;$(MEGATEST) -runtests runfirst -itempatt %/1 -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_itempatt -v cd fullrun;$(MEGATEST) -runtests runfirst -itempatt %blahha% -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_itempatt -debug 10 cleanprep : ../*.scm Makefile */*.config # if [ -e fullrun/megatest.db ]; then sqlite3 fullrun/megatest.db "delete from metadat where var='SERVER';";fi mkdir -p /tmp/mt_runs /tmp/mt_links cd ..;make install + rm -f fullrun/logging.db touch cleanprep fullprep : cleanprep cd fullrun;$(MEGATEST) -remove-runs :runname $(RUNNAME)% -target %/%/% -testpatt % -itempatt % cd fullrun;$(BINPATH)/dboard -rows 15 & Index: tests/tests.scm ================================================================== --- tests/tests.scm +++ tests/tests.scm @@ -1,6 +1,7 @@ (require-extension test) +(require-extension regex) (define test-work-dir (current-directory)) ;; read in all the _record files (let ((files (glob "*_records.scm"))) @@ -7,10 +8,22 @@ (for-each (lambda (file) (print "Loading " file) (load file)) files)) + +;;====================================================================== +;; P R O C E S S E S +;;====================================================================== + +(test "cmd-run-with-stderr->list" '("No such file or directory") + (let ((reslst (cmd-run-with-stderr->list "ls" "/tmp/ihadbetternotexist"))) + (string-search (regexp "No such file or directory")(car reslst)))) + +;;====================================================================== +;; C O N F I G F I L E S +;;====================================================================== (define conffile #f) (test "Read a config" #t (hash-table? (read-config "test.config" #f #f))) (test "Read a config that doesn't exist" #t (hash-table? (read-config "nada.config" #f #f))) Index: utils/installall.sh ================================================================== --- utils/installall.sh +++ utils/installall.sh @@ -15,10 +15,12 @@ echo sudo apt-get install libmotif3 -OR- set KTYPE=26g4 echo KTYPE can be 26, 26g4, 32, or 32_64 echo KTYPE=$KTYPE echo You are using PREFIX=$PREFIX echo You are using proxy="$proxy" +echo "Set additional_libpath to help find gtk or other libraries, don't forget a leading :" +echo ADDITIONAL_LIBPATH=$ADDITIONAL_LIBPATH echo Hit ^C now to do that # A nice way to run this script: # # script -c 'PREFIX=/tmp/delme ./installall.sh ' installall.log @@ -129,11 +131,11 @@ make make install cd $BUILDHOME -export LIBPATH=$PREFIX/lib +export LIBPATH=$PREFIX/lib$ADDITIONAL_LIBPATH export LD_LIBRARY_PATH=$LIBPATH CSC_OPTIONS="-I$PREFIX/include -L$LIBPATH" chicken-install $PROX -D no-library-checks iup CSC_OPTIONS="-I$PREFIX/include -L$LIBPATH" chicken-install $PROX -D no-library-checks canvas-draw # export CD_REL=d704525ebe1c6d08