/ Check-in [7c85e831]
Login

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

Overview
Comment:Rework the test/releasetest.tcl script so that it uses the autoconf makefile instead of the test/releasetest.mk makefile. Also add options like --dryrun and --buildonly. Omit the --makefile option and replace it with --srcdir with the default computed relative to the releasetest.tcl script itself.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | releasetest-refactor
Files: files | file ages | folders
SHA1:7c85e831153f9aef2afaf981d53db38a28091be5
User & Date: drh 2014-12-23 19:40:51
Context
2014-12-23
19:52
Add the "checksymbols" target to Makefile.in check-in: 5bd73dba user: drh tags: releasetest-refactor
19:40
Rework the test/releasetest.tcl script so that it uses the autoconf makefile instead of the test/releasetest.mk makefile. Also add options like --dryrun and --buildonly. Omit the --makefile option and replace it with --srcdir with the default computed relative to the releasetest.tcl script itself. check-in: 7c85e831 user: drh tags: releasetest-refactor
2014-12-22
22:02
Fix a typo in an evidence mark on a test script. No changes to code. check-in: a08b0c75 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Deleted test/releasetest.mk.

     1         -########################################################
     2         -TOP=/home/drh/sqlite/sqlite
     3         -
     4         -TCL_FLAGS=-I/home/drh/tcltk/86linux
     5         -LIBTCL=/home/drh/tcltk/86linux/libtcl8.6.a -lm -ldl -lpthread
     6         -
     7         -BCC = gcc
     8         -TCC = gcc -ansi -g $(CFLAGS)
     9         -NAWK   = awk
    10         -AR     = ar cr
    11         -RANLIB = ranlib
    12         -THREADLIB = -lpthread -ldl -lz
    13         -include $(TOP)/main.mk
    14         -########################################################

