| 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 |
|
| 18 |
set testdir [file dirname $argv0] |
| 19 |
source $testdir/tester.tcl |
| 20 |
if {[db eval {SELECT sqlite_compileoption_used('THREADSAFE=0')}]} { |
| 21 |
finish_test |
| 22 |
return |
| 23 |
} |
| 24 |
|
| 25 |
db close |
| 26 |
|
| 27 |
foreach {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 $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 |
| 56 |
} {mutex mem pcache} |
| 57 |
do_test init-$t.8 { |
| 58 |
init_wrapper_uninstall |
| 59 |
} {} |
| 60 |
} |
| 61 |
|
| 62 |
source $testdir/malloc_common.tcl |
| 63 |
if {$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 |
|
| 81 |
autoinstall_test_functions |
| 82 |
finish_test |