]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Move the test scripts for checkfreelist and checkindex over into the
authordrh <drh@noemail.net>
Wed, 1 Nov 2017 18:05:32 +0000 (18:05 +0000)
committerdrh <drh@noemail.net>
Wed, 1 Nov 2017 18:05:32 +0000 (18:05 +0000)
ext/repair/test directory.  Run them now using the sqlite3_checker utility
with the --test option.  Some tests are currently failing due to an
incomplete port.  This is an incremental check-in.

FossilOrigin-Name: 17f8d5e111a9fe5b074f946e23936ae5a2a7a8d8018bad4212660d8eb81c04b7

ext/repair/sqlite3_checker.tcl
ext/repair/test/README.md [new file with mode: 0644]
ext/repair/test/checkfreelist01.test [moved from test/checkfreelist.test with 75% similarity]
ext/repair/test/checkindex01.test [moved from test/checkindex.test with 90% similarity]
ext/repair/test/test.tcl [new file with mode: 0644]
manifest
manifest.uuid

index a29d0332a62025038113d58b1f5f76caf941a23f..ab8d05e600820e95c9f62150fa00b30304c390ed 100644 (file)
@@ -1,5 +1,3 @@
-# Read and run TCL commands from standard input.  Used to implement
-# the --tclsh option.
 # This TCL script is the main driver script for the sqlite3_checker utility
 # program.
 #
 #
 # uses FILENAME in place of this script.
 #