Changes to test/releasetest.tcl.

     1         -
     2         -set rcsid {$Id: $}
     3         -
            1  +#!/usr/bin/tclsh
            2  +#
     4      3   # Documentation for this script. This may be output to stderr
     5      4   # if the script is invoked incorrectly. See the [process_options]
     6      5   # proc below.
     7      6   #
     8      7   set ::USAGE_MESSAGE {
     9      8   This Tcl script is used to test the various configurations required
    10      9   before releasing a new version. Supported command line options (all 
    11     10   optional) are:
    12     11   
    13         -    -makefile PATH-TO-MAKEFILE           (default "releasetest.mk")
    14         -    -platform PLATFORM                   (see below)
    15         -    -quick    BOOLEAN                    (default "0")
    16         -    -config   CONFIGNAME                 (Run only CONFIGNAME)
           12  +    --srcdir   TOP-OF-SQLITE-TREE      (see below)
           13  +    --platform PLATFORM                (see below)
           14  +    --config   CONFIGNAME              (Run only CONFIGNAME)
           15  +    --quick                            (Run "veryquick.test" only)
           16  +    --buildonly                        (Just build testfixture - do not run)
           17  +    --dryrun                           (Print what would have happened)      
           18  +    --info                             (Show diagnostic info)
    17     19   
    18         -The default value for -makefile is "./releasetest.mk".
           20  +The default value for --srcdir is the parent of the directory holding
           21  +this script.
    19     22   
    20         -The script determines the default value for -platform using the
           23  +The script determines the default value for --platform using the
    21     24   $tcl_platform(os) and $tcl_platform(machine) variables. Supported 
    22     25   platforms are "Linux-x86", "Linux-x86_64" and "Darwin-i386".
    23     26   
    24         -If the -quick option is set to true, then the "veryquick.test" script
    25         -is run for all compilation configurations. Otherwise, sometimes "all.test"
    26         -is run, sometimes "veryquick.test".
    27         -
    28         -Almost any SQLite makefile (except those generated by configure - see below)
    29         -should work. The following properties are required:
    30         -
    31         -  * The makefile should support the "fulltest" target.
    32         -  * The makefile should support the variable "OPTS" as a way to pass
    33         -    options from the make command line to lemon and the C compiler.
    34         -
    35         -More precisely, the following invocation must be supported:
    36         -
    37         -  make -f $::MAKEFILE fulltest OPTS="-DSQLITE_SECURE_DELETE=1 -DSQLITE_DEBUG=1"
    38         -
    39         -Makefiles generated by the sqlite configure program cannot be used as
    40         -they do not respect the OPTS variable.
    41         -
    42         -Example Makefile contents:
    43         -
    44         -  ########################################################
    45         -  TOP=/home/dan/work/sqlite/sqlite
    46         -
    47         -  TCL_FLAGS=-I/home/dan/tcl/include
    48         -  LIBTCL=-L/home/dan/tcl/lib -ltcl
    49         -
    50         -  BCC = gcc
    51         -  TCC = gcc -ansi -g $(CFLAGS)
    52         -  NAWK   = awk
    53         -  AR     = ar cr
    54         -  RANLIB = ranlib
    55         -  THREADLIB = -lpthread -ldl
    56         -  include $(TOP)/main.mk
    57         -  ########################################################
           27  +Every test begins with a fresh run of the configure script at the top
           28  +of the SQLite source tree.
    58     29   }
    59     30   
    60     31   array set ::Configs {
    61     32     "Default" {
    62     33       -O2
    63     34     }
    64     35     "Ftrapv" {
................................................................................
   224    195         puts stderr "No such configuration: \"$v\""
   225    196         exit -1
   226    197       }
   227    198     }
   228    199   }
   229    200   
   230    201   proc run_test_suite {name testtarget config} {
   231         -  
   232    202     # Tcl variable $opts is used to build up the value used to set the 
   233    203     # OPTS Makefile variable. Variable $cflags holds the value for
   234    204     # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
   235    205     # CFLAGS is only passed to gcc.
   236    206     #
   237         -  set cflags ""
          207  +  set cflags "-g"
   238    208     set opts ""
   239    209     foreach arg $config {
   240    210       if {[string match -D* $arg]} {
   241    211         lappend opts $arg
   242    212       } else {
   243    213         lappend cflags $arg
   244    214       }
................................................................................
   254    224   
   255    225     if {$::tcl_platform(platform)=="windows"} {
   256    226       append opts " -DSQLITE_OS_WIN=1"
   257    227     } else {
   258    228       append opts " -DSQLITE_OS_UNIX=1"
   259    229     }
   260    230   
   261         -  # Run the test.
   262         -  #
   263         -  set makefile [file normalize $::MAKEFILE]
   264         -  file mkdir $dir
   265         -  puts -nonewline "Testing configuration \"$name\" (logfile=$dir/test.log)..."
   266         -  flush stdout
          231  +  dryrun file mkdir $dir
          232  +  if {!$::DRYRUN} {
          233  +    set n [string length $name]
          234  +    puts -nonewline "${name}[string repeat . [expr {40-$n}]]"
          235  +    flush stdout
          236  +  }
   267    237   
   268         -  set makecmd [concat                                  \
   269         -    [list exec make -C $dir -f $makefile clean]        \
   270         -    $testtarget                                        \
   271         -    [list CFLAGS=$cflags OPTS=$opts >& $dir/test.log]  \
   272         -  ]
   273         -
   274         -  set tm1 [clock seconds] 
   275         -  set rc [catch $makecmd]
          238  +  set tm1 [clock seconds]
          239  +  set origdir [pwd]
          240  +  dryrun cd $dir
          241  +  set rc [catch [list dryrun exec $::SRCDIR/configure >& test.log]]
          242  +  if {!$rc} {
          243  +    set rc [catch [list dryrun exec make clean $testtarget \
          244  +                             CFLAGS=$cflags OPTS=$opts >>& test.log]]
          245  +  }
   276    246     set tm2 [clock seconds]
          247  +  dryrun cd $origdir
   277    248   
   278         -  set minutes [expr {($tm2-$tm1)/60}]
   279         -  set seconds [expr {($tm2-$tm1)%60}]
   280         -  puts -nonewline [format " (%d:%.2d) " $minutes $seconds]
   281         -  if {$rc} {
   282         -    puts "FAILED."
          249  +  if {!$::DRYRUN} {
          250  +    set minutes [expr {($tm2-$tm1)/60}]
          251  +    set seconds [expr {($tm2-$tm1)%60}]
          252  +    set tm [format (%02d:%02d) $minutes $seconds]
          253  +    if {$rc} {
          254  +      puts " FAIL $tm"
          255  +      incr ::NERR
          256  +    } else {
          257  +      puts " Ok   $tm"
          258  +    }
          259  +  }
          260  +}
          261  +
          262  +# The following procedure either prints its arguments (if ::DRYRUN is true)
          263  +# or executes the command of its arguments in the calling context 
          264  +# (if ::DRYRUN is false).
          265  +#
          266  +proc dryrun {args} {
          267  +  if {$::DRYRUN} {
          268  +    puts $args
   283    269     } else {
   284         -    puts "Ok."
          270  +    uplevel 1 $args
   285    271     }
   286    272   }
   287    273   
   288    274   
   289    275   # This proc processes the command line options passed to this script.
   290    276   # Currently the only option supported is "-makefile", default
   291    277   # "releasetest.mk". Set the ::MAKEFILE variable to the value of this
   292    278   # option.
   293    279   #
   294    280   proc process_options {argv} {
   295         -  set ::MAKEFILE releasetest.mk                       ;# Default value
   296         -  set ::QUICK    0                                    ;# Default value
          281  +  set ::SRCDIR    [file normalize [file dirname [file dirname $::argv0]]]
          282  +  set ::QUICK     0
          283  +  set ::BUILDONLY 0
          284  +  set ::DRYRUN    0
          285  +  set ::EXEC      exec
   297    286     set config {}
   298    287     set platform $::tcl_platform(os)-$::tcl_platform(machine)
   299    288   
   300    289     for {set i 0} {$i < [llength $argv]} {incr i} {
   301         -    switch -- [lindex $argv $i] {
   302         -      -makefile {
          290  +    set x [lindex $argv $i]
          291  +    if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}
          292  +    switch -- $x {
          293  +      -srcdir {
   303    294           incr i
   304         -        set ::MAKEFILE [lindex $argv $i]
          295  +        set ::SRCDIR [file normalize [lindex $argv $i]]
   305    296         }
   306    297   
   307    298         -platform {
   308    299           incr i
   309    300           set platform [lindex $argv $i]
   310    301         }
   311    302   
   312    303         -quick {
   313         -        incr i
   314         -        set ::QUICK [lindex $argv $i]
          304  +        set ::QUICK 1
   315    305         }
   316    306   
   317    307         -config {
   318    308           incr i
   319    309           set config [lindex $argv $i]
   320    310         }
          311  +
          312  +      -buildonly {
          313  +        set ::BUILDONLY 1
          314  +      }
          315  +
          316  +      -dryrun {
          317  +        set ::DRYRUN 1
          318  +      }
          319  +
          320  +      -info {
          321  +        puts "Command-line Options:"
          322  +        puts "   --srcdir $::SRCDIR"
          323  +        puts "   --platform [list $platform]"
          324  +        puts "   --config [list $config]"
          325  +        if {$::QUICK}     {puts "   --quick"}
          326  +        if {$::BUILDONLY} {puts "   --buildonly"}
          327  +        if {$::DRYRUN}    {puts "   --dryrun"}
          328  +        puts "\nAvailable --platform options:"
          329  +        foreach y [lsort [array names ::Platforms]] {
          330  +          puts "   [list $y]"
          331  +        }
          332  +        puts "\nAvailable --config options:"
          333  +        foreach y [lsort [array names ::Configs]] {
          334  +          puts "   [list $y]"
          335  +        }
          336  +        exit
          337  +      }
   321    338     
   322    339         default {
   323    340           puts stderr ""
   324    341           puts stderr [string trim $::USAGE_MESSAGE]
   325    342           exit -1
   326    343         }
   327    344       }
   328    345     }
   329    346   
   330         -  set ::MAKEFILE [file normalize $::MAKEFILE]
   331         -
   332    347     if {0==[info exists ::Platforms($platform)]} {
   333    348       puts "Unknown platform: $platform"
   334    349       puts -nonewline "Set the -platform option to "
   335    350       set print [list]
   336    351       foreach p [array names ::Platforms] {
   337    352         lappend print "\"$p\""
   338    353       }
................................................................................
   343    358   
   344    359     if {$config!=""} {
   345    360       if {[llength $config]==1} {lappend config fulltest}
   346    361       set ::CONFIGLIST $config
   347    362     } else {
   348    363       set ::CONFIGLIST $::Platforms($platform)
   349    364     }
   350         -  puts "Running the following configurations for $platform:"
          365  +  puts "Running the following test configurations for $platform:"
   351    366     puts "    [string trim $::CONFIGLIST]"
          367  +  puts -nonewline "Flags:"
          368  +  if {$::DRYRUN} {puts -nonewline " --dryrun"}
          369  +  if {$::BUILDONLY} {puts -nonewline " --buildonly"}
          370  +  if {$::QUICK} {puts -nonewline " --quick"}
          371  +  puts ""
   352    372   }
   353    373   
   354    374   # Main routine.
   355    375   #
   356    376   proc main {argv} {
   357    377   
   358    378     # Process any command line options.
   359    379     process_options $argv
          380  +  puts [string repeat * 70]
   360    381   
          382  +  set NERR 0
          383  +  set NTEST 0
          384  +  set STARTTIME [clock seconds]
   361    385     foreach {zConfig target} $::CONFIGLIST {
   362    386       if {$::QUICK} {set target test}
          387  +    if {$::BUILDONLY} {set target testfixture}
   363    388       set config_options $::Configs($zConfig)
   364    389   
          390  +    incr NTEST
   365    391       run_test_suite $zConfig $target $config_options
   366    392   
   367    393       # If the configuration included the SQLITE_DEBUG option, then remove
   368    394       # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
   369    395       # add it and run veryquick.test.
   370         -    if {$target!="checksymbols"} {
          396  +    if {$target!="checksymbols" && !$::BUILDONLY} {
   371    397         set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
   372    398         if {$debug_idx < 0} {
          399  +        incr NTEST
   373    400           run_test_suite "${zConfig}_debug" test [
   374    401             concat $config_options -DSQLITE_DEBUG=1
   375    402           ]
   376    403         } else {
          404  +        incr NTEST
   377    405           run_test_suite "${zConfig}_ndebug" test [
   378    406             lreplace $config_options $debug_idx $debug_idx
   379    407           ]
   380    408         }
   381    409       }
   382         -
   383    410     }
          411  +
          412  +  set elapsetime [expr {[clock seconds]-$STARTTIME}]
          413  +  puts [string repeat * 70]
          414  +  puts "$NERR failures of $NTEST test suites run in $elapsetime seconds"
   384    415   }
   385    416   
   386    417   main $argv