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. FossilOrigin-Name: c869bf34a8ee42ac6542862e59c7a4b89b042f79
This commit is contained in:
+2
-6
@@ -69,16 +69,12 @@ ifcapable stat4||stat3 {
|
||||
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} {
|
||||
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
|
||||
@@ -388,7 +384,7 @@ ifcapable shared_cache {
|
||||
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]]
|
||||
uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"]
|
||||
}
|
||||
reset_db
|
||||
sqlite3 db file:test.db?cache=shared
|
||||
|
||||
+27
-1
@@ -720,6 +720,17 @@ 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
|
||||
|
||||
@@ -753,7 +764,7 @@ proc do_test {name cmd expected} {
|
||||
output2 "\nError: $result"
|
||||
fail_test $name
|
||||
} else {
|
||||
if {[regexp {^~?/.*/$} $expected]} {
|
||||
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.
|
||||
@@ -767,6 +778,21 @@ proc do_test {name cmd expected} {
|
||||
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]=="*"} {
|
||||
|
||||
Reference in New Issue
Block a user