# along with this program. If not, see <http://www.gnu.org/licenses/>.
-source osstestlib.tcl
-
+source ./tcl/osstestlib.tcl
readconfig
+source-method JobDB
proc check {} {
global flight jobinfo running blessing killing stopping startdelay
if {$stopping} return
- db-open
+ jobdb::db-open
set nqueued [pg_execute dbh "
SELECT job FROM jobs j
ORDER BY job
" maybe-spawn-job
- db-close
+ jobdb::db-close
}
proc prequit {why} {
if {[string equal $job $jobinfo(job)]} return
}
- switch -glob $jobinfo(recipe) {
- build* { set runner sg-run-builds }
- test* { set runner sg-run-tests }
- * { error "unknown runner for recipe $jobinfo(recipe)" }
- }
- log "flight $flight spawning $jobinfo(job) $jobinfo(recipe) $runner"
+ log "flight $flight spawning $jobinfo(job)"
incr startdelay 300
execl sh {-c {trap '' TERM; read dummy}}
error "execl sh returned success ?!"
}
- execl ./$runner [list --start-delay $startdelay \
- $flight --jobs=$jobinfo(job)]
+ execl ./sg-run-job [list --start-delay $startdelay \
+ $flight $jobinfo(job)]
error "execl returned success ?!"
}
close $waiter_sentinel_r
proc parse-args {} {
global argv blessing
- set-flight
+ jobdb::set-flight
if {[llength $argv]!=1} { error "wrong # args" }
lassign $argv blessing
}
}
proc prepare {job} {
- global jobinfo
+ global flight jobinfo
db-open
set found 0
pg_execute -array jobinfo dbh "
set env(OSSTEST_FLIGHT) $flight
}
+variable dbusers 0
proc db-open {} {
global g
- variable dbusers 0
+ variable dbusers
if {$dbusers > 0} { incr dbusers; return }
+ set pl {
+ use Osstest;
+ use Osstest::Executive;
+ readglobalconfig();
+ print db_pg_dsn("osstestdb") or die $!;
+ }
+ set db_pg_dsn [exec perl -e $pl]
+
# PgDbName_* are odbc-style strings as accepted by Perl's DBD::Pg
# but Tcl pg_connect unaccountably uses a different format which
# is whitespace-separated.
- regsub -all {;} $c(ExecutiveDbname_osstestdb) { } conninfo
+ regsub -all {;} $db_pg_dsn { } conninfo
pg_connect -conninfo $conninfo -connhandle dbh
incr dbusers
}