/ Check-in [c869bf34]
Login

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

Overview
Comment:Add the "#/value-list/" style of results for approximate value matching in the do_test command of the test infrastructure. Use this new result style to make the SQLITE_DBSTATUS_CACHE_SIZE_SHARED tests cross-platform.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c869bf34a8ee42ac6542862e59c7a4b89b042f79
User & Date: drh 2016-07-09 17:47:01
Context
2016-07-10
19:35
Fix typos in comments. No changes to code. check-in: 77c692a6 user: mistachkin tags: trunk
2016-07-09
20:23
Add some support for using row value constructors in certain parts of SQL expressions. There are many bugs on this branch. check-in: b2204215 user: dan tags: rowvalue
17:47
Add the "#/value-list/" style of results for approximate value matching in the do_test command of the test infrastructure. Use this new result style to make the SQLITE_DBSTATUS_CACHE_SIZE_SHARED tests cross-platform. check-in: c869bf34 user: drh tags: trunk
17:15
Fix a compiler warning in test code - in the int64array_addr TCL command. check-in: 29fb988f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/dbstatus.test.

    65     65   
    66     66   ifcapable stat4||stat3 {
    67     67     set STAT3 1
    68     68   } else {
    69     69     set STAT3 0
    70     70   }
    71     71   
    72         -ifcapable malloc_usable_size {
    73         -  finish_test
    74         -  return
    75         -}
    76         -
    77     72   #---------------------------------------------------------------------------
    78     73   # Run the dbstatus-2 and dbstatus-3 tests with several of different
    79     74   # lookaside buffer sizes.
    80     75   #
    81     76   foreach ::lookaside_buffer_size {0 64 120} {
           77  +  ifcapable malloc_usable_size break
    82     78   
    83     79     # Do not run any of these tests if there is SQL configured to run
    84     80     # as part of the [sqlite3] command. This prevents the script from
    85     81     # configuring the size of the lookaside buffer after [sqlite3] has
    86     82     # returned.
    87     83     if {[presql] != ""} break
    88     84   
................................................................................
   384    380   #
   385    381   ifcapable shared_cache {
   386    382     proc do_cacheused_test {tn db res} {
   387    383       set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0]
   388    384       set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0]
   389    385       set cu [lindex $cu 1]
   390    386       set pcu [lindex $pcu 1]
   391         -    uplevel [list do_test $tn [list list $cu $pcu] [list {*}$res]]
          387  +    uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"]
   392    388     }
   393    389     reset_db
   394    390     sqlite3 db file:test.db?cache=shared
   395    391   
   396    392     do_execsql_test 4.0 {
   397    393       CREATE TABLE t1(a, b, c);
   398    394       INSERT INTO t1 VALUES(1, 2, 3);

Changes to test/tester.tcl.

   716    716   }
   717    717   rename puts puts_original
   718    718   proc puts {args} { uplevel puts_override $args }
   719    719   
   720    720   
   721    721   # Invoke the do_test procedure to run a single test
   722    722   #
          723  +# The $expected parameter is the expected result.  The result is the return
          724  +# value from the last TCL command in $cmd.
          725  +#
          726  +# Normally, $expected must match exactly.  But if $expected is of the form
          727  +# "/regexp/" then regular expression matching is used.  If $expected is
          728  +# "~/regexp/" then the regular expression must NOT match.  If $expected is
          729  +# of the form "#/value-list/" then each term in value-list must be numeric
          730  +# and must approximately match the corresponding numeric term in $result.
          731  +# Values must match within 10%.  Or if the $expected term is A..B then the
          732  +# $result term must be in between A and B.
          733  +#
   723    734   proc do_test {name cmd expected} {
   724    735     global argv cmdlinearg
   725    736   
   726    737     fix_testname name
   727    738   
   728    739     sqlite3_memdebug_settitle $name
   729    740   
................................................................................
   749    760   
   750    761     if {![info exists ::G(match)] || [string match $::G(match) $name]} {
   751    762       if {[catch {uplevel #0 "$cmd;\n"} result]} {
   752    763         output2_if_no_verbose -nonewline $name...
   753    764         output2 "\nError: $result"
   754    765         fail_test $name
   755    766       } else {
   756         -      if {[regexp {^~?/.*/$} $expected]} {
          767  +      if {[regexp {^[~#]?/.*/$} $expected]} {
   757    768           # "expected" is of the form "/PATTERN/" then the result if correct if
   758    769           # regular expression PATTERN matches the result.  "~/PATTERN/" means
   759    770           # the regular expression must not match.
   760    771           if {[string index $expected 0]=="~"} {
   761    772             set re [string range $expected 2 end-1]
   762    773             if {[string index $re 0]=="*"} {
   763    774               # If the regular expression begins with * then treat it as a glob instead
   764    775               set ok [string match $re $result]
   765    776             } else {
   766    777               set re [string map {# {[-0-9.]+}} $re]
   767    778               set ok [regexp $re $result]
   768    779             }
   769    780             set ok [expr {!$ok}]
          781  +        } elseif {[string index $expected 0]=="#"} {
          782  +          # Numeric range value comparison.  Each term of the $result is matched
          783  +          # against one term of $expect.  Both $result and $expected terms must be
          784  +          # numeric.  The values must match within 10%.  Or if $expected is of the
          785  +          # form A..B then the $result term must be between A and B.
          786  +          set e2 [string range $expected 2 end-1]
          787  +          foreach i $result j $e2 {
          788  +            if {[regexp {^(-?\d+)\.\.(-?\d)$} $j all A B]} {
          789  +              set ok [expr {$i+0>=$A && $i+0<=$B}]
          790  +            } else {
          791  +              set ok [expr {$i+0>=0.9*$j && $i+0<=1.1*$j}]
          792  +            }
          793  +            if {!$ok} break
          794  +          }
          795  +          if {$ok && [llength $result]!=[llength $e2]} {set ok 0}
   770    796           } else {
   771    797             set re [string range $expected 1 end-1]
   772    798             if {[string index $re 0]=="*"} {
   773    799               # If the regular expression begins with * then treat it as a glob instead
   774    800               set ok [string match $re $result]
   775    801             } else {
   776    802               set re [string map {# {[-0-9.]+}} $re]