Update the releasetest.tcl script so that it can run multiple tests in

parallel in separate processes.

FossilOrigin-Name: e3de82919d6f7ef5c2c5ab9a932a480604856950
This commit is contained in:
drh
2015-11-03 14:49:35 +00:00
4 changed files with 251 additions and 70 deletions
+9 -8
View File
@@ -1,5 +1,5 @@
C On\sunix,\sif\sa\sfile\sis\sopened\svia\sa\ssymlink,\screate,\sread\sand\swrite\sjournal\sand\swal\sfiles\sbased\son\sthe\sname\sof\sthe\sactual\sdb\sfile,\snot\sthe\ssymlink.
D 2015-11-02T15:08:56.877
C Update\sthe\sreleasetest.tcl\sscript\sso\sthat\sit\scan\srun\smultiple\stests\sin\s\nparallel\sin\sseparate\sprocesses.
D 2015-11-03T14:49:35.919
F Makefile.in 4469ed8b02a9934fea9503d791165367d19db2f7
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4
@@ -480,7 +480,7 @@ F test/backup_ioerr.test 4c3c7147cee85b024ecf6e150e090c32fdbb5135
F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450
F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f
F test/badutf2.test f5bc7f2d280670ecd79b9cf4f0f1760c607fe51f
F test/bc_common.tcl 5c8689cc6d2fb44b7c0968ae4f85eb26d50022fa
F test/bc_common.tcl 3eda41ef9cda7d5f6c205462c96228b301da4191
F test/between.test 34d375fb5ce1ae283ffe82b6b233e9f38e84fc6c
F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59
F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc
@@ -948,7 +948,7 @@ F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736
F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8
F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8
F test/reindex.test 44edd3966b474468b823d481eafef0c305022254
F test/releasetest.tcl 67a82199e6ddee609211488bc04ed3f9ea3aa28a
F test/releasetest.tcl c4f9bc9ef7e4b52b5b0f4a4dc304f048f9f67500
F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea
F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14
@@ -1398,7 +1398,8 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P db319a035feeb6f8fcd04f90fb10cd4b06e68184 c7c8105099c0412ac6c605f98987092c10bde57c
R d67684ec76cb9980f2fad9cc50640002
U dan
Z f0eb56e4c62ba83d5d97aac57baaa5e0
P 6d5ce3ede4c7038c19a77268a5a7b9d5650933c2 0d8b59783e0a84bc59661b3469e1ca1b1fa90c71
R 8a201b5bd814ee8b7a884b9405d8d10a
T +closed 0d8b59783e0a84bc59661b3469e1ca1b1fa90c71
U drh
Z b983fd166efa43546f60974df0033637
+1 -1
View File
@@ -1 +1 @@
6d5ce3ede4c7038c19a77268a5a7b9d5650933c2
e3de82919d6f7ef5c2c5ab9a932a480604856950
+3 -1
View File
@@ -7,11 +7,13 @@ proc bc_find_binaries {zCaption} {
# against.
#
set binaries [list]
set pattern "[file tail [info nameofexec]]?*"
set self [file tail [info nameofexec]]
set pattern "$self?*"
if {$::tcl_platform(platform)=="windows"} {
set pattern [string map {\.exe {}} $pattern]
}
foreach file [glob -nocomplain $pattern] {
if {$file==$self} continue
if {[file executable $file] && [file isfile $file]} {lappend binaries $file}
}
+238 -60
View File
@@ -19,6 +19,7 @@ optional) are:
--dryrun (Print what would have happened)
--info (Show diagnostic info)
--with-tcl=DIR (Use TCL build at DIR)
--jobs N (Use N processes - default 1)
The default value for --srcdir is the parent of the directory holding
this script.
@@ -285,6 +286,9 @@ array set ::Platforms [strip_comments {
#########################################################################
#########################################################################
# Configuration verification: Check that each entry in the list of configs
# specified for each platforms exists.
#
foreach {key value} [array get ::Platforms] {
foreach {v t} $value {
if {0==[info exists ::Configs($v)]} {
@@ -386,12 +390,165 @@ proc count_tests_and_errors {logfile rcVar errmsgVar} {
}
}
proc run_test_suite {name testtarget config} {
#--------------------------------------------------------------------------
# This command is invoked as the [main] routine for scripts run with the
# "--slave" option.
#
# For each test (i.e. "configure && make test" execution), the master
# process spawns a process with the --slave option. It writes two lines
# to the slaves stdin. The first contains a single boolean value - the
# value of ::TRACE to use in the slave script. The second line contains a
# list in the same format as each element of the list passed to the
# [run_all_test_suites] command in the master process.
#
# The slave then runs the "configure && make test" commands specified. It
# exits successfully if the tests passes, or with a non-zero error code
# otherwise.
#
proc run_slave_test {} {
# Read global vars configuration from stdin.
set V [gets stdin]
foreach {::TRACE ::MSVC ::DRYRUN} $V {}
# Read the test-suite configuration from stdin.
set T [gets stdin]
foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
# Create and switch to the test directory.
trace_cmd file mkdir $dir
trace_cmd cd $dir
catch {file delete core}
catch {file delete test.log}
# Run the "./configure && make" commands.
set rc 0
set rc [catch [configureCommand $configOpts]]
if {!$rc} {
if {[info exists ::env(TCLSH_CMD)]} {
set savedEnv(TCLSH_CMD) $::env(TCLSH_CMD)
} else {
unset -nocomplain savedEnv(TCLSH_CMD)
}
set ::env(TCLSH_CMD) [file nativename [info nameofexecutable]]
set rc [catch [makeCommand $testtarget $makeOpts $cflags $opts]]
if {[info exists savedEnv(TCLSH_CMD)]} {
set ::env(TCLSH_CMD) $savedEnv(TCLSH_CMD)
} else {
unset -nocomplain ::env(TCLSH_CMD)
}
}
# Exis successfully if the test passed, or with a non-zero error code
# otherwise.
exit $rc
}
# This command is invoked in the master process each time a slave
# file-descriptor is readable.
#
proc slave_fileevent {fd T tm1} {
global G
foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
if {[eof $fd]} {
fconfigure $fd -blocking 1
set rc [catch { close $fd }]
set errmsg {}
set logfile [file join $dir test.log]
if {[file exists $logfile]} {
count_tests_and_errors [file join $dir test.log] rc errmsg
} elseif {$rc==0} {
set rc 1
set errmsg "no test.log file..."
}
if {!$::TRACE} {
set tm2 [clock seconds]
set hours [expr {($tm2-$tm1)/3600}]
set minutes [expr {(($tm2-$tm1)/60)%60}]
set seconds [expr {($tm2-$tm1)%60}]
set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
if {$rc} {
set status FAIL
incr ::NERR
} else {
set status Ok
}
set n [string length $title]
PUTS "finished: ${title}[string repeat . [expr {53-$n}]] $status $tm"
if {$errmsg!=""} {PUTS " $errmsg"}
flush stdout
}
incr G(nJob) -1
} else {
set line [gets $fd]
if {[string trim $line] != ""} {
puts "Trace : $title - \"$line\""
}
}
}
#--------------------------------------------------------------------------
# The only argument passed to this function is a list of test-suites to
# run. Each "test-suite" is itself a list consisting of the following
# elements:
#
# * Test title (for display).
# * The name of the directory to run the test in.
# * The argument for [configureCommand]
# * The first argument for [makeCommand]
# * The second argument for [makeCommand]
# * The third argument for [makeCommand]
#
proc run_all_test_suites {alltests} {
global G
set tests $alltests
set G(nJob) 0
while {[llength $tests]>0 || $G(nJob)>0} {
if {$G(nJob)>=$::JOBS || [llength $tests]==0} {
vwait G(nJob)
}
if {[llength $tests]>0} {
set T [lindex $tests 0]
set tests [lrange $tests 1 end]
foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
if {!$::TRACE} {
set n [string length $title]
PUTS "starting: ${title}"
flush stdout
}
# Run the job.
#
set tm1 [clock seconds]
incr G(nJob)
set script [file normalize [info script]]
set fd [open "|[info nameofexecutable] $script --slave" r+]
fconfigure $fd -blocking 0
fileevent $fd readable [list slave_fileevent $fd $T $tm1]
puts $fd [list $::TRACE $::MSVC $::DRYRUN]
puts $fd [list {*}$T]
flush $fd
}
}
}
proc add_test_suite {listvar name testtarget config} {
upvar $listvar alltests
# Tcl variable $opts is used to build up the value used to set the
# OPTS Makefile variable. Variable $cflags holds the value for
# CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
# CFLAGS is only passed to gcc.
#
set makeOpts ""
set cflags [expr {$::MSVC ? "-Zi" : "-g"}]
set opts ""
set title ${name}($testtarget)
@@ -404,67 +561,74 @@ proc run_test_suite {name testtarget config} {
} elseif {[regexp {^[A-Z]+=} $arg]} {
lappend testtarget $arg
} elseif {[regexp {^--(enable|disable)-} $arg]} {
if {$::MSVC} {
if {$arg eq "--disable-amalgamation"} {
lappend makeOpts USE_AMALGAMATION=0
continue
}
if {$arg eq "--disable-shared"} {
lappend makeOpts USE_CRT_DLL=0 DYNAMIC_SHELL=0
continue
}
if {$arg eq "--enable-fts5"} {
lappend opts -DSQLITE_ENABLE_FTS5
continue
}
if {$arg eq "--enable-json1"} {
lappend opts -DSQLITE_ENABLE_JSON1
continue
}
if {$arg eq "--enable-shared"} {
lappend makeOpts USE_CRT_DLL=1 DYNAMIC_SHELL=1
continue
}
}
lappend configOpts $arg
} else {
if {$::MSVC} {
if {$arg eq "-g"} {
lappend cflags -Zi
continue
}
if {[regexp -- {^-O(\d+)$} $arg all level]} then {
lappend makeOpts OPTIMIZATIONS=$level
continue
}
}
lappend cflags $arg
}
}
set cflags [join $cflags " "]
set opts [join $opts " "]
append opts " -DSQLITE_NO_SYNC=1"
# Disable sync to make testing faster.
#
lappend opts -DSQLITE_NO_SYNC=1
# Some configurations already set HAVE_USLEEP; in that case, skip it.
#
if {![regexp { -DHAVE_USLEEP$} $opts]
&& ![regexp { -DHAVE_USLEEP[ =]+} $opts]} {
append opts " -DHAVE_USLEEP=1"
if {[lsearch -regexp $opts {^-DHAVE_USLEEP(?:=|$)}]==-1} {
lappend opts -DHAVE_USLEEP=1
}
# Add the define for this platform.
#
if {$::tcl_platform(platform)=="windows"} {
lappend opts -DSQLITE_OS_WIN=1
} else {
lappend opts -DSQLITE_OS_UNIX=1
}
# Set the sub-directory to use.
#
set dir [string tolower [string map {- _ " " _} $name]]
if {$::tcl_platform(platform)=="windows"} {
append opts " -DSQLITE_OS_WIN=1"
} else {
append opts " -DSQLITE_OS_UNIX=1"
}
# Join option lists into strings, using space as delimiter.
#
set makeOpts [join $makeOpts " "]
set cflags [join $cflags " "]
set opts [join $opts " "]
if {!$::TRACE} {
set n [string length $title]
PUTS -nonewline "${title}[string repeat . [expr {63-$n}]]"
flush stdout
}
set rc 0
set tm1 [clock seconds]
set origdir [pwd]
trace_cmd file mkdir $dir
trace_cmd cd $dir
set errmsg {}
catch {file delete core}
set rc [catch [configureCommand $configOpts]]
if {!$rc} {
set rc [catch [makeCommand $testtarget $cflags $opts]]
count_tests_and_errors test.log rc errmsg
}
trace_cmd cd $origdir
set tm2 [clock seconds]
if {!$::TRACE} {
set hours [expr {($tm2-$tm1)/3600}]
set minutes [expr {(($tm2-$tm1)/60)%60}]
set seconds [expr {($tm2-$tm1)%60}]
set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
if {$rc} {
PUTS " FAIL $tm"
incr ::NERR
} else {
PUTS " Ok $tm"
}
if {$errmsg!=""} {PUTS " $errmsg"}
}
lappend alltests [list \
$title $dir $configOpts $testtarget $makeOpts $cflags $opts]
}
# The following procedure returns the "configure" command to be exectued for
@@ -484,15 +648,19 @@ proc configureCommand {opts} {
# The following procedure returns the "make" command to be executed for the
# specified targets, compiler flags, and options.
#
proc makeCommand { targets cflags opts } {
proc makeCommand { targets makeOpts cflags opts } {
set result [list trace_cmd exec]
if {$::MSVC} {
set nmakeDir [file nativename $::SRCDIR]
set nmakeFile [file join $nmakeDir Makefile.msc]
lappend result nmake /f $nmakeFile TOP=$nmakeDir clean
set nmakeFile [file nativename [file join $nmakeDir Makefile.msc]]
lappend result nmake /f $nmakeFile TOP=$nmakeDir
} else {
lappend result make clean
lappend result make
}
foreach makeOpt $makeOpts {
lappend result $makeOpt
}
lappend result clean
foreach target $targets {
lappend result $target
}
@@ -507,9 +675,11 @@ proc trace_cmd {args} {
if {$::TRACE} {
PUTS $args
}
set res ""
if {!$::DRYRUN} {
uplevel 1 $args
set res [uplevel 1 $args]
}
return $res
}
@@ -524,8 +694,8 @@ proc process_options {argv} {
set ::MSVC 0
set ::BUILDONLY 0
set ::DRYRUN 0
set ::EXEC exec
set ::TRACE 0
set ::JOBS 1
set ::WITHTCL {}
set config {}
set platform $::tcl_platform(os)-$::tcl_platform(machine)
@@ -534,6 +704,11 @@ proc process_options {argv} {
set x [lindex $argv $i]
if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}
switch -glob -- $x {
-slave {
run_slave_test
exit
}
-srcdir {
incr i
set ::SRCDIR [file normalize [lindex $argv $i]]
@@ -544,6 +719,11 @@ proc process_options {argv} {
set platform [lindex $argv $i]
}
-jobs {
incr i
set ::JOBS [lindex $argv $i]
}
-quick {
set ::QUICK 1
}
@@ -597,11 +777,7 @@ proc process_options {argv} {
}
-g {
if {$::MSVC} {
lappend ::EXTRACONFIG -Zi
} else {
lappend ::EXTRACONFIG [lindex $argv $i]
}
lappend ::EXTRACONFIG [lindex $argv $i]
}
-with-tcl=* {
@@ -689,7 +865,7 @@ proc main {argv} {
set config_options [concat $::Configs($zConfig) $::EXTRACONFIG]
incr NTEST
run_test_suite $zConfig $target $config_options
add_test_suite all $zConfig $target $config_options
# If the configuration included the SQLITE_DEBUG option, then remove
# it and run veryquick.test. If it did not include the SQLITE_DEBUG option
@@ -703,16 +879,18 @@ proc main {argv} {
if {$debug_idx < 0} {
incr NTEST
append config_options " -DSQLITE_DEBUG=1"
run_test_suite "${zConfig}_debug" $xtarget $config_options
add_test_suite all "${zConfig}_debug" $xtarget $config_options
} else {
incr NTEST
regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options
regsub { *-DSQLITE_DEBUG[^ ]* *} $config_options { } config_options
run_test_suite "${zConfig}_ndebug" $xtarget $config_options
add_test_suite all "${zConfig}_ndebug" $xtarget $config_options
}
}
}
run_all_test_suites $all
set elapsetime [expr {[clock seconds]-$STARTTIME}]
set hr [expr {$elapsetime/3600}]
set min [expr {($elapsetime/60)%60}]