blob: 7cb18f492ac142b7d1fccb89b3e7aba6b95b8abc [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
drhacd63a52010-03-22 15:47:38 +000020if {[db eval {SELECT sqlite_compileoption_used('THREADSAFE=0')}]} {
21 finish_test
22 return
23}
dane1ab2192009-08-17 15:16:19 +000024
25db close
26
27foreach {t failed rc started} {
dan3d6e0602009-08-17 15:52:25 +000028 1.1 {} SQLITE_OK {mutex mem pcache}
dane1ab2192009-08-17 15:16:19 +000029 1.2 {mutex} SQLITE_ERROR {}
30 1.3 {mem} SQLITE_ERROR {mutex}
31 1.4 {pcache} SQLITE_ERROR {mutex mem}
dane1ab2192009-08-17 15:16:19 +000032} {
33 do_test init-$t.1 {
34 eval init_wrapper_install $failed
35 sqlite3_initialize
36 } $rc
37 do_test init-$t.2 {
38 init_wrapper_query
39 } $started
40 do_test init-$t.3 {
41 sqlite3_shutdown
42 init_wrapper_query
43 } {}
44 do_test init-$t.4 {
45 sqlite3_initialize
46 } $rc
47 do_test init-$t.5 {
48 init_wrapper_query
49 } $started
50 do_test init-$t.6 {
51 init_wrapper_clear
52 sqlite3_initialize
53 } SQLITE_OK
54 do_test init-$t.7 {
55 init_wrapper_query
dan3d6e0602009-08-17 15:52:25 +000056 } {mutex mem pcache}
dane1ab2192009-08-17 15:16:19 +000057 do_test init-$t.8 {
58 init_wrapper_uninstall
59 } {}
60}
61
dan3d6e0602009-08-17 15:52:25 +000062source $testdir/malloc_common.tcl
63if {$MEMDEBUG} {
64 do_malloc_test init-2 -tclprep {
65 db close
66 init_wrapper_install
67 } -tclbody {
68 set rc [sqlite3_initialize]
69 if {[string match "SQLITE*NOMEM" $rc]} {error "out of memory"}
70 } -cleanup {
71 set zRepeat "transient"
72 if {$::iRepeat} {set zRepeat "persistent"}
73 do_test init-2.$zRepeat.$::n.x {
74 init_wrapper_clear
75 sqlite3_initialize
76 } SQLITE_OK
77 init_wrapper_uninstall
78 }
79}
80
dane1ab2192009-08-17 15:16:19 +000081autoinstall_test_functions
82finish_test