Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -289,11 +289,11 @@ $(MTQA_FOSSIL) : fossil clone https://www.kiatoa.com/fossils/megatest_qa $(MTQA_FOSSIL) clean : - rm -f $(OFILES) $(GOFILES)$(MOFILES) $(PREFIX)/megatest $(PREFIX)/dashboard mtest mtutil dboard dboard.o megatest.o dashboard.o megatest-fossil-hash.* altdb.scm + rm -f $(OFILES) $(GOFILES)$(MOFILES) $(PREFIX)/megatest $(PREFIX)/dashboard mtest mtutil dboard dboard.o megatest.o dashboard.o megatest-fossil-hash.* altdb.scm mofiles/*.o vg.o #====================================================================== # Make the records files #====================================================================== Index: dashboard.scm ================================================================== --- dashboard.scm +++ dashboard.scm @@ -85,10 +85,11 @@ "-test" "-xterm" "-debug" "-host" "-transport" + "-start-dir" ) (list "-h" "-use-server" "-guimonitor" "-main" @@ -109,10 +110,19 @@ (if (args:get-arg "-h") (begin (print help) (exit))) + +(if (args:get-arg "-start-dir") + (if (directory-exists? (args:get-arg "-start-dir")) + (let ((fullpath (common:real-path (args:get-arg "-start-dir")))) + (setenv "PWD" fullpath) + (change-directory fullpath)) + (begin + (debug:print-error 0 *default-log-port* "non-existant start dir " (args:get-arg "-start-dir") " specified, exiting.") + (exit 1)))) ;; TODO: Move this inside (main) ;; (if (not (launch:setup)) (begin Index: megatest.config ================================================================== --- megatest.config +++ megatest.config @@ -49,12 +49,12 @@ [access] ext matt:admin mattw:owner [accesstypes] -admin run rerun resume remove set-ss -owner run rerun resume remove +admin run rerun resume remove set-ss rerun-clean +owner run rerun resume remove rerun-all badguy set-ss [setup] maxload 1.2 Index: mtut.scm ================================================================== --- mtut.scm +++ mtut.scm @@ -97,10 +97,19 @@ (if (common:file-exists? ".mtutil.so") (load ".mtutil.so") (if (common:file-exists? ".mtutil.scm") (load ".mtutil.scm")))) +;; main three types of run +;; "-run" => initiate a run +;; "-rerun-clean" => set failed, aborted, killed, etc. (not pass/fail) to NOT_STARTED and kick off run +;; "-rerun-all" => set all tests NOT_STARTED and kick off run again + +;; deprecated/do not use +;; "-runall" => synonym for run, do not use +;; "-runtests" => synonym for run, do not use + ;; Disabled help items ;; -rollup : (currently disabled) fill run (set by :runname) with latest test(s) ;; from prior runs with same keys ;; Contour actions ;; import : import pkts @@ -115,18 +124,22 @@ Usage: mtutil action [options] -h : this help -manual : show the Megatest user manual -version : print megatest version (currently " megatest-version ") -Actions: - run : initiate runs +Run management: + run : initiate or resume a run, already completed and in-progress + tests are not affected. + rerun-clean : clean and rerun all not completed pass/fail tests + rerun-all : clean and rerun entire run remove : remove runs - rerun : register action for processing set-ss : set state/status archive : compress and move test data to archive disk kill : stop tests or entire runs db : database utilities + +Queries: areas, contours, setup : show areas, contours or setup section from megatest.config gendot : generate a graphviz dot file from pkts. Contour actions: process : runs import, rungen and dispatch @@ -154,10 +167,11 @@ overwritten by values set in config files. -log logfile : send stdout and stderr to logfile -repl : start a repl (useful for extending megatest) -load file.scm : load and run file.scm -debug N|N,M,O... : enable debug messages 0-N or N and M and O ... + -list-pkt-keys : list all pkt keys Utility db pgschema : emit postgresql schema; do \"mtutil db pgschema | psql -d mydb\" Examples: @@ -209,21 +223,30 @@ ("-version" . #f) ;; misc ("-repl" . #f) ("-immediate" . I) ("-preclean" . r) - ("-rerun-all" . u) ("-prepend-contour" . w) + ("-list-pkt-keys" . #f) )) ;; alist to map actions to old megatest commands (define *action-keys* '((run . "-run") + (rerun-clean . "-rerun-clean") + (rerun-all . "-rerun-all") (sync . "") (archive . "-archive") (set-ss . "-set-state-status") (remove . "-remove-runs"))) + +;; manually keep this list updated from the keys to +;; the case *action* near the end of this file. +(define *other-actions* + '(run remove rerun set-ss archive kill list + dispatch import rungen process + show gendot db tsend tlisten)) ;; Card types: ;; ;; A action ;; U username (Unix) @@ -264,10 +287,13 @@ (or inlst *arg-keys*))) (define (lookup-action-by-key key) (alist-ref (string->symbol key) *action-keys*)) +(define (swizzle-alist lst) + (map (lambda (x)(cons (cdr x)(car x))) lst)) + ;;====================================================================== ;; U T I L S ;;====================================================================== ;; given a mtutil param, return the old megatest equivalent @@ -345,28 +371,79 @@ ;;====================================================================== ;; GLOBALS ;;====================================================================== -;; process args -(define *action* (if (> (length (argv)) 1) +;; first token is our action, but only if no leading dash +(define *action* (if (and (> (length (argv)) 1) + (not (string-match "^\\-.*" (cadr (argv))))) (cadr (argv)) #f)) + +;; process arguments, extract switches and parameters first (define remargs (args:get-args (if *action* (cdr (argv)) (argv)) ;; args:get-args dumps first in argv list (the program name) (map car *arg-keys*) (map car *switch-keys*) args:arg-hash 0)) +;; handle requests for help +;; (if (or (member *action* '("-h" "-help" "help" "--help")) (args:any-defined? "-h" "-help" "--help")) (begin (print help) (exit 1))) +(define (print-pkt-keys inlst) + (for-each + (lambda (p) + (let ((sw (car p)) + (c (cdr p))) + (print (or c "n/a") "\t" sw))) + inlst)) + +(define (print-duplicate-keys . all) + (let ((card-hash (make-hash-table))) + (for-each + (lambda (lst) + (for-each + (lambda (card-spec) + (let ((k (cdr card-spec))) + ;; (print "card-spec: " card-spec ", k: " k) + (if k (hash-table-set! card-hash k (+ (hash-table-ref/default card-hash k 0) 1))))) + lst)) + all) + (for-each + (lambda (k) + (if (> (hash-table-ref card-hash k) 1) + (print k "\t" (hash-table-ref card-hash k)))) + (sort (hash-table-keys card-hash) (lambda (a b)(>= (hash-table-ref card-hash a)(hash-table-ref card-hash b))))) + )) + +(define (print-pkt-key-info) + (print "Argument keys") + (print-pkt-keys *arg-keys*) + (print "\nSwitch keys") + (print-pkt-keys *switch-keys*) + (print "\nAction keys") + (print-pkt-keys *action-keys*) + (print "\nAdditional cards") + (print-pkt-keys (swizzle-alist *additional-cards*)) + (print "\nDuplicate keys") + (print-duplicate-keys *arg-keys* *switch-keys* *action-keys* (swizzle-alist *additional-cards*)) + (print "\nEnd of report.") + ) + +;; list packet keys +;; +(if (args:get-arg "-list-pkt-keys") + (begin (print-pkt-key-info)(exit 0))) + ;; (print "*action*: " *action*) + ;; (let-values (((uuid pkt) ;; (command-line->pkt #f args:arg-hash))) ;; (print pkt)) ;; Add args that use remargs here @@ -1115,11 +1192,11 @@ (if (common:file-exists? debugcontrolf) (load debugcontrolf))) (if *action* (case (string->symbol *action*) - ((run remove rerun set-ss archive kill list) + ((run remove rerun rerun-clean rerun-all set-ss archive kill list) (let* ((mtconfdat (simple-setup (args:get-arg "-start-dir"))) (mtconf (car mtconfdat)) (area (args:get-arg "-area")) ;; look up the area to dispatch to from [areas] section (areasec (if area (configf:lookup mtconf "areas" area) #f)) (areadat (if areasec (common:val->alist areasec) #f)) @@ -1258,11 +1335,14 @@ (let loop ((instr (nn-recv rep))) (print "received " instr ", running \"" script " " instr "\"") (system (conc script " '" instr "'")) (nn-send rep "ok") (loop (nn-recv rep)))) - (print "ERROR: Port " portnum " already in use. Try another port"))))))) + (print "ERROR: Port " portnum " already in use. Try another port"))))))) + (else + (let ((all-actions (sort (map conc (delete-duplicates (append *other-actions* (map car *action-keys*)))) string<=?))) + (print "unrecognised action: \"" *action* "\", try one of; \"" (string-intersperse all-actions "\", \"") "\""))) )) ;; the end ;; If HTTP_HOST is defined then we must be in the cgi environment