1
0

async.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #
  2. # May you do good and not evil.
  3. # May you find forgiveness for yourself and forgive others.
  4. # May you share freely, never taking more than you give.
  5. #
  6. #***********************************************************************
  7. # This file runs all tests.
  8. #
  9. # $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $
  10. set testdir [file dirname $argv0]
  11. source $testdir/tester.tcl
  12. if {[info commands sqlite3async_initialize] eq ""} {
  13. # The async logic is not built into this system
  14. finish_test
  15. return
  16. }
  17. rename finish_test async_really_finish_test
  18. proc finish_test {} {
  19. catch {db close}
  20. catch {db2 close}
  21. catch {db3 close}
  22. }
  23. if {[info exists G(isquick)]} { set ASYNC_SAVE_ISQUICK $G(isquick) }
  24. set G(isquick) 1
  25. set ASYNC_INCLUDE {
  26. insert.test
  27. insert2.test
  28. insert3.test
  29. lock.test
  30. lock2.test
  31. lock3.test
  32. select1.test
  33. select2.test
  34. select3.test
  35. select4.test
  36. trans.test
  37. }
  38. # Enable asynchronous IO.
  39. sqlite3async_initialize "" 1
  40. # This proc flushes the contents of the async-IO queue through to the
  41. # underlying VFS. A couple of the test scripts identified in $ASYNC_INCLUDE
  42. # above contain lines like "catch flush_async_queue" in places where
  43. # this is required for the tests to work in async mode.
  44. #
  45. proc flush_async_queue {} {
  46. sqlite3async_control halt idle
  47. sqlite3async_start
  48. sqlite3async_wait
  49. sqlite3async_control halt never
  50. }
  51. rename do_test async_really_do_test
  52. proc do_test {name args} {
  53. uplevel async_really_do_test async_io-$name $args
  54. flush_async_queue
  55. }
  56. foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
  57. set tail [file tail $testfile]
  58. if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue
  59. source $testfile
  60. # Make sure everything is flushed through. This is because [source]ing
  61. # the next test file will delete the database file on disk (using
  62. # [delete_file]). If the asynchronous backend still has the file
  63. # open, it will become confused.
  64. #
  65. flush_async_queue
  66. }
  67. # Flush the write-queue and disable asynchronous IO. This should ensure
  68. # all allocated memory is cleaned up.
  69. set sqlite3async_trace 1
  70. flush_async_queue
  71. sqlite3async_shutdown
  72. set sqlite3async_trace 0
  73. rename do_test {}
  74. rename async_really_do_test do_test
  75. rename finish_test {}
  76. rename async_really_finish_test finish_test
  77. if {[info exists ASYNC_SAVE_ISQUICK]} { set G(isquick) $ASYNC_SAVE_ISQUICK }
  78. finish_test