@@ -37,10 +37,18 @@ Run data :runname : required, name for this particular test run :state : required if updating step state; e.g. start, end, completed :status : required if updating step status; e.g. pass, fail, n/a +Values and record errors and warnings + -set-values : update or set values in the megatest db + :value : value measured + :expected_value : value expected + :tol : tolerance |value-expect| <= tol + :first_err : record an error message + :first_warn : record a warning message + Queries -list-runs patt : list runs matching pattern \"patt\", % is the wildcard -testpatt patt : in list-runs show only these tests, % is the wildcard -itempatt patt : in list-runs show only tests with items that match patt -showkeys : show the keys used in this megatest setup @@ -57,10 +65,11 @@ if -keepgoing is also specified) -rebuild-db : bring the database schema up to date -rollup N : fill run (set by :runname) with latest test(s) from past N days, requires keys -rename-run : rename run (set by :runname) to , requires keys + -update-meta : update the tests metadata for all tests Helpers -runstep stepname ... : take remaining params as comand and execute as stepname log will be in stepname.log. Best to put command in quotes -logpro file : with -exec apply logpro file to stepname.log, creates @@ -94,25 +103,34 @@ "-m" "-rerun" "-days" "-rename-run" "-to" + ;; values and messages + ":first_err" + ":first_warn" + ":value" + ":expected_value" + ":tol" + ;; misc "-debug" ;; for *verbosity* > 2 ) (list "-h" "-force" "-xterm" "-showkeys" "-test-status" + "-set-values" "-summarize-items" "-gui" "-runall" ;; run all tests "-remove-runs" "-keepgoing" "-usequeue" "-rebuild-db" "-rollup" + "-update-meta" "-v" ;; verbose 2, more than normal (normal is 1) "-q" ;; quiet 0, errors/warnings only ) args:arg-hash 0)) @@ -358,11 +376,11 @@ (alist->env-vars env-ovrd) (set-megatest-env-vars db run-id) (set-item-env-vars itemdat) (save-environment-as-files "megatest") (test-set-meta-info db run-id test-name itemdat) - (test-set-status! db run-id test-name "REMOTEHOSTSTART" "n/a" itemdat (args:get-arg "-m")) + (test-set-status! db run-id test-name "REMOTEHOSTSTART" "n/a" itemdat (args:get-arg "-m") #f) (if (args:get-arg "-xterm") (set! fullrunscript "xterm") (if (not (file-execute-access? fullrunscript)) (system (conc "chmod ug+x " fullrunscript)))) ;; We are about to actually kick off the test @@ -446,11 +464,11 @@ ;; (sqlite3:finalize! db) ;; (exit 1))))) (begin (debug:print 0 "WARNING: Request received to kill job but problem with process, attempting to kill manager process") (test-set-status! db run-id test-name "KILLED" "FAIL" - itemdat (args:get-arg "-m")) + itemdat (args:get-arg "-m") #f) (sqlite3:finalize! db) (exit 1)))) ;; (thread-terminate! job-thread))) (set! kill-tries (+ 1 kill-tries)) (mutex-unlock! m))) @@ -490,11 +508,11 @@ (if (vector-ref exit-info 1) ;; look at the exit-status (if (and (not kill-job?) (eq? (vector-ref exit-info 2) 0)) "PASS" "FAIL") - "FAIL") itemdat (args:get-arg "-m")))) + "FAIL") itemdat (args:get-arg "-m") #f))) ;; for automated creation of the rollup html file this is a good place... (if (not (equal? item-path "")) (tests:summarize-items db run-id test-name #f)) ;; don't force - just update if no ) (mutex-unlock! m) @@ -538,10 +556,11 @@ (set! *didsomething* #t)))) (if (or (args:get-arg "-setlog") ;; since setting up is so costly lets piggyback on -test-status (args:get-arg "-set-toplog") (args:get-arg "-test-status") + (args:get-arg "-set-values") (args:get-arg "-runstep") (args:get-arg "-summarize-items")) (if (not (getenv "MT_CMDINFO")) (begin (debug:print 0 "ERROR: MT_CMDINFO env var not set, commands -test-status, -runstep and -setlog must be called *inside* a megatest environment!") @@ -616,22 +635,33 @@ (if (not (eq? exitstat 0)) (exit 254)) ;; (exit exitstat) doesn't work?!? ;; open the db ;; mark the end of the test ))) - (if (args:get-arg "-test-status") + (if (or (args:get-arg "-test-status") + (args:get-arg "-set-values")) (let ((newstatus (cond ((number? status) (if (equal? status 0) "PASS" "FAIL")) - ((string->number status)(if (equal? (string->number status) 0) "PASS" "FAIL")) - (else status)))) - (test-set-status! db run-id test-name state newstatus itemdat (args:get-arg "-m"))) - (if (and state status) - (if (not (args:get-arg "-setlog")) - (begin - (debug:print 0 "ERROR: You must specify :state and :status with every call to -test-status\n" help) - (sqlite3:finalize! db) - (exit 6))))) + ((and (string? status) + (string->number status))(if (equal? (string->number status) 0) "PASS" "FAIL")) + (else status))) + ;; transfer relevant keys into a hash to be passed to test-set-status! + ;; could use an assoc list I guess. + (otherdata (let ((res (make-hash-table))) + (for-each (lambda (key) + (if (args:get-arg key) + (hash-table-set! res key (args:get-arg key)))) + (list ":value" ":tol" ":expected_value" ":first_err" ":first_warn")) + res))) + (if (and (args:get-arg "-test-status") + (or (not state) + (not status))) + (begin + (debug:print 0 "ERROR: You must specify :state and :status with every call to -test-status\n" help) + (sqlite3:finalize! db) + (exit 6))) + (test-set-status! db run-id test-name state newstatus itemdat (args:get-arg "-m") otherdata))) (sqlite3:finalize! db) (set! *didsomething* #t)))) (if (args:get-arg "-showkeys") (let ((db #f) @@ -665,10 +695,26 @@ ;; now can find our db (set! db (open-db)) (patch-db db) (sqlite3:finalize! db) (set! *didsomething* #t))) + +;;====================================================================== +;; Update the tests meta data from the testconfig files +;; + +(if (args:get-arg "-update-meta") + (begin + (if (not (setup-for-run)) + (begin + (debug:print 0 "Failed to setup, exiting") + (exit 1))) + ;; now can find our db + (set! db (open-db)) + (runs:update-all-test_meta db) + (sqlite3:finalize! db) + (set! *didsomething* #t))) (if (not *didsomething*) (debug:print 0 help)) (if (not (eq? *globalexitstatus* 0))