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 Unified Diffs Ignore Whitespace Patch

Added Tests/tkt-d1fb769a8e.eagle.









































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
###############################################################################
#
# tkt-d1fb769a8e.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

package require Eagle
package require Eagle.Library
package require Eagle.Test

runTestPrologue

###############################################################################

package require System.Data.SQLite.Test
runSQLiteTestPrologue

###############################################################################

runTest {test tkt-d1fb769a8e-1.1 {R*Tree virtual table creation} -setup {
  unset -nocomplain errors thread index count
  setupDb [set fileName tkt-d1fb769a8e-1.1.db]

  proc writeToDb { fileName count delay } {
    setupDb $fileName "" "" "" "" "" true false

    try {
      for {set index 1} {$index <= $count} {incr index} {
        after [expr {int(rand() * $delay)}]
        if {[catch {
          sql execute $db "CREATE TABLE t${index}(x);"
          sql execute $db "INSERT INTO t1 (x) VALUES(${index});"
        } error]} then {
          incr ::errors(0)
          tputs $::test_channel [appendArgs \
              \n "---- INSERT error: " \n\t $error \n]
        }
      }
    } finally {
      cleanupDb $fileName db true false false
    }
  }

  proc createRTreeTable { fileName count delay } {
    setupDb $fileName "" "" "" "" "" true false

    try {
      for {set index 1} {$index <= $count} {incr index} {
        after [expr {int(rand() * $delay)}]
        if {[catch {
          sql execute $db [subst {
            CREATE VIRTUAL TABLE IF NOT EXISTS test${index} USING rtree(
              id, minX, maxX, minY, maxY
            );
          }]
        } error]} then {
          incr ::errors(1)
          tputs $::test_channel [appendArgs \
              \n "---- CREATE VIRTUAL TABLE error: " \n\t $error \n]
        }
      }
    } finally {
      cleanupDb $fileName db true false false
    }
  }
} -body {
  set errors(0) 0;   # total number of INSERT errors.
  set errors(1) 0;   # total number of R*Tree errors.
  set count(0) 2;    # total number of test threads.
  set count(1) 1000; # total number of iterations per test thread.
  set count(2) 500;  # maximum milliseconds between test thread iterations.

  tputs $test_channel [appendArgs \
      "==== WARNING: this test may take several minutes...\n"]

  for {set index(0) 1} {$index(0) <= $count(0)} {incr index(0)} {
    set thread($index(0)) [object create -alias System.Threading.Thread \
        [list [expr {$index(0) % 2 == 0 ? "createRTreeTable" : "writeToDb"}] \
        $fileName $count(1) $count(2)] 1048576]

    $thread($index(0)) Name [appendArgs \
        [file rootname [file tail $fileName]] " #" $index(0)]
  }

  foreach index(0) [list Start Join] {
    foreach index(1) [array names thread] {
      $thread($index(1)) $index(0)
    }
  }

  foreach index(0) [array names thread] {
    if {[info exists thread($index(0))] && \
        [cleanupThread $thread($index(0))]} then {
      unset -nocomplain thread($index(0))
    }
  }

  list $errors(0) $errors(1)
} -cleanup {
  foreach index [array names thread] {
    if {[info exists thread($index)] && \
        [cleanupThread $thread($index)]} then {
      unset -nocomplain thread($index)
    }
  }

  rename createRTreeTable ""
  rename writeToDb ""

  catch {
    object removecallback [list \
        createRTreeTable $fileName $count(1) $count(2)]
  }
  catch {
    object removecallback [list \
        writeToDb $fileName $count(1) $count(2)]
  }

  cleanupDb $fileName

  unset -nocomplain errors thread index count db fileName
} -time true -constraints \
{eagle monoBug28 defineConstant.System.Data.SQLite.INTEROP_TEST_EXTENSION\
command.sql compile.DATA SQLite System.Data.SQLite} -result {0 0}}

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue