AryaWu/sqlite
0
1# 2001 September 152#3# The author disclaims copyright to this source code. In place of4# 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. The13# 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.tcl20if {[db eval {SELECT sqlite_compileoption_used('THREADSAFE=0')}]} {21 finish_test22 return23}24 25db close26 27foreach {t failed rc started} {28 1.1 {} SQLITE_OK {mutex mem pcache}29 1.2 {mutex} SQLITE_ERROR {}30 1.3 {mem} SQLITE_ERROR {mutex}31 1.4 {pcache} SQLITE_ERROR {mutex mem}32} {33 do_test init-$t.1 {34 eval init_wrapper_install $failed35 sqlite3_initialize36 } $rc37 do_test init-$t.2 {38 init_wrapper_query39 } $started40 do_test init-$t.3 {41 sqlite3_shutdown42 init_wrapper_query43 } {}44 do_test init-$t.4 {45 sqlite3_initialize46 } $rc47 do_test init-$t.5 {48 init_wrapper_query49 } $started50 do_test init-$t.6 {51 init_wrapper_clear52 sqlite3_initialize53 } SQLITE_OK54 do_test init-$t.7 {55 init_wrapper_query56 } {mutex mem pcache}57 do_test init-$t.8 {58 init_wrapper_uninstall59 } {}60}61 62source $testdir/malloc_common.tcl63if {$MEMDEBUG} {64 do_malloc_test init-2 -tclprep {65 db close66 init_wrapper_install67 } -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_clear75 sqlite3_initialize76 } SQLITE_OK77 init_wrapper_uninstall78 }79}80 81autoinstall_test_functions82finish_test83 