/ Check-in [3d29f912]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the "--jobs N" option to the releasetest.tcl script to allow tests to be run in parallel by N processes. N defaults to 1.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mp-releasetest
Files: files | file ages | folders
SHA1: 3d29f912cb7c6ee3e4903b1b14dd7ae82e4d02b1
User & Date: dan 2015-11-02 18:32:00
Context
2015-11-02
20:24
Fix releasetest.tcl so that output lines are less than 80 characters wide. check-in: aef177fe user: dan tags: mp-releasetest
18:32
Add the "--jobs N" option to the releasetest.tcl script to allow tests to be run in parallel by N processes. N defaults to 1. check-in: 3d29f912 user: dan tags: mp-releasetest
2015-11-01
21:19
If a table-constraint PRIMARY KEY lists a single column in single-quotes and that column has type INTEGER, then make that column an integer primary key, for historical compatibility. Fix for ticket [ac661962a2aeab3c331]. check-in: db319a03 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/releasetest.tcl.

   281    281   }]
   282    282   
   283    283   
   284    284   # End of configuration section.
   285    285   #########################################################################
   286    286   #########################################################################
   287    287   
          288  +# Configuration verification: Check that each entry in the list of configs 
          289  +# specified for each platforms exists.
          290  +#
   288    291   foreach {key value} [array get ::Platforms] {
   289    292     foreach {v t} $value {
   290    293       if {0==[info exists ::Configs($v)]} {
   291    294         puts stderr "No such configuration: \"$v\""
   292    295         exit -1
   293    296       }
   294    297     }
................................................................................
   382    385       set errmsg "Test did not complete"
   383    386       if {[file readable core]} {
   384    387         append errmsg " - core file exists"
   385    388       }
   386    389     }
   387    390   }
   388    391   
   389         -proc run_test_suite {name testtarget config} {
          392  +#--------------------------------------------------------------------------
          393  +# This command is invoked as the [main] routine for scripts run with the
          394  +# "--slave" option. 
          395  +#
          396  +# For each test (i.e. "configure && make test" execution), the master
          397  +# process spawns a process with the --slave option. It writes two lines
          398  +# to the slaves stdin. The first contains a single boolean value - the 
          399  +# value of ::TRACE to use in the slave script. The second line contains a 
          400  +# list in the same format as each element of the list passed to the
          401  +# [run_all_test_suites] command in the master process.
          402  +#
          403  +# The slave then runs the "configure && make test" commands specified. It
          404  +# exits successfully if the tests passes, or with a non-zero error code
          405  +# otherwise.
          406  +#
          407  +proc run_slave_test {} {
          408  +  # Read global vars configuration from stdin.
          409  +  set V [gets stdin]
          410  +  foreach {::TRACE} $V {}
          411  +
          412  +  # Read the test-suite configuration from stdin.
          413  +  set T [gets stdin]
          414  +  foreach {title dir configOpts testtarget cflags opts} $T {}
          415  +
          416  +  # Create and switch to the test directory.
          417  +  trace_cmd file mkdir $dir
          418  +  trace_cmd cd $dir
          419  +  catch {file delete core}
          420  +  catch {file delete test.log}
          421  +
          422  +  # Run the "./configure && make" commands.
          423  +  set rc 0
          424  +  set rc [catch [configureCommand $configOpts]]
          425  +  if {!$rc} {
          426  +    set rc [catch [makeCommand $testtarget $cflags $opts]]
          427  +  }
          428  +
          429  +  # Exis successfully if the test passed, or with a non-zero error code
          430  +  # otherwise.
          431  +  exit $rc
          432  +}
          433  +
          434  +# This command is invoked in the master process each time a slave 
          435  +# file-descriptor is readable.
          436  +#
          437  +proc slave_fileevent {fd T tm1} {
          438  +  global G
          439  +  foreach {title dir configOpts testtarget cflags opts} $T {}
          440  +
          441  +  if {[eof $fd]} {
          442  +    fconfigure $fd -blocking 1
          443  +    set rc [catch { close $fd }]
          444  +
          445  +    set errmsg {}
          446  +    count_tests_and_errors [file join $dir test.log] rc errmsg
          447  +
          448  +    if {!$::TRACE} {
          449  +      set tm2 [clock seconds]
          450  +      set hours [expr {($tm2-$tm1)/3600}]
          451  +      set minutes [expr {(($tm2-$tm1)/60)%60}]
          452  +      set seconds [expr {($tm2-$tm1)%60}]
          453  +      set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
          454  +
          455  +      if {$rc} {
          456  +        set status FAIL
          457  +        incr ::NERR
          458  +      } else {
          459  +        set status Ok
          460  +      }
          461  +
          462  +      set n [string length $title]
          463  +      PUTS "finished: ${title}[string repeat . [expr {63-$n}]] $status $tm"
          464  +      if {$errmsg!=""} {PUTS "     $errmsg"}
          465  +      flush stdout
          466  +    }
          467  +
          468  +    incr G(nJob) -1
          469  +  } else {
          470  +    set line [gets $fd]
          471  +    if {[string trim $line] != ""} {
          472  +      puts "Trace   : $title - \"$line\""
          473  +    }
          474  +  }
          475  +}
          476  +
          477  +#--------------------------------------------------------------------------
          478  +# The only argument passed to this function is a list of test-suites to
          479  +# run. Each "test-suite" is itself a list consisting of the following
          480  +# elements:
          481  +#
          482  +#   * Test title (for display).
          483  +#   * The name of the directory to run the test in.
          484  +#   * The argument for [configureCommand]
          485  +#   * The first argument for [makeCommand]
          486  +#   * The second argument for [makeCommand]
          487  +#   * The third argument for [makeCommand]
          488  +#   
          489  +proc run_all_test_suites {alltests} {
          490  +  global G
          491  +  set tests $alltests
          492  +
          493  +  set G(nJob) 0
          494  +
          495  +  while {[llength $tests]>0 || $G(nJob)>0} {
          496  +    if {$G(nJob)>=$::JOBS || [llength $tests]==0} {
          497  +      vwait G(nJob)
          498  +    }
          499  +
          500  +    if {[llength $tests]>0} {
          501  +      set T [lindex $tests 0]
          502  +      set tests [lrange $tests 1 end]
          503  +      foreach {title dir configOpts testtarget cflags opts} $T {}
          504  +      if {!$::TRACE} {
          505  +        set n [string length $title]
          506  +        PUTS "starting: ${title}"
          507  +        flush stdout
          508  +      }
          509  +
          510  +      # Run the job.
          511  +      #
          512  +      set tm1 [clock seconds]
          513  +      incr G(nJob)
          514  +      set fd [open "|[info nameofexecutable] [info script] --slave" r+]
          515  +      fconfigure $fd -blocking 0
          516  +      fileevent $fd readable [list slave_fileevent $fd $T $tm1]
          517  +      puts $fd [list $::TRACE]
          518  +      puts $fd [list {*}$T]
          519  +      flush $fd
          520  +    }
          521  +  }
          522  +}
          523  +
          524  +proc add_test_suite {listvar name testtarget config} {
          525  +  upvar $listvar alltests
          526  +
   390    527     # Tcl variable $opts is used to build up the value used to set the
   391    528     # OPTS Makefile variable. Variable $cflags holds the value for
   392    529     # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
   393    530     # CFLAGS is only passed to gcc.
   394    531     #
   395    532     set cflags [expr {$::MSVC ? "-Zi" : "-g"}]
   396    533     set opts ""
................................................................................
   427    564   
   428    565     if {$::tcl_platform(platform)=="windows"} {
   429    566       append opts " -DSQLITE_OS_WIN=1"
   430    567     } else {
   431    568       append opts " -DSQLITE_OS_UNIX=1"
   432    569     }
   433    570   
   434         -  if {!$::TRACE} {
   435         -    set n [string length $title]
   436         -    PUTS -nonewline "${title}[string repeat . [expr {63-$n}]]"
   437         -    flush stdout
   438         -  }
   439         -
   440         -  set rc 0
   441         -  set tm1 [clock seconds]
   442         -  set origdir [pwd]
   443         -  trace_cmd file mkdir $dir
   444         -  trace_cmd cd $dir
   445         -  set errmsg {}
   446         -  catch {file delete core}
   447         -  set rc [catch [configureCommand $configOpts]]
   448         -  if {!$rc} {
   449         -    set rc [catch [makeCommand $testtarget $cflags $opts]]
   450         -    count_tests_and_errors test.log rc errmsg
   451         -  }
   452         -  trace_cmd cd $origdir
   453         -  set tm2 [clock seconds]
   454         -
   455         -  if {!$::TRACE} {
   456         -    set hours [expr {($tm2-$tm1)/3600}]
   457         -    set minutes [expr {(($tm2-$tm1)/60)%60}]
   458         -    set seconds [expr {($tm2-$tm1)%60}]
   459         -    set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
   460         -    if {$rc} {
   461         -      PUTS " FAIL $tm"
   462         -      incr ::NERR
   463         -    } else {
   464         -      PUTS " Ok   $tm"
   465         -    }
   466         -    if {$errmsg!=""} {PUTS "     $errmsg"}
   467         -  }
          571  +  lappend alltests [list $title $dir $configOpts $testtarget $cflags $opts]
   468    572   }
   469    573   
   470    574   # The following procedure returns the "configure" command to be exectued for
   471    575   # the current platform, which may be Windows (via MinGW, etc).
   472    576   #
   473    577   proc configureCommand {opts} {
   474    578     if {$::MSVC} return [list]; # This is not needed for MSVC.
................................................................................
   503    607   # And it executes the command of its arguments in the calling context
   504    608   # if ::DRYRUN is false.
   505    609   #
   506    610   proc trace_cmd {args} {
   507    611     if {$::TRACE} {
   508    612       PUTS $args
   509    613     }
          614  +  set res ""
   510    615     if {!$::DRYRUN} {
   511         -    uplevel 1 $args
          616  +    set res [uplevel 1 $args]
   512    617     }
          618  +  return $res
   513    619   }
   514    620   
   515    621   
   516    622   # This proc processes the command line options passed to this script.
   517    623   # Currently the only option supported is "-makefile", default
   518    624   # "releasetest.mk". Set the ::MAKEFILE variable to the value of this
   519    625   # option.
................................................................................
   522    628     set ::SRCDIR    [file normalize [file dirname [file dirname $::argv0]]]
   523    629     set ::QUICK     0
   524    630     set ::MSVC      0
   525    631     set ::BUILDONLY 0
   526    632     set ::DRYRUN    0
   527    633     set ::EXEC      exec
   528    634     set ::TRACE     0
          635  +  set ::JOBS      1
   529    636     set ::WITHTCL   {}
   530    637     set config {}
   531    638     set platform $::tcl_platform(os)-$::tcl_platform(machine)
   532    639   
   533    640     for {set i 0} {$i < [llength $argv]} {incr i} {
   534    641       set x [lindex $argv $i]
   535    642       if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}
   536    643       switch -glob -- $x {
          644  +      -slave {
          645  +        run_slave_test
          646  +        exit
          647  +      }
          648  +
   537    649         -srcdir {
   538    650           incr i
   539    651           set ::SRCDIR [file normalize [lindex $argv $i]]
   540    652         }
   541    653   
   542    654         -platform {
   543    655           incr i
   544    656           set platform [lindex $argv $i]
   545    657         }
          658  +
          659  +      -jobs {
          660  +        incr i
          661  +        set ::JOBS [lindex $argv $i]
          662  +      }
   546    663   
   547    664         -quick {
   548    665           set ::QUICK 1
   549    666         }
   550    667         -veryquick {
   551    668           set ::QUICK 2
   552    669         }
................................................................................
   685    802           set target testfixture
   686    803           if {$::MSVC} {append target .exe}
   687    804         }
   688    805       }
   689    806       set config_options [concat $::Configs($zConfig) $::EXTRACONFIG]
   690    807   
   691    808       incr NTEST
   692         -    run_test_suite $zConfig $target $config_options
          809  +    add_test_suite all $zConfig $target $config_options
   693    810   
   694    811       # If the configuration included the SQLITE_DEBUG option, then remove
   695    812       # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
   696    813       # add it and run veryquick.test.
   697    814       if {$target!="checksymbols" && $target!="valgrindtest"
   698    815              && $target!="fuzzoomtest" && !$::BUILDONLY && $::QUICK<2} {
   699    816         set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
   700    817         set xtarget $target
   701    818         regsub -all {fulltest[a-z]*} $xtarget test xtarget
   702    819         regsub -all {fuzzoomtest} $xtarget fuzztest xtarget
   703    820         if {$debug_idx < 0} {
   704    821           incr NTEST
   705    822           append config_options " -DSQLITE_DEBUG=1"
   706         -        run_test_suite "${zConfig}_debug" $xtarget $config_options
          823  +        add_test_suite all "${zConfig}_debug" $xtarget $config_options
   707    824         } else {
   708    825           incr NTEST
   709    826           regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options
   710    827           regsub { *-DSQLITE_DEBUG[^ ]* *} $config_options { } config_options
   711         -        run_test_suite "${zConfig}_ndebug" $xtarget $config_options
          828  +        add_test_suite all "${zConfig}_ndebug" $xtarget $config_options
   712    829         }
   713    830       }
   714    831     }
          832  +
          833  +  run_all_test_suites $all
   715    834   
   716    835     set elapsetime [expr {[clock seconds]-$STARTTIME}]
   717    836     set hr [expr {$elapsetime/3600}]
   718    837     set min [expr {($elapsetime/60)%60}]
   719    838     set sec [expr {$elapsetime%60}]
   720    839     set etime [format (%02d:%02d:%02d) $hr $min $sec]
   721    840     PUTS [string repeat * 79]