2022-07-12 23:31:16 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
set dir [pwd]
|
2023-08-12 20:36:57 +03:00
|
|
|
set testdir [file normalize [file dirname $argv0]]
|
2023-02-04 21:47:59 +03:00
|
|
|
set saved $argv
|
|
|
|
set argv [list]
|
|
|
|
source [file join $testdir testrunner_data.tcl]
|
|
|
|
source [file join $testdir permutations.test]
|
|
|
|
set argv $saved
|
|
|
|
cd $dir
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-08-12 22:25:26 +03:00
|
|
|
# This script requires an interpreter that supports [package require sqlite3]
|
|
|
|
# to run. If this is not such an intepreter, see if there is a [testfixture]
|
|
|
|
# in the current directory. If so, run the command using it. If not,
|
|
|
|
# recommend that the user build one.
|
|
|
|
#
|
|
|
|
proc find_interpreter {} {
|
|
|
|
set interpreter [file tail [info nameofexec]]
|
|
|
|
set rc [catch { package require sqlite3 }]
|
|
|
|
if {$rc} {
|
|
|
|
if { [string match -nocase testfixture* $interpreter]==0
|
|
|
|
&& [file executable ./testfixture]
|
|
|
|
} {
|
|
|
|
puts "Failed to find tcl package sqlite3. Restarting with ./testfixture.."
|
|
|
|
set status [catch {
|
|
|
|
exec ./testfixture [info script] {*}$::argv >@ stdout
|
|
|
|
} msg]
|
|
|
|
exit $status
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if {$rc} {
|
|
|
|
puts stderr "Failed to find tcl package sqlite3"
|
|
|
|
puts stderr "Run \"make testfixture\" and then try again..."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
find_interpreter
|
|
|
|
|
2023-08-12 20:36:57 +03:00
|
|
|
# Usually this script is run by [testfixture]. But it can also be run
|
2023-08-12 22:25:26 +03:00
|
|
|
# by a regular [tclsh]. For these cases, emulate the [clock_milliseconds]
|
|
|
|
# command.
|
2023-08-12 20:36:57 +03:00
|
|
|
if {[info commands clock_milliseconds]==""} {
|
|
|
|
proc clock_milliseconds {} {
|
|
|
|
clock milliseconds
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 23:31:16 +03:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
proc usage {} {
|
2023-02-04 21:47:59 +03:00
|
|
|
set a0 [file tail $::argv0]
|
2022-07-14 00:02:07 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
puts stderr [string trim [subst -nocommands {
|
|
|
|
Usage:
|
|
|
|
$a0 ?SWITCHES? ?PERMUTATION? ?PATTERNS?
|
2023-02-04 21:50:16 +03:00
|
|
|
$a0 PERMUTATION FILE
|
2023-02-04 21:47:59 +03:00
|
|
|
$a0 njob ?NJOB?
|
|
|
|
$a0 status
|
|
|
|
|
|
|
|
where SWITCHES are:
|
|
|
|
--jobs NUMBER-OF-JOBS
|
2023-02-14 21:09:40 +03:00
|
|
|
--zipvfs ZIPVFS-SOURCE-DIR
|
2023-02-04 21:47:59 +03:00
|
|
|
|
|
|
|
Interesting values for PERMUTATION are:
|
|
|
|
|
|
|
|
veryquick - a fast subset of the tcl test scripts. This is the default.
|
|
|
|
full - all tcl test scripts.
|
|
|
|
all - all tcl test scripts, plus a subset of test scripts rerun
|
|
|
|
with various permutations.
|
|
|
|
release - full release test with various builds.
|
|
|
|
|
|
|
|
If no PATTERN arguments are present, all tests specified by the PERMUTATION
|
|
|
|
are run. Otherwise, each pattern is interpreted as a glob pattern. Only
|
|
|
|
those tcl tests for which the final component of the filename matches at
|
|
|
|
least one specified pattern are run.
|
|
|
|
|
|
|
|
If no PATTERN arguments are present, then various fuzztest, threadtest
|
|
|
|
and other tests are run as part of the "release" permutation. These are
|
|
|
|
omitted if any PATTERN arguments are specified on the command line.
|
|
|
|
|
2023-02-04 21:50:16 +03:00
|
|
|
If a PERMUTATION is specified and is followed by the path to a Tcl script
|
|
|
|
instead of a list of patterns, then that single Tcl test script is run
|
|
|
|
with the specified permutation.
|
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
The "status" and "njob" commands are designed to be run from the same
|
|
|
|
directory as a running testrunner.tcl script that is running tests. The
|
|
|
|
"status" command prints a report describing the current state and progress
|
|
|
|
of the tests. The "njob" command may be used to query or modify the number
|
|
|
|
of sub-processes the test script uses to run tests.
|
|
|
|
}]]
|
2022-07-14 00:02:07 +03:00
|
|
|
|
2022-07-12 23:31:16 +03:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Try to estimate a the number of processes to use.
|
2023-02-01 23:14:59 +03:00
|
|
|
#
|
2023-02-04 21:47:59 +03:00
|
|
|
# Command [guess_number_of_cores] attempts to glean the number of logical
|
|
|
|
# cores. Command [default_njob] returns the default value for the --jobs
|
|
|
|
# switch.
|
2023-02-01 23:14:59 +03:00
|
|
|
#
|
2023-02-04 21:47:59 +03:00
|
|
|
proc guess_number_of_cores {} {
|
2023-02-24 16:45:51 +03:00
|
|
|
if {[catch {number_of_cores} ret]} {
|
|
|
|
set ret 4
|
2023-02-04 21:47:59 +03:00
|
|
|
|
2023-08-16 17:18:53 +03:00
|
|
|
if {$::tcl_platform(platform)=="windows"} {
|
|
|
|
catch { set ret $::env(NUMBER_OF_PROCESSORS) }
|
2023-02-24 16:45:51 +03:00
|
|
|
} else {
|
2023-08-16 17:18:53 +03:00
|
|
|
if {$::tcl_platform(os)=="Darwin"} {
|
|
|
|
set cmd "sysctl -n hw.logicalcpu"
|
|
|
|
} else {
|
|
|
|
set cmd "nproc"
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
set fd [open "|$cmd" r]
|
|
|
|
set ret [gets $fd]
|
|
|
|
close $fd
|
|
|
|
set ret [expr $ret]
|
|
|
|
}
|
2023-02-24 16:45:51 +03:00
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
|
|
|
proc default_njob {} {
|
|
|
|
set nCore [guess_number_of_cores]
|
2023-02-24 16:45:51 +03:00
|
|
|
if {$nCore<=2} {
|
|
|
|
set nHelper 1
|
|
|
|
} else {
|
|
|
|
set nHelper [expr int($nCore*0.5)]
|
|
|
|
}
|
|
|
|
return $nHelper
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Setup various default values in the global TRG() array.
|
|
|
|
#
|
|
|
|
set TRG(dbname) [file normalize testrunner.db]
|
|
|
|
set TRG(logname) [file normalize testrunner.log]
|
|
|
|
set TRG(build.logname) [file normalize testrunner_build.log]
|
|
|
|
set TRG(info_script) [file normalize [info script]]
|
|
|
|
set TRG(timeout) 10000 ;# Default busy-timeout for testrunner.db
|
|
|
|
set TRG(nJob) [default_njob] ;# Default number of helper processes
|
|
|
|
set TRG(patternlist) [list]
|
|
|
|
set TRG(cmdline) $argv
|
|
|
|
set TRG(reporttime) 2000
|
2023-02-06 14:43:22 +03:00
|
|
|
set TRG(fuzztest) 0 ;# is the fuzztest option present.
|
2023-02-14 21:09:40 +03:00
|
|
|
set TRG(zipvfs) "" ;# -zipvfs option, if any
|
2023-02-04 21:47:59 +03:00
|
|
|
|
|
|
|
switch -nocase -glob -- $tcl_platform(os) {
|
|
|
|
*darwin* {
|
2023-08-27 00:04:54 +03:00
|
|
|
set TRG(platform) osx
|
|
|
|
set TRG(make) make.sh
|
|
|
|
set TRG(makecmd) "bash make.sh"
|
|
|
|
set TRG(testfixture) testfixture
|
2023-08-28 19:28:00 +03:00
|
|
|
set TRG(run) run.sh
|
|
|
|
set TRG(runcmd) "bash run.sh"
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
|
|
|
*linux* {
|
2023-08-27 00:04:54 +03:00
|
|
|
set TRG(platform) linux
|
|
|
|
set TRG(make) make.sh
|
|
|
|
set TRG(makecmd) "bash make.sh"
|
|
|
|
set TRG(testfixture) testfixture
|
2023-08-28 19:28:00 +03:00
|
|
|
set TRG(run) run.sh
|
|
|
|
set TRG(runcmd) "bash run.sh"
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
|
|
|
*win* {
|
2023-08-27 00:04:54 +03:00
|
|
|
set TRG(platform) win
|
|
|
|
set TRG(make) make.bat
|
|
|
|
set TRG(makecmd) make.bat
|
|
|
|
set TRG(testfixture) testfixture.exe
|
2023-08-28 19:28:00 +03:00
|
|
|
set TRG(run) run.bat
|
|
|
|
set TRG(runcmd) "run.bat"
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
|
|
|
default {
|
|
|
|
error "cannot determine platform!"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#-------------------------------------------------------------------------
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# The database schema used by the testrunner.db database.
|
|
|
|
#
|
|
|
|
set TRG(schema) {
|
2023-08-27 00:04:54 +03:00
|
|
|
DROP TABLE IF EXISTS jobs;
|
2023-02-04 21:47:59 +03:00
|
|
|
DROP TABLE IF EXISTS config;
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
/*
|
|
|
|
** This table contains one row for each job that testrunner.tcl must run
|
|
|
|
** before the entire test run is finished.
|
2023-08-28 21:15:14 +03:00
|
|
|
**
|
|
|
|
** jobid:
|
|
|
|
** Unique identifier for each job. Must be a +ve non-zero number.
|
|
|
|
**
|
|
|
|
** displaytype:
|
|
|
|
** 3 or 4 letter mnemonic for the class of tests this belongs to e.g.
|
|
|
|
** "fuzz", "tcl", "make" etc.
|
|
|
|
**
|
|
|
|
** displayname:
|
|
|
|
** Name/description of job. For display purposes.
|
|
|
|
**
|
|
|
|
** build:
|
|
|
|
** If the job requires a make.bat/make.sh make wrapper (i.e. to build
|
|
|
|
** something), the name of the build configuration it uses. See
|
|
|
|
** testrunner_data.tcl for a list of build configs. e.g. "Win32-MemDebug".
|
|
|
|
**
|
|
|
|
** dirname:
|
|
|
|
** If the job should use a well-known directory name for its
|
|
|
|
** sub-directory instead of an anonymous "testdir[1234...]" sub-dir
|
|
|
|
** that is deleted after the job is finished.
|
|
|
|
**
|
|
|
|
** cmd:
|
|
|
|
** Bash or batch script to run the job.
|
|
|
|
**
|
|
|
|
** depid:
|
|
|
|
** The jobid value of a job that this job depends on. This job may not
|
|
|
|
** be run before its depid job has finished successfully.
|
|
|
|
**
|
|
|
|
** priority:
|
|
|
|
** Higher values run first. Sometimes.
|
2023-08-27 00:04:54 +03:00
|
|
|
*/
|
|
|
|
CREATE TABLE jobs(
|
|
|
|
/* Fields populated when db is initialized */
|
2023-08-28 19:28:00 +03:00
|
|
|
jobid INTEGER PRIMARY KEY, -- id to identify job
|
|
|
|
displaytype TEXT NOT NULL, -- Type of test (for one line report)
|
2023-08-27 00:04:54 +03:00
|
|
|
displayname TEXT NOT NULL, -- Human readable job name
|
|
|
|
build TEXT NOT NULL DEFAULT '', -- make.sh/make.bat file request, if any
|
|
|
|
dirname TEXT NOT NULL DEFAULT '', -- directory name, if required
|
|
|
|
cmd TEXT NOT NULL, -- shell command to run
|
|
|
|
depid INTEGER, -- identifier of dependency (or '')
|
|
|
|
priority INTEGER NOT NULL, -- higher priority jobs may run earlier
|
|
|
|
|
|
|
|
/* Fields updated as jobs run */
|
|
|
|
starttime INTEGER,
|
|
|
|
endtime INTEGER,
|
2023-02-04 21:47:59 +03:00
|
|
|
state TEXT CHECK( state IN ('', 'ready', 'running', 'done', 'failed') ),
|
2023-08-27 00:04:54 +03:00
|
|
|
output TEXT
|
2023-02-04 21:47:59 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE config(
|
|
|
|
name TEXT COLLATE nocase PRIMARY KEY,
|
|
|
|
value
|
|
|
|
) WITHOUT ROWID;
|
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
CREATE INDEX i1 ON jobs(state, priority);
|
|
|
|
CREATE INDEX i2 ON jobs(depid);
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------
|
|
|
|
# Check if this script is being invoked to run a single file. If so,
|
|
|
|
# run it.
|
|
|
|
#
|
|
|
|
if {[llength $argv]==2
|
|
|
|
&& ([lindex $argv 0]=="" || [info exists ::testspec([lindex $argv 0])])
|
|
|
|
&& [file exists [lindex $argv 1]]
|
|
|
|
} {
|
|
|
|
set permutation [lindex $argv 0]
|
|
|
|
set script [file normalize [lindex $argv 1]]
|
2023-02-01 23:14:59 +03:00
|
|
|
set ::argv [list]
|
|
|
|
|
2023-08-12 20:36:57 +03:00
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $::testdir/tester.tcl
|
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
if {$permutation=="full"} {
|
|
|
|
|
|
|
|
unset -nocomplain ::G(isquick)
|
|
|
|
reset_db
|
|
|
|
|
|
|
|
} elseif {$permutation!="default" && $permutation!=""} {
|
|
|
|
|
|
|
|
if {[info exists ::testspec($permutation)]==0} {
|
|
|
|
error "no such permutation: $permutation"
|
|
|
|
}
|
|
|
|
|
|
|
|
array set O $::testspec($permutation)
|
|
|
|
set ::G(perm:name) $permutation
|
|
|
|
set ::G(perm:prefix) $O(-prefix)
|
|
|
|
set ::G(isquick) 1
|
|
|
|
set ::G(perm:dbconfig) $O(-dbconfig)
|
|
|
|
set ::G(perm:presql) $O(-presql)
|
|
|
|
|
|
|
|
rename finish_test helper_finish_test
|
|
|
|
proc finish_test {} "
|
|
|
|
uplevel {
|
|
|
|
$O(-shutdown)
|
|
|
|
}
|
|
|
|
helper_finish_test
|
|
|
|
"
|
|
|
|
|
|
|
|
eval $O(-initialize)
|
|
|
|
}
|
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
reset_db
|
2023-02-01 23:14:59 +03:00
|
|
|
source $script
|
|
|
|
exit
|
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
#--------------------------------------------------------------------------
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
#--------------------------------------------------------------------------
|
|
|
|
# Check if this is the "njob" command:
|
2022-07-13 20:46:42 +03:00
|
|
|
#
|
2023-02-04 21:47:59 +03:00
|
|
|
if {([llength $argv]==2 || [llength $argv]==1)
|
|
|
|
&& [string compare -nocase njob [lindex $argv 0]]==0
|
|
|
|
} {
|
|
|
|
sqlite3 mydb $TRG(dbname)
|
|
|
|
if {[llength $argv]==2} {
|
|
|
|
set param [lindex $argv 1]
|
|
|
|
if {[string is integer $param]==0 || $param<1 || $param>128} {
|
|
|
|
puts stderr "parameter must be an integer between 1 and 128"
|
|
|
|
exit 1
|
|
|
|
}
|
2022-07-13 20:46:42 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
mydb eval { REPLACE INTO config VALUES('njob', $param); }
|
|
|
|
}
|
|
|
|
set res [mydb one { SELECT value FROM config WHERE name='njob' }]
|
|
|
|
mydb close
|
|
|
|
puts "$res"
|
|
|
|
exit
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
#--------------------------------------------------------------------------
|
2022-07-13 20:46:42 +03:00
|
|
|
|
2023-08-15 21:52:25 +03:00
|
|
|
#--------------------------------------------------------------------------
|
|
|
|
# Check if this is the "script" command:
|
|
|
|
#
|
|
|
|
if {[string compare -nocase script [lindex $argv 0]]==0} {
|
|
|
|
if {[llength $argv]!=2 && !([llength $argv]==3&&[lindex $argv 1]=="-msvc")} {
|
|
|
|
usage
|
|
|
|
}
|
|
|
|
|
|
|
|
set bMsvc [expr ([llength $argv]==3)]
|
|
|
|
set config [lindex $argv [expr [llength $argv]-1]]
|
|
|
|
|
|
|
|
puts [trd_buildscript $config [file dirname $testdir] $bMsvc]
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
#--------------------------------------------------------------------------
|
|
|
|
# Check if this is the "status" command:
|
2022-07-13 20:46:42 +03:00
|
|
|
#
|
2023-02-04 21:47:59 +03:00
|
|
|
if {[llength $argv]==1
|
|
|
|
&& [string compare -nocase status [lindex $argv 0]]==0
|
|
|
|
} {
|
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
proc display_job {jobdict {tm ""}} {
|
|
|
|
array set job $jobdict
|
|
|
|
|
|
|
|
set dfname [format %-60s $job(displayname)]
|
2023-02-04 21:47:59 +03:00
|
|
|
|
|
|
|
set dtm ""
|
2023-08-27 00:04:54 +03:00
|
|
|
if {$tm!=""} { set dtm "\[[expr {$tm-$job(starttime)}]ms\]" }
|
|
|
|
puts " $dfname $dtm"
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sqlite3 mydb $TRG(dbname)
|
|
|
|
mydb timeout 1000
|
|
|
|
mydb eval BEGIN
|
|
|
|
|
|
|
|
set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }]
|
|
|
|
set nJob [mydb one { SELECT value FROM config WHERE name='njob' }]
|
2023-08-12 20:36:57 +03:00
|
|
|
|
|
|
|
set now [clock_milliseconds]
|
|
|
|
set tm [mydb one {
|
|
|
|
SELECT
|
|
|
|
COALESCE((SELECT value FROM config WHERE name='end'), $now) -
|
|
|
|
(SELECT value FROM config WHERE name='start')
|
|
|
|
}]
|
2023-02-04 21:47:59 +03:00
|
|
|
|
|
|
|
set total 0
|
|
|
|
foreach s {"" ready running done failed} { set S($s) 0 }
|
|
|
|
mydb eval {
|
2023-08-27 00:04:54 +03:00
|
|
|
SELECT state, count(*) AS cnt FROM jobs GROUP BY 1
|
2023-02-04 21:47:59 +03:00
|
|
|
} {
|
|
|
|
incr S($state) $cnt
|
|
|
|
incr total $cnt
|
|
|
|
}
|
|
|
|
set fin [expr $S(done)+$S(failed)]
|
|
|
|
if {$cmdline!=""} {set cmdline " $cmdline"}
|
|
|
|
|
|
|
|
set f ""
|
|
|
|
if {$S(failed)>0} {
|
|
|
|
set f "$S(failed) FAILED, "
|
|
|
|
}
|
|
|
|
puts "Command line: \[testrunner.tcl$cmdline\]"
|
|
|
|
puts "Jobs: $nJob"
|
|
|
|
puts "Summary: ${tm}ms, ($fin/$total) finished, ${f}$S(running) running"
|
|
|
|
|
|
|
|
set srcdir [file dirname [file dirname $TRG(info_script)]]
|
|
|
|
if {$S(running)>0} {
|
|
|
|
puts "Running: "
|
|
|
|
mydb eval {
|
2023-08-27 00:04:54 +03:00
|
|
|
SELECT * FROM jobs WHERE state='running' ORDER BY starttime
|
|
|
|
} job {
|
|
|
|
display_job [array get job] $now
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
2022-07-14 00:28:19 +03:00
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
if {$S(failed)>0} {
|
|
|
|
puts "Failures: "
|
|
|
|
mydb eval {
|
2023-08-27 00:04:54 +03:00
|
|
|
SELECT * FROM jobs WHERE state='failed' ORDER BY starttime
|
|
|
|
} job {
|
|
|
|
display_job [array get job]
|
2023-02-04 21:47:59 +03:00
|
|
|
}
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
|
|
|
|
mydb close
|
|
|
|
exit
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
2023-02-04 21:47:59 +03:00
|
|
|
# Parse the command line.
|
|
|
|
#
|
|
|
|
for {set ii 0} {$ii < [llength $argv]} {incr ii} {
|
|
|
|
set isLast [expr $ii==([llength $argv]-1)]
|
|
|
|
set a [lindex $argv $ii]
|
|
|
|
set n [string length $a]
|
|
|
|
|
|
|
|
if {[string range $a 0 0]=="-"} {
|
|
|
|
if {($n>2 && [string match "$a*" --jobs]) || $a=="-j"} {
|
|
|
|
incr ii
|
|
|
|
set TRG(nJob) [lindex $argv $ii]
|
|
|
|
if {$isLast} { usage }
|
2023-02-14 21:09:40 +03:00
|
|
|
} elseif {($n>2 && [string match "$a*" --zipvfs]) || $a=="-z"} {
|
|
|
|
incr ii
|
2023-11-01 17:33:44 +03:00
|
|
|
set TRG(zipvfs) [file normalize [lindex $argv $ii]]
|
2023-02-14 21:09:40 +03:00
|
|
|
if {$isLast} { usage }
|
2023-02-04 21:47:59 +03:00
|
|
|
} else {
|
|
|
|
usage
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lappend TRG(patternlist) [string map {% *} $a]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set argv [list]
|
2022-07-13 20:46:42 +03:00
|
|
|
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2022-07-13 22:57:35 +03:00
|
|
|
|
2023-02-03 21:47:00 +03:00
|
|
|
# This script runs individual tests - tcl scripts or [make xyz] commands -
|
|
|
|
# in directories named "testdir$N", where $N is an integer. This variable
|
|
|
|
# contains a list of integers indicating the directories in use.
|
|
|
|
#
|
|
|
|
# This variable is accessed only via the following commands:
|
|
|
|
#
|
|
|
|
# dirs_nHelper
|
|
|
|
# Return the number of entries currently in the list.
|
|
|
|
#
|
|
|
|
# dirs_freeDir IDIR
|
|
|
|
# Remove value IDIR from the list. It is an error if it is not present.
|
|
|
|
#
|
|
|
|
# dirs_allocDir
|
|
|
|
# Select a value that is not already in the list. Add it to the list
|
|
|
|
# and return it.
|
|
|
|
#
|
2023-02-04 21:47:59 +03:00
|
|
|
set TRG(dirs_in_use) [list]
|
2023-02-03 21:47:00 +03:00
|
|
|
|
|
|
|
proc dirs_nHelper {} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
|
|
|
llength $TRG(dirs_in_use)
|
2023-02-03 21:47:00 +03:00
|
|
|
}
|
|
|
|
proc dirs_freeDir {iDir} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
2023-02-03 21:47:00 +03:00
|
|
|
set out [list]
|
2023-02-04 21:47:59 +03:00
|
|
|
foreach d $TRG(dirs_in_use) {
|
2023-02-03 21:47:00 +03:00
|
|
|
if {$iDir!=$d} { lappend out $d }
|
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
if {[llength $out]!=[llength $TRG(dirs_in_use)]-1} {
|
2023-02-03 21:47:00 +03:00
|
|
|
error "dirs_freeDir could not find $iDir"
|
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
set TRG(dirs_in_use) $out
|
2023-02-03 21:47:00 +03:00
|
|
|
}
|
|
|
|
proc dirs_allocDir {} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
2023-02-03 21:47:00 +03:00
|
|
|
array set inuse [list]
|
2023-02-04 21:47:59 +03:00
|
|
|
foreach d $TRG(dirs_in_use) {
|
2023-02-03 21:47:00 +03:00
|
|
|
set inuse($d) 1
|
|
|
|
}
|
|
|
|
for {set iRet 0} {[info exists inuse($iRet)]} {incr iRet} { }
|
2023-02-04 21:47:59 +03:00
|
|
|
lappend TRG(dirs_in_use) $iRet
|
2023-02-03 21:47:00 +03:00
|
|
|
return $iRet
|
|
|
|
}
|
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
# Check that directory $dir exists. If it does not, create it. If
|
|
|
|
# it does, delete its contents.
|
2022-07-13 20:46:42 +03:00
|
|
|
#
|
2023-02-01 23:14:59 +03:00
|
|
|
proc create_or_clear_dir {dir} {
|
|
|
|
set dir [file normalize $dir]
|
|
|
|
catch { file mkdir $dir }
|
|
|
|
foreach f [glob -nocomplain [file join $dir *]] {
|
|
|
|
catch { file delete -force $f }
|
2022-07-12 23:31:16 +03:00
|
|
|
}
|
2023-02-01 23:14:59 +03:00
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
proc build_to_dirname {bname} {
|
|
|
|
set fold [string tolower [string map {- _} $bname]]
|
|
|
|
return "testrunner_build_$fold"
|
|
|
|
}
|
|
|
|
|
2022-07-14 21:09:56 +03:00
|
|
|
#-------------------------------------------------------------------------
|
2023-08-27 00:04:54 +03:00
|
|
|
|
|
|
|
proc r_write_db {tcl} {
|
|
|
|
trdb eval { BEGIN EXCLUSIVE }
|
|
|
|
uplevel $tcl
|
|
|
|
trdb eval { COMMIT }
|
|
|
|
}
|
|
|
|
|
|
|
|
# Obtain a new job to be run by worker $iJob (an integer). A job is
|
|
|
|
# returned as a three element list:
|
2022-07-14 21:09:56 +03:00
|
|
|
#
|
2023-08-27 00:04:54 +03:00
|
|
|
# {$build $config $file}
|
2022-07-14 21:09:56 +03:00
|
|
|
#
|
2023-08-27 00:04:54 +03:00
|
|
|
proc r_get_next_job {iJob} {
|
|
|
|
global T
|
2022-07-14 21:09:56 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
if {($iJob%2)} {
|
|
|
|
set orderby "ORDER BY priority ASC"
|
|
|
|
} else {
|
|
|
|
set orderby "ORDER BY priority DESC"
|
|
|
|
}
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set ret [list]
|
2022-07-14 21:09:56 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
r_write_db {
|
|
|
|
set query "
|
|
|
|
SELECT * FROM jobs AS j WHERE state='ready' $orderby LIMIT 1
|
|
|
|
"
|
|
|
|
trdb eval $query job {
|
|
|
|
set tm [clock_milliseconds]
|
|
|
|
set T($iJob) $tm
|
|
|
|
set jobid $job(jobid)
|
2023-08-22 18:19:50 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
trdb eval {
|
|
|
|
UPDATE jobs SET starttime=$tm, state='running' WHERE jobid=$jobid
|
|
|
|
}
|
2023-08-12 20:36:57 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set ret [array get job]
|
2023-08-12 20:36:57 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
}
|
2022-07-14 21:09:56 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
return $ret
|
|
|
|
}
|
2023-02-03 21:47:00 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
#rename r_get_next_job r_get_next_job_r
|
|
|
|
#proc r_get_next_job {iJob} {
|
|
|
|
#puts [time { set res [r_get_next_job_r $iJob] }]
|
|
|
|
#set res
|
|
|
|
#}
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# add_job OPTION ARG OPTION ARG...
|
|
|
|
#
|
|
|
|
# where available OPTIONS are:
|
|
|
|
#
|
|
|
|
# -displaytype
|
|
|
|
# -displayname
|
|
|
|
# -build
|
|
|
|
# -dirname
|
|
|
|
# -cmd
|
|
|
|
# -depid
|
|
|
|
# -priority
|
|
|
|
#
|
|
|
|
# Returns the jobid value for the new job.
|
|
|
|
#
|
|
|
|
proc add_job {args} {
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set options {
|
|
|
|
-displaytype -displayname -build -dirname
|
2023-08-28 19:28:00 +03:00
|
|
|
-cmd -depid -priority
|
2023-08-27 00:04:54 +03:00
|
|
|
}
|
2023-02-06 14:43:22 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
# Set default values of options.
|
|
|
|
set A(-dirname) ""
|
|
|
|
set A(-depid) ""
|
|
|
|
set A(-priority) 0
|
|
|
|
set A(-build) ""
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
array set A $args
|
2022-07-14 21:09:56 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
# Check all required options are present. And that no extras are present.
|
|
|
|
foreach o $options {
|
|
|
|
if {[info exists A($o)]==0} { error "missing required option $o" }
|
2022-07-14 21:09:56 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
foreach o [array names A] {
|
|
|
|
if {[lsearch -exact $options $o]<0} { error "unrecognized option: $o" }
|
2023-02-06 14:43:22 +03:00
|
|
|
}
|
2022-07-14 21:09:56 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set state ""
|
|
|
|
if {$A(-depid)==""} { set state ready }
|
|
|
|
|
|
|
|
trdb eval {
|
|
|
|
INSERT INTO jobs(
|
2023-08-28 19:28:00 +03:00
|
|
|
displaytype, displayname, build, dirname, cmd, depid, priority,
|
2023-08-27 00:04:54 +03:00
|
|
|
state
|
|
|
|
) VALUES (
|
|
|
|
$A(-displaytype),
|
|
|
|
$A(-displayname),
|
|
|
|
$A(-build),
|
|
|
|
$A(-dirname),
|
|
|
|
$A(-cmd),
|
|
|
|
$A(-depid),
|
|
|
|
$A(-priority),
|
|
|
|
$state
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
trdb last_insert_rowid
|
2023-02-01 23:14:59 +03:00
|
|
|
}
|
2022-07-14 21:09:56 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
proc add_tcl_jobs {build config patternlist} {
|
|
|
|
global TRG
|
|
|
|
|
|
|
|
set topdir [file dirname $::testdir]
|
|
|
|
set testrunner_tcl [file normalize [info script]]
|
2022-07-14 21:09:56 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
if {$build==""} {
|
|
|
|
set testfixture [info nameofexec]
|
|
|
|
} else {
|
|
|
|
set testfixture [file join [lindex $build 1] $TRG(testfixture)]
|
|
|
|
}
|
2023-08-28 14:22:33 +03:00
|
|
|
if {[lindex $build 2]=="Valgrind"} {
|
2023-08-28 19:28:00 +03:00
|
|
|
set setvar "export OMIT_MISUSE=1\n"
|
|
|
|
set testfixture "${setvar}valgrind -v --error-exitcode=1 $testfixture"
|
2023-08-28 14:22:33 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
|
|
|
|
# The ::testspec array is populated by permutations.test
|
|
|
|
foreach f [dict get $::testspec($config) -files] {
|
2023-02-01 23:14:59 +03:00
|
|
|
|
|
|
|
if {[llength $patternlist]>0} {
|
|
|
|
set bMatch 0
|
2022-07-14 21:09:56 +03:00
|
|
|
foreach p $patternlist {
|
2023-02-01 23:14:59 +03:00
|
|
|
if {[string match $p [file tail $f]]} {
|
2023-02-03 21:47:00 +03:00
|
|
|
set bMatch 1
|
2023-02-01 23:14:59 +03:00
|
|
|
break
|
2022-07-14 21:09:56 +03:00
|
|
|
}
|
|
|
|
}
|
2023-02-01 23:14:59 +03:00
|
|
|
if {$bMatch==0} continue
|
2022-07-14 21:09:56 +03:00
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
if {[file pathtype $f]!="absolute"} { set f [file join $::testdir $f] }
|
|
|
|
set f [file normalize $f]
|
|
|
|
|
|
|
|
set displayname [string map [list $topdir/ {}] $f]
|
|
|
|
if {$config=="full" || $config=="veryquick"} {
|
|
|
|
set cmd "$testfixture $f"
|
|
|
|
} else {
|
|
|
|
set cmd "$testfixture $testrunner_tcl $config $f"
|
|
|
|
set displayname "config=$config $displayname"
|
2023-02-01 23:14:59 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
if {$build!=""} {
|
|
|
|
set displayname "[lindex $build 2] $displayname"
|
|
|
|
}
|
|
|
|
|
|
|
|
set lProp [trd_test_script_properties $f]
|
|
|
|
set priority 0
|
|
|
|
if {[lsearch $lProp slow]>=0} { set priority 2 }
|
|
|
|
if {[lsearch $lProp superslow]>=0} { set priority 4 }
|
|
|
|
|
|
|
|
add_job \
|
|
|
|
-displaytype tcl \
|
|
|
|
-displayname $displayname \
|
|
|
|
-cmd $cmd \
|
|
|
|
-depid [lindex $build 0] \
|
|
|
|
-priority $priority
|
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
}
|
2022-07-14 21:09:56 +03:00
|
|
|
}
|
2023-02-01 23:14:59 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
proc add_build_job {buildname target} {
|
|
|
|
global TRG
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set dirname "[string tolower [string map {- _} $buildname]]_$target"
|
|
|
|
set dirname "testrunner_bld_$dirname"
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set id [add_job \
|
|
|
|
-displaytype bld \
|
|
|
|
-displayname "Build $buildname ($target)" \
|
|
|
|
-dirname $dirname \
|
|
|
|
-build $buildname \
|
|
|
|
-cmd "$TRG(makecmd) $target" \
|
|
|
|
-priority 3
|
|
|
|
]
|
|
|
|
|
|
|
|
list $id [file normalize $dirname] $buildname
|
2022-07-12 23:31:16 +03:00
|
|
|
}
|
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
proc add_make_job {bld target} {
|
|
|
|
global TRG
|
2022-07-18 22:32:30 +03:00
|
|
|
|
2023-08-28 19:28:00 +03:00
|
|
|
if {$TRG(platform)=="win"} {
|
2023-08-28 21:15:14 +03:00
|
|
|
set path [string map {/ \\} [lindex $bld 1]]
|
|
|
|
set cmd "xcopy /S $path\\* ."
|
2023-08-28 19:28:00 +03:00
|
|
|
} else {
|
|
|
|
set cmd "cp -r [lindex $bld 1]/* ."
|
|
|
|
}
|
|
|
|
append cmd "\n$TRG(makecmd) $target"
|
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
add_job \
|
|
|
|
-displaytype make \
|
|
|
|
-displayname "[lindex $bld 2] make $target" \
|
2023-08-28 19:28:00 +03:00
|
|
|
-cmd $cmd \
|
2023-08-27 00:04:54 +03:00
|
|
|
-depid [lindex $bld 0] \
|
|
|
|
-priority 1
|
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
proc add_fuzztest_jobs {buildname} {
|
|
|
|
|
|
|
|
foreach {interpreter scripts} [trd_fuzztest_data] {
|
|
|
|
set subcmd [lrange $interpreter 1 end]
|
|
|
|
set interpreter [lindex $interpreter 0]
|
|
|
|
|
|
|
|
set bld [add_build_job $buildname $interpreter]
|
|
|
|
foreach {depid dirname displayname} $bld {}
|
|
|
|
|
|
|
|
foreach s $scripts {
|
|
|
|
|
|
|
|
# Fuzz data files fuzzdata1.db and fuzzdata2.db are larger than
|
|
|
|
# the others. So ensure that these are run as a higher priority.
|
|
|
|
set tail [file tail $s]
|
|
|
|
if {$tail=="fuzzdata1.db" || $tail=="fuzzdata2.db"} {
|
|
|
|
set priority 5
|
|
|
|
} else {
|
|
|
|
set priority 1
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
|
|
|
|
add_job \
|
|
|
|
-displaytype fuzz \
|
|
|
|
-displayname "$buildname $interpreter $tail" \
|
|
|
|
-depid $depid \
|
|
|
|
-cmd "[file join $dirname $interpreter] $subcmd $s" \
|
|
|
|
-priority $priority
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
}
|
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
proc add_zipvfs_jobs {} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
2023-08-27 00:04:54 +03:00
|
|
|
source [file join $TRG(zipvfs) test zipvfs_testrunner.tcl]
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set bld [add_build_job Zipvfs $TRG(testfixture)]
|
|
|
|
foreach s [zipvfs_testrunner_files] {
|
|
|
|
set cmd "[file join [lindex $bld 1] $TRG(testfixture)] $s"
|
|
|
|
add_job \
|
|
|
|
-displaytype tcl \
|
|
|
|
-displayname "Zipvfs [file tail $s]" \
|
|
|
|
-cmd $cmd \
|
|
|
|
-depid [lindex $bld 0]
|
2023-08-24 22:08:50 +03:00
|
|
|
}
|
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set ::env(SQLITE_TEST_DIR) $::testdir
|
|
|
|
}
|
2023-02-14 21:09:40 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
proc add_jobs_from_cmdline {patternlist} {
|
|
|
|
global TRG
|
2023-02-04 21:47:59 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
if {$TRG(zipvfs)!=""} {
|
|
|
|
add_zipvfs_jobs
|
|
|
|
if {[llength $patternlist]==0} return
|
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
if {[llength $patternlist]==0} {
|
|
|
|
set patternlist [list veryquick]
|
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set first [lindex $patternlist 0]
|
|
|
|
switch -- $first {
|
|
|
|
all {
|
|
|
|
set patternlist [lrange $patternlist 1 end]
|
|
|
|
set clist [trd_all_configs]
|
|
|
|
foreach c $clist {
|
|
|
|
add_tcl_jobs "" $c $patternlist
|
2023-02-06 14:43:22 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
}
|
2023-02-06 14:43:22 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
mdevtest {
|
|
|
|
foreach b [list All-O0 All-Debug] {
|
|
|
|
set bld [add_build_job $b $TRG(testfixture)]
|
|
|
|
add_tcl_jobs $bld veryquick ""
|
|
|
|
add_fuzztest_jobs $b
|
2023-02-01 23:14:59 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
sdevtest {
|
|
|
|
foreach b [list All-Sanitize All-Debug] {
|
|
|
|
set bld [add_build_job $b $TRG(testfixture)]
|
|
|
|
add_tcl_jobs $bld veryquick ""
|
|
|
|
add_fuzztest_jobs $b
|
2023-02-03 21:47:00 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
}
|
2023-02-03 21:47:00 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
release {
|
|
|
|
foreach b [trd_builds $TRG(platform)] {
|
|
|
|
set bld [add_build_job $b $TRG(testfixture)]
|
|
|
|
foreach c [trd_configs $TRG(platform) $b] {
|
|
|
|
add_tcl_jobs $bld $c ""
|
|
|
|
}
|
2023-08-16 17:18:53 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
foreach e [trd_extras $TRG(platform) $b] {
|
|
|
|
if {$e=="fuzztest"} {
|
|
|
|
add_fuzztest_jobs $b
|
|
|
|
} else {
|
|
|
|
add_make_job $bld $e
|
|
|
|
}
|
|
|
|
}
|
2023-08-16 17:18:53 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
}
|
2023-08-16 17:18:53 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
default {
|
|
|
|
if {[info exists ::testspec($first)]} {
|
|
|
|
add_tcl_jobs "" $first [lrange $patternlist 1 end]
|
|
|
|
} else {
|
|
|
|
add_tcl_jobs "" full $patternlist
|
2023-02-01 23:14:59 +03:00
|
|
|
}
|
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
proc make_new_testset {} {
|
|
|
|
global TRG
|
|
|
|
|
|
|
|
r_write_db {
|
|
|
|
trdb eval $TRG(schema)
|
|
|
|
set nJob $TRG(nJob)
|
|
|
|
set cmdline $TRG(cmdline)
|
|
|
|
set tm [clock_milliseconds]
|
|
|
|
trdb eval { REPLACE INTO config VALUES('njob', $nJob ); }
|
|
|
|
trdb eval { REPLACE INTO config VALUES('cmdline', $cmdline ); }
|
|
|
|
trdb eval { REPLACE INTO config VALUES('start', $tm ); }
|
|
|
|
|
|
|
|
add_jobs_from_cmdline $TRG(patternlist)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
proc script_input_ready {fd iJob jobid} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
2023-02-01 23:14:59 +03:00
|
|
|
global O
|
|
|
|
global T
|
|
|
|
|
|
|
|
if {[eof $fd]} {
|
2023-08-27 00:04:54 +03:00
|
|
|
trdb eval { SELECT * FROM jobs WHERE jobid=$jobid } job {}
|
|
|
|
|
2023-08-28 19:28:00 +03:00
|
|
|
# If this job specified a directory name, then delete the run.sh/run.bat
|
|
|
|
# file from it before continuing. This is because the contents of this
|
|
|
|
# directory might be copied by some other job, and we don't want to copy
|
|
|
|
# the run.sh file in this case.
|
|
|
|
if {$job(dirname)!=""} {
|
|
|
|
file delete -force [file join $job(dirname) $TRG(run)]
|
|
|
|
}
|
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
set ::done 1
|
|
|
|
fconfigure $fd -blocking 1
|
|
|
|
set state "done"
|
|
|
|
set rc [catch { close $fd } msg]
|
|
|
|
if {$rc} {
|
2023-08-27 00:04:54 +03:00
|
|
|
if {[info exists TRG(reportlength)]} {
|
|
|
|
puts -nonewline "[string repeat " " $TRG(reportlength)]\r"
|
|
|
|
}
|
2023-08-28 19:28:00 +03:00
|
|
|
puts "FAILED: $job(displayname) ($iJob)"
|
2023-02-01 23:14:59 +03:00
|
|
|
set state "failed"
|
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set tm [clock_milliseconds]
|
|
|
|
set jobtm [expr {$tm - $job(starttime)}]
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
puts $TRG(log) "### $job(displayname) ${jobtm}ms ($state)"
|
2023-02-04 21:47:59 +03:00
|
|
|
puts $TRG(log) [string trim $O($iJob)]
|
2022-07-13 20:46:42 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
r_write_db {
|
|
|
|
set output $O($iJob)
|
2023-02-04 21:47:59 +03:00
|
|
|
trdb eval {
|
2023-08-27 00:04:54 +03:00
|
|
|
UPDATE jobs
|
|
|
|
SET output=$output, state=$state, endtime=$tm
|
|
|
|
WHERE jobid=$jobid;
|
|
|
|
UPDATE jobs SET state='ready' WHERE depid=$jobid;
|
2023-02-03 21:47:00 +03:00
|
|
|
}
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
|
|
|
|
2023-02-03 21:47:00 +03:00
|
|
|
dirs_freeDir $iJob
|
|
|
|
launch_some_jobs
|
2023-02-01 23:14:59 +03:00
|
|
|
incr ::wakeup
|
|
|
|
} else {
|
|
|
|
set rc [catch { gets $fd line } res]
|
|
|
|
if {$rc} {
|
|
|
|
puts "ERROR $res"
|
|
|
|
}
|
|
|
|
if {$res>=0} {
|
|
|
|
append O($iJob) "$line\n"
|
2022-07-12 23:31:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
proc dirname {ii} {
|
|
|
|
return "testdir$ii"
|
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
proc launch_another_job {iJob} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
2023-02-01 23:14:59 +03:00
|
|
|
global O
|
|
|
|
global T
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
set testfixture [info nameofexec]
|
2023-02-04 21:47:59 +03:00
|
|
|
set script $TRG(info_script)
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
set O($iJob) ""
|
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set jobdict [r_get_next_job $iJob]
|
|
|
|
if {$jobdict==""} { return 0 }
|
|
|
|
array set job $jobdict
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
set dir $job(dirname)
|
|
|
|
if {$dir==""} { set dir [dirname $iJob] }
|
|
|
|
create_or_clear_dir $dir
|
2023-02-03 21:47:00 +03:00
|
|
|
|
2023-08-27 00:04:54 +03:00
|
|
|
if {$job(build)!=""} {
|
|
|
|
set srcdir [file dirname $::testdir]
|
|
|
|
if {$job(build)=="Zipvfs"} {
|
2023-02-14 21:09:40 +03:00
|
|
|
set script [zipvfs_testrunner_script]
|
|
|
|
} else {
|
2023-08-27 00:04:54 +03:00
|
|
|
set bWin [expr {$TRG(platform)=="win"}]
|
|
|
|
set script [trd_buildscript $job(build) $srcdir $bWin]
|
2023-02-14 21:09:40 +03:00
|
|
|
}
|
2023-08-27 00:04:54 +03:00
|
|
|
set fd [open [file join $dir $TRG(make)] w]
|
2023-02-03 21:47:00 +03:00
|
|
|
puts $fd $script
|
|
|
|
close $fd
|
2023-08-27 00:04:54 +03:00
|
|
|
}
|
2023-02-03 21:47:00 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
set pwd [pwd]
|
|
|
|
cd $dir
|
2023-08-28 19:28:00 +03:00
|
|
|
set fd [open $TRG(run) w]
|
|
|
|
puts $fd $job(cmd)
|
|
|
|
close $fd
|
|
|
|
set fd [open "|$TRG(runcmd) 2>@1" r]
|
2023-02-01 23:14:59 +03:00
|
|
|
cd $pwd
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
fconfigure $fd -blocking false
|
2023-08-27 00:04:54 +03:00
|
|
|
fileevent $fd readable [list script_input_ready $fd $iJob $job(jobid)]
|
2023-02-03 21:47:00 +03:00
|
|
|
|
|
|
|
return 1
|
2022-07-12 23:31:16 +03:00
|
|
|
}
|
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
proc one_line_report {} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
2022-07-13 20:46:42 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
set tm [expr [clock_milliseconds] - $TRG(starttime)]
|
2023-02-06 17:48:02 +03:00
|
|
|
set tm [format "%d" [expr int($tm/1000.0 + 0.5)]]
|
2022-07-15 00:17:22 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
r_write_db {
|
2023-08-27 00:04:54 +03:00
|
|
|
trdb eval {
|
|
|
|
SELECT displaytype, state, count(*) AS cnt
|
|
|
|
FROM jobs
|
|
|
|
GROUP BY 1, 2
|
2023-02-01 23:14:59 +03:00
|
|
|
} {
|
2023-08-27 00:04:54 +03:00
|
|
|
set v($state,$displaytype) $cnt
|
|
|
|
incr t($displaytype) $cnt
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-03 21:47:00 +03:00
|
|
|
set text ""
|
2023-08-27 00:04:54 +03:00
|
|
|
foreach j [lsort [array names t]] {
|
|
|
|
foreach k {done failed running} { incr v($k,$j) 0 }
|
2023-02-03 21:47:00 +03:00
|
|
|
set fin [expr $v(done,$j) + $v(failed,$j)]
|
2023-10-21 14:34:59 +03:00
|
|
|
lappend text "${j}($fin/$t($j))"
|
|
|
|
if {$v(failed,$j)>0} {
|
|
|
|
lappend text "f$v(failed,$j)"
|
|
|
|
}
|
|
|
|
if {$v(running,$j)>0} {
|
|
|
|
lappend text "r$v(running,$j)"
|
|
|
|
}
|
2023-02-03 21:47:00 +03:00
|
|
|
}
|
2022-07-13 20:46:42 +03:00
|
|
|
|
2023-02-06 14:43:22 +03:00
|
|
|
if {[info exists TRG(reportlength)]} {
|
|
|
|
puts -nonewline "[string repeat " " $TRG(reportlength)]\r"
|
|
|
|
}
|
2023-10-21 14:34:59 +03:00
|
|
|
set report "${tm} [join $text { }]"
|
2023-02-06 14:43:22 +03:00
|
|
|
set TRG(reportlength) [string length $report]
|
2023-08-27 00:04:54 +03:00
|
|
|
if {[string length $report]<100} {
|
2023-02-06 17:48:02 +03:00
|
|
|
puts -nonewline "$report\r"
|
|
|
|
flush stdout
|
|
|
|
} else {
|
|
|
|
puts $report
|
|
|
|
}
|
2023-02-06 14:43:22 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
after $TRG(reporttime) one_line_report
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
|
|
|
|
2023-02-03 21:47:00 +03:00
|
|
|
proc launch_some_jobs {} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
2023-08-27 00:04:54 +03:00
|
|
|
set nJob [trdb one { SELECT value FROM config WHERE name='njob' }]
|
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
while {[dirs_nHelper]<$nJob} {
|
2023-02-03 21:47:00 +03:00
|
|
|
set iDir [dirs_allocDir]
|
|
|
|
if {0==[launch_another_job $iDir]} {
|
|
|
|
dirs_freeDir $iDir
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
proc run_testset {} {
|
2023-02-04 21:47:59 +03:00
|
|
|
global TRG
|
2023-02-01 23:14:59 +03:00
|
|
|
set ii 0
|
2022-07-13 20:46:42 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
set TRG(starttime) [clock_milliseconds]
|
|
|
|
set TRG(log) [open $TRG(logname) w]
|
2022-07-13 20:46:42 +03:00
|
|
|
|
2023-02-03 21:47:00 +03:00
|
|
|
launch_some_jobs
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
one_line_report
|
2023-02-04 21:47:59 +03:00
|
|
|
while {[dirs_nHelper]>0} {
|
2023-02-01 23:14:59 +03:00
|
|
|
after 500 {incr ::wakeup}
|
|
|
|
vwait ::wakeup
|
2022-07-12 23:31:16 +03:00
|
|
|
}
|
2023-02-04 21:47:59 +03:00
|
|
|
close $TRG(log)
|
2023-02-01 23:14:59 +03:00
|
|
|
one_line_report
|
2022-07-14 21:09:56 +03:00
|
|
|
|
2023-02-01 23:14:59 +03:00
|
|
|
r_write_db {
|
2023-08-12 20:36:57 +03:00
|
|
|
set tm [clock_milliseconds]
|
|
|
|
trdb eval { REPLACE INTO config VALUES('end', $tm ); }
|
2023-08-27 00:04:54 +03:00
|
|
|
set nErr [trdb one {SELECT count(*) FROM jobs WHERE state='failed'}]
|
2023-02-01 23:14:59 +03:00
|
|
|
if {$nErr>0} {
|
|
|
|
puts "$nErr failures:"
|
2023-02-04 21:47:59 +03:00
|
|
|
trdb eval {
|
2023-08-27 00:04:54 +03:00
|
|
|
SELECT displayname FROM jobs WHERE state='failed'
|
2023-02-01 23:14:59 +03:00
|
|
|
} {
|
2023-08-27 00:04:54 +03:00
|
|
|
puts "FAILED: $displayname"
|
2023-02-01 23:14:59 +03:00
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-05 03:32:32 +03:00
|
|
|
puts "\nTest database is $TRG(dbname)"
|
2023-02-04 21:47:59 +03:00
|
|
|
puts "Test log is $TRG(logname)"
|
2022-07-13 20:46:42 +03:00
|
|
|
}
|
2022-07-12 23:31:16 +03:00
|
|
|
|
2023-02-04 21:47:59 +03:00
|
|
|
|
|
|
|
sqlite3 trdb $TRG(dbname)
|
|
|
|
trdb timeout $TRG(timeout)
|
2023-02-01 23:14:59 +03:00
|
|
|
set tm [lindex [time { make_new_testset }] 0]
|
2023-02-24 16:45:51 +03:00
|
|
|
if {$TRG(nJob)>1} {
|
2023-08-24 22:08:50 +03:00
|
|
|
puts "splitting work across $TRG(nJob) jobs"
|
2023-02-24 16:45:51 +03:00
|
|
|
}
|
2023-02-01 23:14:59 +03:00
|
|
|
puts "built testset in [expr $tm/1000]ms.."
|
|
|
|
run_testset
|
2023-02-04 21:47:59 +03:00
|
|
|
trdb close
|
2023-02-01 23:14:59 +03:00
|
|
|
#puts [pwd]
|