Index: configf.scm ================================================================== --- configf.scm +++ configf.scm @@ -53,11 +53,11 @@ (define configf:include-rx (regexp "^\\[include\\s+(.*)\\]\\s*$")) (define configf:section-rx (regexp "^\\[(.*)\\]\\s*$")) (define configf:blank-l-rx (regexp "^\\s*$")) (define configf:key-sys-pr (regexp "^(\\S+)\\s+\\[system\\s+(\\S+.*)\\]\\s*$")) -(define configf:key-val-pr (regexp "^(\\S+)\\s+(.*)$")) +(define configf:key-val-pr (regexp "^(\\S+)(\\s+(.*)|())$")) (define configf:comment-rx (regexp "^\\s*#.*")) (define configf:cont-ln-rx (regexp "^(\\s+)(\\S+.*)$")) ;; read a line and process any #{ ... } constructs @@ -181,11 +181,11 @@ ((return-procs) val-proc) ((return-string) cmd) (else (val-proc))))) (loop (configf:read-line inp res) curr-section-name #f #f)) (loop (configf:read-line inp res) curr-section-name #f #f))) - (configf:key-val-pr ( x key val ) (let* ((alist (hash-table-ref/default res curr-section-name '())) + (configf:key-val-pr ( x key unk1 val unk2 ) (let* ((alist (hash-table-ref/default res curr-section-name '())) (envar (and environ-patt (string-search (regexp environ-patt) curr-section-name))) (realval (if envar (config:eval-string-in-environment val) val))) (debug:print 6 "INFO: read-config env setting, envar: " envar " realval: " realval " val: " val " key: " key " curr-section-name: " curr-section-name) Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -475,11 +475,12 @@ (define (db:patt->like fieldname pattstr #!key (comparator " OR ")) (let ((patts (if (string? pattstr) (string-split pattstr ",") '("%")))) (string-intersperse (map (lambda (patt) - (conc fieldname " LIKE '" patt "'")) + (let ((wildtype (if (substring-index "%" patt) "LIKE" "GLOB"))) + (conc fieldname " " wildtype " '" patt "'"))) (if (null? patts) '("") patts)) comparator))) Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -32,32 +32,34 @@ ;; register a test run with the db ;; ;; Use: (db-get-value-by-header (db:get-header runinfo)(db:get-row runinfo)) ;; to extract info from the structure returned ;; -(define (runs:get-runs-by-patt db keys runnamepatt . params) ;; test-name) +(define (runs:get-runs-by-patt db keys runnamepatt) ;; test-name) (let* ((keyvallst (keys->vallist keys)) (tmp (runs:get-std-run-fields keys '("id" "runname" "state" "status" "owner" "event_time"))) (keystr (car tmp)) (header (cadr tmp)) (res '()) - (key-patt "")) + (key-patt "") + (runwildtype (if (substring-index "%" runnamepatt) "like" "glob"))) (for-each (lambda (keyval) (let* ((key (vector-ref keyval 0)) (fulkey (conc ":" key)) - (patt (args:get-arg fulkey))) + (patt (args:get-arg fulkey)) + (wildtype (if (substring-index "%" patt) "like" "glob"))) (if patt - (set! key-patt (conc key-patt " AND " key " like '" patt "'")) + (set! key-patt (conc key-patt " AND " key " " wildtype " '" patt "'")) (begin (debug:print 0 "ERROR: searching for runs with no pattern set for " fulkey) (exit 6))))) keys) (sqlite3:for-each-row (lambda (a . r) (set! res (cons (list->vector (cons a r)) res))) db - (conc "SELECT " keystr " FROM runs WHERE runname like ? " key-patt ";") + (conc "SELECT " keystr " FROM runs WHERE runname " runwildtype " ? " key-patt ";") runnamepatt) (vector header res))) (define (runs:test-get-full-path test) (let* ((testname (db:test-get-testname test)) @@ -734,18 +736,20 @@ sort-by: (case action ((remove-runs) 'rundir) (else 'event_time))) '())) (lasttpath "/does/not/exist/I/hope")) - + (debug:print 4 "INFO: runs:operate-on run=" run ", header=" header) (if (not (null? tests)) (begin (case action ((remove-runs) (debug:print 1 "Removing tests for run: " runkey " " (db:get-value-by-header run header "runname"))) ((set-state-status) (debug:print 1 "Modifying state and staus for tests for run: " runkey " " (db:get-value-by-header run header "runname"))) + ((print-run) + (debug:print 1 "Printing info for run " runkey ", run=" run ", tests=" tests ", header=" header)) (else (print "INFO: action not recognised " action))) (for-each (lambda (test) (let* ((item-path (db:test-get-item-path test)) Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -27,10 +27,12 @@ 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 -reqtarg ubuntu/nfs/none -itempatt a/1 :runname $(RUNNAME)_a $(SERVER) + cd fullrun;sleep 20;megatest -target ubuntu/nfs/none :runname $(RUNNAME) -set-state-status :state COMPLETED :status FORCED -testpatt runfirst -itempatt '' + test3 : fullprep cd fullrun;$(MEGATEST) -runtests runfirst -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_b $(SERVER) -debug 10 test4 : fullprep Index: tests/fullrun/megatest.config ================================================================== --- tests/fullrun/megatest.config +++ tests/fullrun/megatest.config @@ -36,10 +36,12 @@ WACKYVAR4 #{scheme (+ 5 6 7)} WACKYVAR5 #{getenv sysname}/#{getenv fsname}/#{getenv datapath} WACKYVAR6 #{scheme (args:get-arg "-target")} PREDICTABLE the_ans MRAH MT_RUN_AREA_HOME=#{getenv MT_RUN_AREA_HOME} +# The empty var should have a definition with null string +EMPTY_VAR # XTERM [system xterm] # RUNDEAD [system exit 56] ## disks are: ADDED tests/fullrun/tests/test_mt_vars/empty_var.sh Index: tests/fullrun/tests/test_mt_vars/empty_var.sh ================================================================== --- /dev/null +++ tests/fullrun/tests/test_mt_vars/empty_var.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +if [ x$EMPTY_VAR != "x" ];then + echo BAD EMPTY VAR! + exit 1 +fi Index: tests/fullrun/tests/test_mt_vars/testconfig ================================================================== --- tests/fullrun/tests/test_mt_vars/testconfig +++ tests/fullrun/tests/test_mt_vars/testconfig @@ -9,10 +9,13 @@ # $BOGOUS should NOT be set bogousnotset bogousnotset.sh # ALT_VAR should NOT be set altvarnotset altvarnotset.sh + +# EMPTY_VAR should be an empty string +empty_var empty_var.sh [requirements] waiton runfirst priority 0 Index: tests/tests.scm ================================================================== --- tests/tests.scm +++ tests/tests.scm @@ -100,10 +100,17 @@ "myrun" "new" "n/a" "bob"))) (define keys (db:get-keys *db*)) + +;;====================================================================== +;; D B +;;====================================================================== +(test #f "FOO LIKE 'abc%def'" (db:patt->like "FOO" "abc%def")) +(test #f "SYSTEM,RELEASE,id,runname,state,status,owner,event_time" (car (runs:get-std-run-fields keys '("id" "runname" "state" "status" "owner" "event_time")))) +(test #f #t (list? (runs:operate-on 'print "%" "%" "%"))) ;;(test "update-test-info" #t (test-update-meta-info *db* 1 "nada" (setenv "BLAHFOO" "1234") (unsetenv "NADAFOO") (test "env temp overrides" "xyz" (let ((prevvals (alist->env-vars '(("BLAHFOO" 4321)("NADAFOO" xyz))))