File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / sqlite3 / test / async.test
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 17:04:16 2012 UTC (12 years, 4 months ago) by misho
Branches: sqlite3, MAIN
CVS tags: v3_7_10, HEAD
sqlite3

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>