2N/A#pragma ident "%Z%%M% %I% %E% SMI" 2N/A# The author disclaims copyright to this source code. In place of 2N/A# a legal notice, here is a blessing: 2N/A# May you do good and not evil. 2N/A# May you find forgiveness for yourself and forgive others. 2N/A# May you share freely, never taking more than you give. 2N/A#*********************************************************************** 2N/A# This file implements some common TCL routines used for regression 2N/A# testing the SQLite library 2N/A# Make sure tclsqlite was compiled correctly. Abort now with an 2N/A# error message if not. 2N/A puts stderr "$argv0 was linked against an older version" 2N/A puts stderr "of TCL that does not support Unicode, but uses a header" 2N/A puts stderr "file (\"tcl.h\") from a new TCL version that does support" 2N/A puts stderr "Unicode. This combination causes internal errors." 2N/A puts stderr "Recompile using a TCL library and header file that match" 2N/A puts stderr "and try again.\n**************************" 2N/A if {
"\u1234"!
="u1234"} {
2N/A puts stderr "$argv0 was linked against an newer version" 2N/A puts stderr "of TCL that supports Unicode, but uses a header file" 2N/A puts stderr "(\"tcl.h\") from a old TCL version that does not support" 2N/A puts stderr "Unicode. This combination causes internal errors." 2N/A puts stderr "Recompile using a TCL library and header file that match" 2N/A puts stderr "and try again.\n**************************" 2N/A# Use the pager codec if it is available 2N/A# Create a test database 2N/A# Abort early if this script has been run before. 2N/A# Set the test counters to zero 2N/A# Invoke the do_test procedure to run a single test 2N/A if {[
catch {
uplevel #0 "$cmd;\n"} result]} { 2N/A puts "\nError: $result" 2N/A puts "\nExpected: \[$expected\]\n Got: \[$result\]" 2N/A# Invoke this procedure on a test that is probabilistic 2N/A# and might fail sometimes. 2N/A if {[
catch {
uplevel #0 "$cmd;\n"} result]} { 2N/A puts "\nError: $result" 2N/A puts "\nExpected: \[$expected\]\n Got: \[$result\]" 2N/A puts "NOTE: The results of the previous test depend on system load" 2N/A puts "and processor speed. The test may sometimes fail even if the" 2N/A puts "library is working correctly." 2N/A# The procedure uses the special "sqlite_malloc_stat" command 2N/A# (which is only available if SQLite is compiled with -DMEMORY_DEBUG=1) 2N/A# to see how many malloc()s have not been free()ed. The number 2N/A# of surplus malloc()s is stored in the global variable $::Leak. 2N/A# If the value in $::Leak grows, it may mean there is a memory leak 2N/A# Run this routine last 2N/A puts "$nErr errors out of $nTest tests" 2N/A puts "Failures on these tests: $::failList" 2N/A puts "$nProb probabilistic tests also failed, but this does" 2N/A puts "not necessarily indicate a malfunction." 2N/A puts "$sqlite_open_file_count files were left open" 2N/A# A procedure to execute SQL 2N/A# Execute SQL and catch exceptions. 2N/A# Do an VDBE code dump on the SQL given 2N/A puts "addr opcode p1 p2 p3 " 2N/A puts "---- ------------ ------ ------ ---------------" 2N/A $
db eval "explain $sql" {} {
2N/A# Another procedure to execute SQL. This one includes the field 2N/A# names in the returned list. 2N/A# Use the non-callback API to execute multiple SQL statements 2N/A# Delete a file or directory 2N/A# Do an integrity check of the entire database