SQLite

Check-in [c869bf34a8]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c869bf34a8ee42ac6542862e59c7a4b89b042f79
User & Date: drh 2016-07-09 17:47:01.013
Context
2016-07-10
19:35
Fix typos in comments. No changes to code. (check-in: 77c692a670 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: b2204215b2 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: c869bf34a8 user: drh tags: trunk)
17:15
Fix a compiler warning in test code - in the int64array_addr TCL command. (check-in: 29fb988f1a user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/dbstatus.test.
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

82
83
84
85
86
87
88

ifcapable stat4||stat3 {
  set STAT3 1
} else {
  set STAT3 0
}

ifcapable malloc_usable_size {
  finish_test
  return
}

#---------------------------------------------------------------------------
# Run the dbstatus-2 and dbstatus-3 tests with several of different
# lookaside buffer sizes.
#
foreach ::lookaside_buffer_size {0 64 120} {


  # Do not run any of these tests if there is SQL configured to run
  # as part of the [sqlite3] command. This prevents the script from
  # configuring the size of the lookaside buffer after [sqlite3] has
  # returned.
  if {[presql] != ""} break








<
<
<
<
<





>







65
66
67
68
69
70
71





72
73
74
75
76
77
78
79
80
81
82
83
84

ifcapable stat4||stat3 {
  set STAT3 1
} else {
  set STAT3 0
}






#---------------------------------------------------------------------------
# Run the dbstatus-2 and dbstatus-3 tests with several of different
# lookaside buffer sizes.
#
foreach ::lookaside_buffer_size {0 64 120} {
  ifcapable malloc_usable_size break

  # Do not run any of these tests if there is SQL configured to run
  # as part of the [sqlite3] command. This prevents the script from
  # configuring the size of the lookaside buffer after [sqlite3] has
  # returned.
  if {[presql] != ""} break

384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
#
ifcapable shared_cache {
  proc do_cacheused_test {tn db res} {
    set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0]
    set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0]
    set cu [lindex $cu 1]
    set pcu [lindex $pcu 1]
    uplevel [list do_test $tn [list list $cu $pcu] [list {*}$res]]
  }
  reset_db
  sqlite3 db file:test.db?cache=shared

  do_execsql_test 4.0 {
    CREATE TABLE t1(a, b, c);
    INSERT INTO t1 VALUES(1, 2, 3);







|







380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
#
ifcapable shared_cache {
  proc do_cacheused_test {tn db res} {
    set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0]
    set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0]
    set cu [lindex $cu 1]
    set pcu [lindex $pcu 1]
    uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"]
  }
  reset_db
  sqlite3 db file:test.db?cache=shared

  do_execsql_test 4.0 {
    CREATE TABLE t1(a, b, c);
    INSERT INTO t1 VALUES(1, 2, 3);
Changes to test/tester.tcl.
716
717
718
719
720
721
722











723
724
725
726
727
728
729
}
rename puts puts_original
proc puts {args} { uplevel puts_override $args }


# Invoke the do_test procedure to run a single test
#











proc do_test {name cmd expected} {
  global argv cmdlinearg

  fix_testname name

  sqlite3_memdebug_settitle $name








>
>
>
>
>
>
>
>
>
>
>







716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
}
rename puts puts_original
proc puts {args} { uplevel puts_override $args }


# Invoke the do_test procedure to run a single test
#
# The $expected parameter is the expected result.  The result is the return
# value from the last TCL command in $cmd.
#
# Normally, $expected must match exactly.  But if $expected is of the form
# "/regexp/" then regular expression matching is used.  If $expected is
# "~/regexp/" then the regular expression must NOT match.  If $expected is
# of the form "#/value-list/" then each term in value-list must be numeric
# and must approximately match the corresponding numeric term in $result.
# Values must match within 10%.  Or if the $expected term is A..B then the
# $result term must be in between A and B.
#
proc do_test {name cmd expected} {
  global argv cmdlinearg

  fix_testname name

  sqlite3_memdebug_settitle $name

749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769















770
771
772
773
774
775
776

  if {![info exists ::G(match)] || [string match $::G(match) $name]} {
    if {[catch {uplevel #0 "$cmd;\n"} result]} {
      output2_if_no_verbose -nonewline $name...
      output2 "\nError: $result"
      fail_test $name
    } else {
      if {[regexp {^~?/.*/$} $expected]} {
        # "expected" is of the form "/PATTERN/" then the result if correct if
        # regular expression PATTERN matches the result.  "~/PATTERN/" means
        # the regular expression must not match.
        if {[string index $expected 0]=="~"} {
          set re [string range $expected 2 end-1]
          if {[string index $re 0]=="*"} {
            # If the regular expression begins with * then treat it as a glob instead
            set ok [string match $re $result]
          } else {
            set re [string map {# {[-0-9.]+}} $re]
            set ok [regexp $re $result]
          }
          set ok [expr {!$ok}]















        } else {
          set re [string range $expected 1 end-1]
          if {[string index $re 0]=="*"} {
            # If the regular expression begins with * then treat it as a glob instead
            set ok [string match $re $result]
          } else {
            set re [string map {# {[-0-9.]+}} $re]







|













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802

  if {![info exists ::G(match)] || [string match $::G(match) $name]} {
    if {[catch {uplevel #0 "$cmd;\n"} result]} {
      output2_if_no_verbose -nonewline $name...
      output2 "\nError: $result"
      fail_test $name
    } else {
      if {[regexp {^[~#]?/.*/$} $expected]} {
        # "expected" is of the form "/PATTERN/" then the result if correct if
        # regular expression PATTERN matches the result.  "~/PATTERN/" means
        # the regular expression must not match.
        if {[string index $expected 0]=="~"} {
          set re [string range $expected 2 end-1]
          if {[string index $re 0]=="*"} {
            # If the regular expression begins with * then treat it as a glob instead
            set ok [string match $re $result]
          } else {
            set re [string map {# {[-0-9.]+}} $re]
            set ok [regexp $re $result]
          }
          set ok [expr {!$ok}]
        } elseif {[string index $expected 0]=="#"} {
          # Numeric range value comparison.  Each term of the $result is matched
          # against one term of $expect.  Both $result and $expected terms must be
          # numeric.  The values must match within 10%.  Or if $expected is of the
          # form A..B then the $result term must be between A and B.
          set e2 [string range $expected 2 end-1]
          foreach i $result j $e2 {
            if {[regexp {^(-?\d+)\.\.(-?\d)$} $j all A B]} {
              set ok [expr {$i+0>=$A && $i+0<=$B}]
            } else {
              set ok [expr {$i+0>=0.9*$j && $i+0<=1.1*$j}]
            }
            if {!$ok} break
          }
          if {$ok && [llength $result]!=[llength $e2]} {set ok 0}
        } else {
          set re [string range $expected 1 end-1]
          if {[string index $re 0]=="*"} {
            # If the regular expression begins with * then treat it as a glob instead
            set ok [string match $re $result]
          } else {
            set re [string map {# {[-0-9.]+}} $re]