1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Minor fixes related to the tests in misuse.test (CVS 1738)

FossilOrigin-Name: 0af3ff39422e02afdfdaf2005ab5eb01b496dc72
This commit is contained in:
danielk1977
2004-06-26 09:50:11 +00:00
parent 40b38dcdf8
commit e35ee196dc
7 changed files with 95 additions and 84 deletions

View File

@ -11,36 +11,12 @@
# This file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API.
#
# $Id: capi2.test,v 1.16 2004/06/21 07:36:33 danielk1977 Exp $
# $Id: capi2.test,v 1.17 2004/06/26 09:50:12 danielk1977 Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# proc sqlite_step {stmt N VALS COLS} {
# upvar $VALS vals
# upvar $COLS cols
# upvar $N n
# set vals [list]
# set cols [list]
#
# set n [sqlite3_column_count $stmt]
#
# set rc [sqlite3_step $stmt]
# for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
# lappend cols [sqlite3_column_name $stmt $i]
# }
# for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
# lappend cols [sqlite3_column_decltype $stmt $i]
# }
#
# for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {
# lappend vals [sqlite3_column_text $stmt $i]
# }
#
# return $rc
# }
# Return the text values from the current row pointed at by STMT as a list.
proc get_row_values {STMT} {
set VALUES [list]

View File

@ -10,7 +10,7 @@
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: crash.test,v 1.4 2004/06/25 06:23:23 danielk1977 Exp $
# $Id: crash.test,v 1.5 2004/06/26 09:50:12 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -37,7 +37,6 @@ proc crashsql {crashdelay crashfile sql} {
set f [open crash.tcl w]
puts $f "sqlite3_crashparams $crashdelay $cfile"
puts $f "sqlite3 db test.db"
puts $f "db eval {pragma synchronous = full}"
puts $f "db eval {pragma cache_size = 10}"
puts $f "db eval {"
puts $f "$sql"
@ -232,14 +231,9 @@ for {set i 1} {$i < $repeats} {incr i} {
do_test crash-4.0 {
file delete -force test2.db
file delete -force test2.db-journal
sqlite3 db2 test2.db
execsql {
pragma default_cache_size = 10;
pragma default_synchronous = full;
} db2
db2 close
execsql {
ATTACH 'test2.db' AS aux;
PRAGMA aux.default_cache_size = 10;
CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc;
}
expr [file size test2.db] / 1024

View File

@ -13,11 +13,28 @@
# This file implements tests for the SQLITE_MISUSE detection logic.
# This test file leaks memory and file descriptors.
#
# $Id: misuse.test,v 1.5 2004/06/19 00:16:31 drh Exp $
# $Id: misuse.test,v 1.6 2004/06/26 09:50:12 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
proc catchsql2 {sql} {
set r [
catch {
set res [list]
db eval $sql data {
if { $res==[list] } {
foreach f $data(*) {lappend res $f}
}
foreach f $data(*) {lappend res $data($f)}
}
set res
} msg
]
lappend r $msg
}
# Make sure the test logic works
#
do_test misuse-1.1 {
@ -28,14 +45,20 @@ do_test misuse-1.1 {
CREATE TABLE t1(a,b);
INSERT INTO t1 VALUES(1,2);
}
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
catchsql2 {
SELECT * FROM t1
}
} {0 {a b 1 2}}
do_test misuse-1.2 {
sqlite_exec_printf $::DB {SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1} {}
catchsql2 {
SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1
}
} {1 {no such function: x_coalesce}}
do_test misuse-1.3 {
sqlite_create_function $::DB
sqlite_exec_printf $::DB {SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1} {}
sqlite3_create_function $::DB
catchsql2 {
SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1
}
} {0 {xyz 1}}
# Use the x_sqlite_exec() SQL function to simulate the effect of two
@ -46,12 +69,12 @@ do_test misuse-1.3 {
# they do not.
#
do_test misuse-1.4 {
sqlite_exec_printf $::DB {
catchsql2 {
SELECT x_sqlite_exec('SELECT * FROM t1') AS xyz;
} {}
}
} {0 {xyz {1 2}}}
do_test misuse-1.5 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-1.6 {
catchsql {
@ -69,19 +92,19 @@ do_test misuse-2.1 {
}
} {1 2}
do_test misuse-2.2 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-2.3 {
set v [catch {
db eval {SELECT * FROM t1} {} {
sqlite_create_function $::DB
sqlite3_create_function $::DB
}
} msg]
lappend v $msg
} {1 {library routine called out of sequence}}
do_test misuse-2.4 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
} {21 {library routine called out of sequence}}
catchsql2 {SELECT * FROM t1}
} {1 {library routine called out of sequence}}
do_test misuse-2.5 {
catchsql {
SELECT * FROM t1
@ -98,19 +121,19 @@ do_test misuse-3.1 {
}
} {1 2}
do_test misuse-3.2 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-3.3 {
set v [catch {
db eval {SELECT * FROM t1} {} {
sqlite_create_aggregate $::DB
sqlite3_create_aggregate $::DB
}
} msg]
lappend v $msg
} {1 {library routine called out of sequence}}
do_test misuse-3.4 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
} {21 {library routine called out of sequence}}
catchsql2 {SELECT * FROM t1}
} {1 {library routine called out of sequence}}
do_test misuse-3.5 {
catchsql {
SELECT * FROM t1
@ -119,6 +142,8 @@ do_test misuse-3.5 {
# Attempt to close the database from an sqlite_exec callback.
#
# Update for v3: The db cannot be closed because there are active
# VMs. The sqlite3_close call would return SQLITE_BUSY.
do_test misuse-4.1 {
db close
set ::DB [sqlite3 db test2.db]
@ -127,19 +152,20 @@ do_test misuse-4.1 {
}
} {1 2}
do_test misuse-4.2 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-4.3 {
set v [catch {
db eval {SELECT * FROM t1} {} {
sqlite_close $::DB
set r [sqlite3_close $::DB]
}
} msg]
lappend v $msg
} {1 {library routine called out of sequence}}
lappend v $msg $r
} {0 {} SQLITE_BUSY}
do_test misuse-4.4 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
} {21 {library routine called out of sequence}}
sqlite3_close $::DB
catchsql2 {SELECT * FROM t1}
} {1 {library routine called out of sequence}}
do_test misuse-4.5 {
catchsql {
SELECT * FROM t1
@ -156,11 +182,14 @@ do_test misuse-5.1 {
}
} {1 2}
do_test misuse-5.2 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-5.3 {
db close
sqlite_exec_printf $::DB {SELECT * FROM t1} {}
} {21 {library routine called out of sequence}}
set r [catch {
sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL
} msg]
lappend r $msg
} {1 {(21) library routine called out of sequence}}
finish_test