init.test 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. if {[db eval {SELECT sqlite_compileoption_used('THREADSAFE=0')}]} {
  20. finish_test
  21. return
  22. }
  23. db close
  24. foreach {t failed rc started} {
  25. 1.1 {} SQLITE_OK {mutex mem pcache}
  26. 1.2 {mutex} SQLITE_ERROR {}
  27. 1.3 {mem} SQLITE_ERROR {mutex}
  28. 1.4 {pcache} SQLITE_ERROR {mutex mem}
  29. } {
  30. do_test init-$t.1 {
  31. eval init_wrapper_install $failed
  32. sqlite3_initialize
  33. } $rc
  34. do_test init-$t.2 {
  35. init_wrapper_query
  36. } $started
  37. do_test init-$t.3 {
  38. sqlite3_shutdown
  39. init_wrapper_query
  40. } {}
  41. do_test init-$t.4 {
  42. sqlite3_initialize
  43. } $rc
  44. do_test init-$t.5 {
  45. init_wrapper_query
  46. } $started
  47. do_test init-$t.6 {
  48. init_wrapper_clear
  49. sqlite3_initialize
  50. } SQLITE_OK
  51. do_test init-$t.7 {
  52. init_wrapper_query
  53. } {mutex mem pcache}
  54. do_test init-$t.8 {
  55. init_wrapper_uninstall
  56. } {}
  57. }
  58. source $testdir/malloc_common.tcl
  59. if {$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. autoinstall_test_functions
  77. finish_test