blob: efd6b4ce78a6eefffdd1190431a96383462d4920 [file] [log] [blame]
dane1ab2192009-08-17 15:16:19 +00001# 2001 September 15
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
dan3d6e0602009-08-17 15:52:25 +000012# This file implements regression tests for SQLite library. The
13# focus of this file is testing the effects of a failure in
14# sqlite3_initialize().
15#
16#
dane1ab2192009-08-17 15:16:19 +000017
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21db close
22
23foreach {t failed rc started} {
dan3d6e0602009-08-17 15:52:25 +000024 1.1 {} SQLITE_OK {mutex mem pcache}
dane1ab2192009-08-17 15:16:19 +000025 1.2 {mutex} SQLITE_ERROR {}
26 1.3 {mem} SQLITE_ERROR {mutex}
27 1.4 {pcache} SQLITE_ERROR {mutex mem}
dane1ab2192009-08-17 15:16:19 +000028} {
29 do_test init-$t.1 {
30 eval init_wrapper_install $failed
31 sqlite3_initialize
32 } $rc
33 do_test init-$t.2 {
34 init_wrapper_query
35 } $started
36 do_test init-$t.3 {
37 sqlite3_shutdown
38 init_wrapper_query
39 } {}
40 do_test init-$t.4 {
41 sqlite3_initialize
42 } $rc
43 do_test init-$t.5 {
44 init_wrapper_query
45 } $started
46 do_test init-$t.6 {
47 init_wrapper_clear
48 sqlite3_initialize
49 } SQLITE_OK
50 do_test init-$t.7 {
51 init_wrapper_query
dan3d6e0602009-08-17 15:52:25 +000052 } {mutex mem pcache}
dane1ab2192009-08-17 15:16:19 +000053 do_test init-$t.8 {
54 init_wrapper_uninstall
55 } {}
56}
57
dan3d6e0602009-08-17 15:52:25 +000058source $testdir/malloc_common.tcl
59if {$MEMDEBUG} {
60 do_malloc_test init-2 -tclprep {
61 db close
62 init_wrapper_install
63 } -tclbody {
64 set rc [sqlite3_initialize]
65 if {[string match "SQLITE*NOMEM" $rc]} {error "out of memory"}
66 } -cleanup {
67 set zRepeat "transient"
68 if {$::iRepeat} {set zRepeat "persistent"}
69 do_test init-2.$zRepeat.$::n.x {
70 init_wrapper_clear
71 sqlite3_initialize
72 } SQLITE_OK
73 init_wrapper_uninstall
74 }
75}
76
dane1ab2192009-08-17 15:16:19 +000077autoinstall_test_functions
78finish_test
79