System.Data.SQLite
Check-in [4e9be1fcdb]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add initial draft of test for ticket [d1fb769a8e].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-d1fb769a8e
Files: files | file ages | folders
SHA1: 4e9be1fcdb04e9d9487571763725f51be2dd59e8
User & Date: mistachkin 2013-01-17 01:47:26
Context
2013-01-17
04:59
Update SQLite core library to include the RTree error message changes. Closed-Leaf check-in: d145c7f890 user: mistachkin tags: tkt-d1fb769a8e
01:47
Add initial draft of test for ticket [d1fb769a8e]. check-in: 4e9be1fcdb user: mistachkin tags: tkt-d1fb769a8e
01:07
Fix minor whitespace issue in stress test file. check-in: d76a622544 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added Tests/tkt-d1fb769a8e.eagle.

            1  +###############################################################################
            2  +#
            3  +# tkt-d1fb769a8e.eagle --
            4  +#
            5  +# Written by Joe Mistachkin.
            6  +# Released to the public domain, use at your own risk!
            7  +#
            8  +###############################################################################
            9  +
           10  +package require Eagle
           11  +package require Eagle.Library
           12  +package require Eagle.Test
           13  +
           14  +runTestPrologue
           15  +
           16  +###############################################################################
           17  +
           18  +package require System.Data.SQLite.Test
           19  +runSQLiteTestPrologue
           20  +
           21  +###############################################################################
           22  +
           23  +runTest {test tkt-d1fb769a8e-1.1 {R*Tree virtual table creation} -setup {
           24  +  unset -nocomplain errors thread index count
           25  +  setupDb [set fileName tkt-d1fb769a8e-1.1.db]
           26  +
           27  +  proc writeToDb { fileName count delay } {
           28  +    setupDb $fileName "" "" "" "" "" true false
           29  +
           30  +    try {
           31  +      for {set index 1} {$index <= $count} {incr index} {
           32  +        after [expr {int(rand() * $delay)}]
           33  +        if {[catch {
           34  +          sql execute $db "CREATE TABLE t${index}(x);"
           35  +          sql execute $db "INSERT INTO t1 (x) VALUES(${index});"
           36  +        } error]} then {
           37  +          incr ::errors(0)
           38  +          tputs $::test_channel [appendArgs \
           39  +              \n "---- INSERT error: " \n\t $error \n]
           40  +        }
           41  +      }
           42  +    } finally {
           43  +      cleanupDb $fileName db true false false
           44  +    }
           45  +  }
           46  +
           47  +  proc createRTreeTable { fileName count delay } {
           48  +    setupDb $fileName "" "" "" "" "" true false
           49  +
           50  +    try {
           51  +      for {set index 1} {$index <= $count} {incr index} {
           52  +        after [expr {int(rand() * $delay)}]
           53  +        if {[catch {
           54  +          sql execute $db [subst {
           55  +            CREATE VIRTUAL TABLE IF NOT EXISTS test${index} USING rtree(
           56  +              id, minX, maxX, minY, maxY
           57  +            );
           58  +          }]
           59  +        } error]} then {
           60  +          incr ::errors(1)
           61  +          tputs $::test_channel [appendArgs \
           62  +              \n "---- CREATE VIRTUAL TABLE error: " \n\t $error \n]
           63  +        }
           64  +      }
           65  +    } finally {
           66  +      cleanupDb $fileName db true false false
           67  +    }
           68  +  }
           69  +} -body {
           70  +  set errors(0) 0;   # total number of INSERT errors.
           71  +  set errors(1) 0;   # total number of R*Tree errors.
           72  +  set count(0) 2;    # total number of test threads.
           73  +  set count(1) 1000; # total number of iterations per test thread.
           74  +  set count(2) 500;  # maximum milliseconds between test thread iterations.
           75  +
           76  +  tputs $test_channel [appendArgs \
           77  +      "==== WARNING: this test may take several minutes...\n"]
           78  +
           79  +  for {set index(0) 1} {$index(0) <= $count(0)} {incr index(0)} {
           80  +    set thread($index(0)) [object create -alias System.Threading.Thread \
           81  +        [list [expr {$index(0) % 2 == 0 ? "createRTreeTable" : "writeToDb"}] \
           82  +        $fileName $count(1) $count(2)] 1048576]
           83  +
           84  +    $thread($index(0)) Name [appendArgs \
           85  +        [file rootname [file tail $fileName]] " #" $index(0)]
           86  +  }
           87  +
           88  +  foreach index(0) [list Start Join] {
           89  +    foreach index(1) [array names thread] {
           90  +      $thread($index(1)) $index(0)
           91  +    }
           92  +  }
           93  +
           94  +  foreach index(0) [array names thread] {
           95  +    if {[info exists thread($index(0))] && \
           96  +        [cleanupThread $thread($index(0))]} then {
           97  +      unset -nocomplain thread($index(0))
           98  +    }
           99  +  }
          100  +
          101  +  list $errors(0) $errors(1)
          102  +} -cleanup {
          103  +  foreach index [array names thread] {
          104  +    if {[info exists thread($index)] && \
          105  +        [cleanupThread $thread($index)]} then {
          106  +      unset -nocomplain thread($index)
          107  +    }
          108  +  }
          109  +
          110  +  rename createRTreeTable ""
          111  +  rename writeToDb ""
          112  +
          113  +  catch {
          114  +    object removecallback [list \
          115  +        createRTreeTable $fileName $count(1) $count(2)]
          116  +  }
          117  +  catch {
          118  +    object removecallback [list \
          119  +        writeToDb $fileName $count(1) $count(2)]
          120  +  }
          121  +
          122  +  cleanupDb $fileName
          123  +
          124  +  unset -nocomplain errors thread index count db fileName
          125  +} -time true -constraints \
          126  +{eagle monoBug28 defineConstant.System.Data.SQLite.INTEROP_TEST_EXTENSION\
          127  +command.sql compile.DATA SQLite System.Data.SQLite} -result {0 0}}
          128  +
          129  +###############################################################################
          130  +
          131  +runSQLiteTestEpilogue
          132  +runTestEpilogue