dan | e1ab219 | 2009-08-17 15:16:19 +0000 | [diff] [blame] | 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 | # |
dan | 3d6e060 | 2009-08-17 15:52:25 +0000 | [diff] [blame] | 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 | # |
dan | e1ab219 | 2009-08-17 15:16:19 +0000 | [diff] [blame] | 17 | |
| 18 | set testdir [file dirname $argv0] |
| 19 | source $testdir/tester.tcl |
drh | acd63a5 | 2010-03-22 15:47:38 +0000 | [diff] [blame] | 20 | if {[db eval {SELECT sqlite_compileoption_used('THREADSAFE=0')}]} { |
| 21 | finish_test |
| 22 | return |
| 23 | } |
dan | e1ab219 | 2009-08-17 15:16:19 +0000 | [diff] [blame] | 24 | |
| 25 | db close |
| 26 | |
| 27 | foreach {t failed rc started} { |
dan | 3d6e060 | 2009-08-17 15:52:25 +0000 | [diff] [blame] | 28 | 1.1 {} SQLITE_OK {mutex mem pcache} |
dan | e1ab219 | 2009-08-17 15:16:19 +0000 | [diff] [blame] | 29 | 1.2 {mutex} SQLITE_ERROR {} |
| 30 | 1.3 {mem} SQLITE_ERROR {mutex} |
| 31 | 1.4 {pcache} SQLITE_ERROR {mutex mem} |
dan | e1ab219 | 2009-08-17 15:16:19 +0000 | [diff] [blame] | 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 |
dan | 3d6e060 | 2009-08-17 15:52:25 +0000 | [diff] [blame] | 56 | } {mutex mem pcache} |
dan | e1ab219 | 2009-08-17 15:16:19 +0000 | [diff] [blame] | 57 | do_test init-$t.8 { |
| 58 | init_wrapper_uninstall |
| 59 | } {} |
| 60 | } |
| 61 | |
dan | 3d6e060 | 2009-08-17 15:52:25 +0000 | [diff] [blame] | 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 | |
dan | e1ab219 | 2009-08-17 15:16:19 +0000 | [diff] [blame] | 81 | autoinstall_test_functions |
| 82 | finish_test |