-if {[lindex $argv 0]=="--test" && [llength $argv]>2} {
-  set file [lindex $argv 1]
+if {[lindex $argv 0]=="--test" && [llength $argv]>1} {
+  set ::argv0 [lindex $argv 1]
   set argv [lrange $argv 2 end]
-  source $file
+  source $argv0
   exit 0
 }
 
diff --git a/ext/repair/test/README.md b/ext/repair/test/README.md
new file mode 100644 (file)
index 0000000..8cc954a
--- /dev/null
@@ -0,0 +1,13 @@
+To run these tests, first build sqlite3_checker:
+
+
+>     make sqlite3_checker
+
+
+Then run the "test.tcl" script using:
+
+
+>     ./sqlite3_checker --test $path/test.tcl
+
+
+Optionally add the full pathnames of individual *.test modules
similarity index 75%
rename from test/checkfreelist.test
rename to ext/repair/test/checkfreelist01.test
index 93e4ecc2346f223d1a7ca204f328c33212af5832..7c338625833169b0be2c8deabcb063c348ca0229 100644 (file)
@@ -1,40 +1,12 @@
 # 2017-10-11
-#
-# The author disclaims copyright to this source code.  In place of
-# a legal notice, here is a blessing:
-#
-#    May you do good and not evil.
-#    May you find forgiveness for yourself and forgive others.
-#    May you share freely, never taking more than you give.
-#
-#***********************************************************************
-# This file implements regression tests for SQLite library.  The
-# focus of this file is testing the checkfreelist extension.
-#
 
-set testdir [file dirname $argv0]
-source $testdir/tester.tcl
 set testprefix checkfreelist
 
-ifcapable !vtab||!compound {
-  finish_test
-  return
-}
-
-if {[file exists ../checkfreelist.so]==0} {
-  finish_test
-  return
-}
-
 do_execsql_test 1.0 {
+  PRAGMA page_size=1024;
   CREATE TABLE t1(a, b);
 }
 
-db enable_load_extension 1
-do_execsql_test 1.1 {
-  SELECT load_extension('../checkfreelist.so');
-} {{}}
-
 do_execsql_test 1.2 { SELECT checkfreelist('main') } {ok}
 do_execsql_test 1.3 {
   WITH s(i) AS (
@@ -118,6 +90,3 @@ do_execsql_test 1.11 {
     SELECT checkfreelist('main');
   ROLLBACK;
 } {{leaf count out of range (249) on trunk page 5}}
-
-finish_test
-
similarity index 90%
rename from test/checkindex.test
rename to ext/repair/test/checkindex01.test
index 22463d3ffebe539086e3c6f3e5a7bd91939b94c9..36bae886d2ae91230191dd17b3b3adfc52799cd1 100644 (file)
@@ -1,31 +1,7 @@
 # 2017-10-11
 #
-# The author disclaims copyright to this source code.  In place of
-# a legal notice, here is a blessing:
-#
-#    May you do good and not evil.
-#    May you find forgiveness for yourself and forgive others.
-#    May you share freely, never taking more than you give.
-#
-#***********************************************************************
-# This file implements regression tests for SQLite library.  The
-# focus of this file is testing the checkindex extension.
-#
-
-set testdir [file dirname $argv0]
-source $testdir/tester.tcl
 set testprefix checkindex
 
-ifcapable !vtab||!compound {
-  finish_test
-  return
-}
-
-if {[file exists ../checkindex.so]==0} {
-  finish_test
-  return
-}
-
 do_execsql_test 1.0 {
   CREATE TABLE t1(a, b);
   CREATE INDEX i1 ON t1(a);
@@ -36,12 +12,7 @@ do_execsql_test 1.0 {
   INSERT INTO t1 VALUES('five', 10);
 
   CREATE INDEX i2 ON t1(a DESC);
-}
-
-db enable_load_extension 1
-do_execsql_test 1.1 {
-  SELECT load_extension('../checkindex.so');
-} {{}}
+} {}
 
 proc incr_index_check {idx nStep} {
   set Q {
@@ -148,7 +119,7 @@ do_execsql_test 2.0 {
   CREATE INDEX i3 ON t2(b, c, d);
   CREATE INDEX i4 ON t2(b DESC, c DESC, d DESC);
   CREATE INDEX i5 ON t2(d, c DESC, b);
-}
+} {}
 
 do_index_check_test 2.1 i3 {
   {} NULL,1,1,1 
@@ -205,7 +176,7 @@ do_execsql_test 3.0 {
   INSERT INTO t3 VALUES('a', 'b', NULL, 8);
   INSERT INTO t3 VALUES('a', 'b', NULL, 9);
 
-}
+} {}
 
 do_index_check_test 3.1 t3wxy {
   {} NULL,NULL,NULL,1 {} NULL,NULL,NULL,2 {} NULL,NULL,NULL,3 
@@ -345,6 +316,3 @@ do_index_check_test 6.2 t6x3 {
   {} 3,2,1 
   {} 6,5,4
 }
-
-finish_test
-
diff --git a/ext/repair/test/test.tcl b/ext/repair/test/test.tcl
new file mode 100644 (file)
index 0000000..c073bb7
--- /dev/null
@@ -0,0 +1,67 @@
+# Run this script using
+#
+#       sqlite3_checker --test $thisscript $testscripts
+#
+# The $testscripts argument is optional.  If omitted, all *.test files
+# in the same directory as $thisscript are run.
+#
+set NTEST 0
+set NERR  0
+
+
+# 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} {
+  if {[info exists ::testprefix]} {
+    set name "$::testprefix$name"
+  }
+
+  incr ::NTEST
+  puts -nonewline $name...
+  flush stdout
+
+  if {[catch {uplevel #0 "$cmd;\n"} result]} {
+    puts -nonewline $name...
+    puts "\nError: $result"
+    incr ::NERR
+  } else {
+    set ok [expr {[string compare $result $expected]==0}]
+    if {!$ok} {
+      puts "\n!  $name expected: \[$expected\]\n! $name got:      \[$result\]"
+      incr ::NERR
+    } else {
+      puts " Ok"
+    }
+  }
+  flush stdout
+}
+
+#
+#   do_execsql_test TESTNAME SQL RES
+#
+proc do_execsql_test {testname sql {result {}}} {
+  uplevel [list do_test $testname [list db eval $sql] [list {*}$result]]
+}
+
+if {[llength $argv]==0} {
+  set dir [file dirname $argv0]
+  set argv [glob -nocomplain $dir/*.test]
+}
+foreach testfile $argv {
+  file delete -force test.db
+  sqlite3 db test.db
+  source $testfile
+  catch {db close}
+}
+puts "$NERR errors out of $NTEST tests"
index bf8e3e2133995f08d7f8cdbe6fdc3cc9bd39ff6e..ff5e3f094dad8a851adbdd4eb737f67076c07f52 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Minor\scleanup\sin\scheckindex.c.\s\sAdd\sprogress\sdisplays\swhen\schecking\sa\nsingle\sindex\sin\sthe\stop-level\sTCL\sscript\sfor\ssqlite3_checker.
-D 2017-11-01T13:09:02.677
+C Move\sthe\stest\sscripts\sfor\scheckfreelist\sand\scheckindex\sover\sinto\sthe\next/repair/test\sdirectory.\s\sRun\sthem\snow\susing\sthe\ssqlite3_checker\sutility\nwith\sthe\s--test\soption.\s\sSome\stests\sare\scurrently\sfailing\sdue\sto\san\nincomplete\sport.\s\sThis\sis\san\sincremental\scheck-in.
+D 2017-11-01T18:05:32.697
 F Makefile.in b142eb20482922153ebc77b261cdfd0a560ed05a81e9f6d9a2b0e8192922a1d2
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc a55372a22454e742ba7c8f6edf05b83213ec01125166ad7dcee0567e2f7fc81b
@@ -330,7 +330,11 @@ F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b14469
 F ext/repair/checkfreelist.c 0abb84b4545016d57ba1a2aa8884c72c73ed838968909858c03bc1f38fb6b054
 F ext/repair/checkindex.c a013a0a165b2e6f2b278a31566da04913856c88d6ed5457d477f89e78d5979d9
 F ext/repair/sqlite3_checker.c.in 16d62615dfce1ff3eeac83d1a77fe376a7b660afa9db07e1fdd8b964dcc41510
-F ext/repair/sqlite3_checker.tcl 32d474decb6bb65e60bd3660dba0b75e7e0719d6f6fb6dba97e5b9249eec94a1
+F ext/repair/sqlite3_checker.tcl 4820d7f58428d47336874b5a148a95b4dad38fe5da72286c01a861590b8f8337
+F ext/repair/test/README.md 34b2f542cf5be7bffe479242b33ee3492cea30711e447cc4a1a86cb5915f419e
+F ext/repair/test/checkfreelist01.test 185648c046c0e269dc3b5141d525b87a38d72f0f55495d46c65108a5dde1428f
+F ext/repair/test/checkindex01.test 7be2299647ac7be41b6a7e249eb78e3aba1b57a7b20943ad199a1dc457edb4f7
+F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c
 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
 F ext/rtree/rtree.c cc91b6905bf55512c6ebc7dfdd37ac81c86f1753db8cfa6d62f0ee864464044f
 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
@@ -655,8 +659,6 @@ F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe
 F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3
 F test/cffault.test 9d6b20606afe712374952eec4f8fd74b1a8097ef
 F test/check.test 33a698e8c63613449d85d624a38ef669bf20331daabebe3891c9405dd6df463a
-F test/checkfreelist.test 100283a3e6b8a3018c7fab7cfdaf03d1d6540fc66453114e248cf82b25784d3b
-F test/checkindex.test 77153b3d92492a186c947031ee0eb2e9b879c07192c0066f6152539b670dd237
 F test/close.test 799ea4599d2f5704b0a30f477d17c2c760d8523fa5d0c8be4a7df2a8cad787d8
 F test/closure01.test b1703ba40639cfc9b295cf478d70739415eec6a4
 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91
@@ -1671,7 +1673,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 6ffe917d10e298cd80cd3a8c8c5116a2819145a176fb8cfccd5dbd88b10f39df
-R 9a8d975a41c4365cfebb7312db115daa
+P 3ca31cc3ffe1cce4a9961d29801eebd47f0093d1b53d0ea63386338a1d434fd3
+R 9a0909f5ab1dfc6f8f86ede9c43722ca
 U drh
-Z d02ff4965492ed83b018c8e578de7329
+Z 17e4966dab1f438179fdac475786b16e
index 86f32e4c10dcb10cf8bc3007fe3b7bd0c89b7f1e..1cd31e3773969dfaa8a33dbeeec02210dcd09efa 100644 (file)
@@ -1 +1 @@
-3ca31cc3ffe1cce4a9961d29801eebd47f0093d1b53d0ea63386338a1d434fd3
\ No newline at end of file
+17f8d5e111a9fe5b074f946e23936ae5a2a7a8d8018bad4212660d8eb81c04b7
\ No newline at end of file