1# 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# 12# 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# 17 18set testdir [file dirname $argv0] 19source $testdir/tester.tcl 20 21db close 22 23foreach {t failed rc started} { 24 1.1 {} SQLITE_OK {mutex mem pcache} 25 1.2 {mutex} SQLITE_ERROR {} 26 1.3 {mem} SQLITE_ERROR {mutex} 27 1.4 {pcache} SQLITE_ERROR {mutex mem} 28} { 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 52 } {mutex mem pcache} 53 do_test init-$t.8 { 54 init_wrapper_uninstall 55 } {} 56} 57 58source $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 77autoinstall_test_functions 78finish_test 79 80