Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -627,24 +627,34 @@ #!key (not-in #t) (sort-by #f) ;; 'rundir 'event_time ) (let* ((res '()) ;; if states or statuses are null then assume match all when not-in is false - (states-str (conc " state in ('" (string-intersperse states "','") "')")) - (statuses-str (conc " status in ('" (string-intersperse statuses "','") "')")) - (state-status-qry (if (or (not (null? states)) - (not (null? states))) - (conc " AND " (if not-in "NOT" "") " (" states-str " AND " statuses-str ") ") - "")) - (qry (conc "SELECT id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment " - " FROM tests WHERE run_id=? AND (" - (tests:match->sqlqry testpatt) - state-status-qry - (case sort-by - ((rundir) ") ORDER BY length(rundir) DESC;") - ((event_time) ") ORDER BY event_time ASC;") - (else ");")) + (states-qry (if (null? states) + #f + (conc " state " + (if not-in "NOT" "") + " IN ('" + (string-intersperse states "','") + "')"))) + (statuses-qry (if (null? statuses) + #f + (conc " status " + (if not-in "NOT" "") + " IN ('" + (string-intersperse statuses "','") + "')"))) + (tests-match-qry (tests:match->sqlqry testpatt)) + (qry (conc "SELECT id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment " + " FROM tests WHERE run_id=? " + (if states-qry (conc " AND " states-qry) "") + (if statuses-qry (conc " AND " statuses-qry) "") + (if tests-match-qry (conc " AND (" tests-match-qry ") ") "") + (case sort-by + ((rundir) " ORDER BY length(rundir) DESC;") + ((event_time) " ORDER BY event_time ASC;") + (else ";")) ))) (debug:print 8 "INFO: db:get-tests-for-run qry=" qry) (sqlite3:for-each-row (lambda (a . b) ;; id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment) (set! res (cons (apply vector a b) res))) ;; id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment) res))) Index: tests.scm ================================================================== --- tests.scm +++ tests.scm @@ -81,11 +81,11 @@ ;; (define (tests:match->sqlqry patterns) (if (string? patterns) (let ((patts (string-split patterns ","))) (if (null? patts) ;;; no pattern(s) means no match, we will do no query - "" + #f (let loop ((patt (car patts)) (tal (cdr patts)) (res '())) ;; (print "loop: patt: " patt ", tal " tal) (let* ((patt-parts (string-match (regexp "^([^\\/]*)(\\/(.*)|)$") patt)) @@ -95,11 +95,12 @@ (item-qry (db:patt->like "item_path" item-patt)) (qry (conc "(" test-qry " AND " item-qry ")"))) ;; (print "tests:match => patt-parts: " patt-parts ", test-patt: " test-patt ", item-patt: " item-patt) (if (null? tal) (string-intersperse (append (reverse res)(list qry)) " OR ") - (loop (car tal)(cdr tal)(cons qry res))))))))) + (loop (car tal)(cdr tal)(cons qry res))))))) + #f)) ;; get the previous record for when this test was run where all keys match but runname ;; returns #f if no such test found, returns a single test record if found (define (test:get-previous-test-run-record db run-id test-name item-path) (let* ((keys (db:get-keys db)) Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -27,11 +27,11 @@ cd simplerun;cp ../../*_records.scm .;perl -pi.bak -e 's/define-inline/define/' *_records.scm cd simplerun;echo '(load "../tests.scm")' | $(MEGATEST) -repl -debug $(DEBUG) test2 : fullprep cd fullrun;$(MEGATEST) -runtests ez_pass,runfirst/a/% -reqtarg ubuntu/nfs/none :runname $(RUNNAME) $(SERVER) -debug $(DEBUG) $(LOGGING) - sleep 40;cd fullrun;megatest -target ubuntu/nfs/none :runname $(RUNNAME) -set-state-status COMPLETED,FORCED :state COMPLETED :status PASS -testpatt ez_p%s,runfirst -debug $(DEBUG) $(LOGGING) + sleep 40;cd fullrun;megatest -target ubuntu/nfs/none :runname $(RUNNAME) -set-state-status COMPLETED,FORCED :state COMPLETED :status PASS -testpatt ez_p%s,runfirst/ -debug $(DEBUG) $(LOGGING) test3 : fullprep cd fullrun;$(MEGATEST) -runtests runfirst -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_b $(SERVER) -debug 10