Fix problems in test scripts. Add new test cases to improve test coverage. (CVS 5521)

FossilOrigin-Name: b65f493c7519e8a5ee632a395b57d45269741dda
This commit is contained in:
drh
2008-08-01 18:47:01 +00:00
parent 987a00e8b5
commit 4cfb22f798
11 changed files with 127 additions and 44 deletions
+3 -1
View File
@@ -12,7 +12,7 @@
# focus of this script is testing the ALTER TABLE statement and
# specifically out-of-memory conditions within that command.
#
# $Id: altermalloc.test,v 1.7 2007/10/03 08:46:45 danielk1977 Exp $
# $Id: altermalloc.test,v 1.8 2008/08/01 18:47:02 drh Exp $
#
set testdir [file dirname $argv0]
@@ -32,6 +32,7 @@ do_malloc_test altermalloc-1 -tclprep {
if {[catch {sqlite3 db test.db}]} {
error "out of memory"
}
sqlite3_db_config_lookaside db 0 0
sqlite3_extended_result_codes db 1
} -sqlbody {
CREATE TABLE t1(a int);
@@ -45,6 +46,7 @@ do_malloc_test altermalloc-1 -tclprep {
ifcapable vtab {
do_malloc_test altermalloc-vtab -tclprep {
sqlite3 db2 test.db
sqlite3_db_config_lookaside db2 0 0
sqlite3_extended_result_codes db2 1
register_echo_module [sqlite3_connection_pointer db2]
db2 eval {
+11 -1
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library.
# This file implements tests for the ANALYZE command.
#
# $Id: analyze.test,v 1.7 2008/04/11 17:11:27 danielk1977 Exp $
# $Id: analyze.test,v 1.8 2008/08/01 18:47:02 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -266,6 +266,16 @@ do_test analyze-4.2 {
SELECT * FROM t4 WHERE x=1234;
}
} {}
do_test analyze-4.3 {
execsql {
INSERT INTO sqlite_stat1 VALUES('t4','xyzzy','0 1 2 3');
}
db close
sqlite3 db test.db
execsql {
SELECT * FROM t4 WHERE x=1234;
}
} {}
# This test corrupts the database file so it must be the last test
# in the series.
+26 -13
View File
@@ -11,11 +11,18 @@
#
# Tests for the lookaside memory allocator.
#
# $Id: lookaside.test,v 1.1 2008/08/01 16:31:14 drh Exp $
# $Id: lookaside.test,v 1.2 2008/08/01 18:47:02 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 0 0
sqlite3_config_scratch 0 0
sqlite3_initialize
sqlite3 db test.db
# Make sure sqlite3_db_config() and sqlite3_db_status are working.
#
do_test lookaside-1.1 {
@@ -29,22 +36,27 @@ do_test lookaside-1.3 {
} {0 0 0}
do_test lookaside-1.4 {
db eval {CREATE TABLE t1(x);}
sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0
} {0 7 20}
foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break
expr {$x==0 && $y<$z && $z==20}
} {1}
do_test lookaside-1.5 {
sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1
} {0 7 20}
foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1] break
expr {$x==0 && $y<$z && $z==20}
} {1}
do_test lookaside-1.6 {
sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0
} {0 7 7}
foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break
expr {$x==0 && $y==$z && $y<20}
} {1}
do_test lookaside-1.7 {
db cache flush
sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0
} {0 0 7}
foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break
expr {$x==0 && $y==0 && $z<20}
} {1}
do_test lookaside-1.8 {
db cache flush
sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1
} {0 0 7}
foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1] break
expr {$x==0 && $y==0 && $z<20}
} {1}
do_test lookaside-1.9 {
db cache flush
sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0
@@ -55,8 +67,9 @@ do_test lookaside-2.1 {
} {0}
do_test lookaside-2.2 {
db eval {CREATE TABLE t2(x);}
sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0
} {0 10 48}
foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break
expr {$x==0 && $y<$z && $z>10 && $z<100}
} {1}
do_test lookaside-2.3 {
sqlite3_db_config_lookaside db 50 50
} {5} ;# SQLITE_BUSY
+2 -2
View File
@@ -11,7 +11,7 @@
#
# This test script checks malloc failures in various obscure operations.
#
# $Id: mallocG.test,v 1.4 2008/07/07 19:52:11 drh Exp $
# $Id: mallocG.test,v 1.5 2008/08/01 18:47:02 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -27,7 +27,7 @@ if {!$MEMDEBUG} {
# Malloc failures while opening a database connection.
#
do_malloc_test malloeG-1 -tclbody {
do_malloc_test mallocG-1 -tclbody {
db close
sqlite3 db test.db
}
+51
View File
@@ -0,0 +1,51 @@
# 2008 August 01
#
# 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 test script checks malloc failures in various obscure operations.
#
# $Id: mallocH.test,v 1.1 2008/08/01 18:47:02 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl
# Malloc failures in journaling of in-memory databases.
#
do_malloc_test mallocH-1 -tclprep {
db close
sqlite3 db :memory:
db eval {
CREATE TABLE t1(x UNIQUE, y);
INSERT INTO t1 VALUES(1,2);
}
} -sqlbody {
INSERT INTO t1 SELECT x+1, y+100 FROM t1;
}
# Malloc failures while parsing a CASE expression.
#
do_malloc_test mallocH-2 -sqlbody {
SELECT CASE WHEN 1 THEN 1 END;
}
# Malloc failures while parsing a EXISTS(SELECT ...)
#
do_malloc_test mallocH-3 -sqlbody {
SELECT 3+EXISTS(SELECT * FROM sqlite_master);
}
# Malloc failures within the replace() function.
#
do_malloc_test mallocH-3 -sqlbody {
SELECT replace('ababa','a','xyzzy');
}
finish_test
+2 -1
View File
@@ -12,7 +12,7 @@
# This file contains common code used by many different malloc tests
# within the test suite.
#
# $Id: malloc_common.tcl,v 1.19 2008/07/23 20:28:14 drh Exp $
# $Id: malloc_common.tcl,v 1.20 2008/08/01 18:47:02 drh Exp $
# If we did not compile with malloc testing enabled, then do nothing.
#
@@ -98,6 +98,7 @@ proc do_malloc_test {tn args} {
if {[info commands db] ne ""} {
sqlite3_extended_result_codes db 1
}
sqlite3_db_config_lookaside db 0 0
# Execute any -tclprep and -sqlprep scripts.
#
+2 -1
View File
@@ -9,7 +9,7 @@
#
#***********************************************************************
#
# $Id: permutations.test,v 1.19 2008/08/01 15:06:30 drh Exp $
# $Id: permutations.test,v 1.20 2008/08/01 18:47:02 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -66,6 +66,7 @@ set EXCLUDE {
fts3.test misc7.test utf16.test
fuzz_malloc.test misuse.test veryquick.test
fuzz.test mutex2.test vtab_err.test
lookaside.test
}
set ALLTESTS [list]
foreach filename [glob $testdir/*.test] {