drh | 762e584 | 2005-10-03 15:11:08 +0000 | [diff] [blame^] | 1 | # 2005 October 3 |
| 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 | # This file implements regression tests for SQLite library. |
| 12 | # |
| 13 | # This file implements tests the ability of the library to open |
| 14 | # many different databases at the same time without leaking memory. |
| 15 | # |
| 16 | # $Id: manydb.test,v 1.1 2005/10/03 15:11:09 drh Exp $ |
| 17 | |
| 18 | set testdir [file dirname $argv0] |
| 19 | source $testdir/tester.tcl |
| 20 | |
| 21 | set N 300 |
| 22 | |
| 23 | # Create a bunch of random database names |
| 24 | # |
| 25 | unset -nocomplain dbname |
| 26 | unset -nocomplain used |
| 27 | for {set i 0} {$i<$N} {incr i} { |
| 28 | while 1 { |
| 29 | set name test-[format %08x [expr {int(rand()*0x7fffffff)}]].db |
| 30 | if {[info exists used($name)]} continue |
| 31 | set dbname($i) $name |
| 32 | set used($name) $i |
| 33 | break |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | # Create a bunch of databases |
| 38 | # |
| 39 | for {set i 0} {$i<$N} {incr i} { |
| 40 | do_test manydb-1.$i { |
| 41 | sqlite3 db$i $dbname($i) |
| 42 | execsql { |
| 43 | CREATE TABLE t1(a,b); |
| 44 | BEGIN; |
| 45 | INSERT INTO t1 VALUES(1,2); |
| 46 | } db$i |
| 47 | } {} |
| 48 | } |
| 49 | |
| 50 | # Finish the transactions |
| 51 | # |
| 52 | for {set i 0} {$i<$N} {incr i} { |
| 53 | do_test manydb-2.$i { |
| 54 | execsql { |
| 55 | COMMIT; |
| 56 | SELECT * FROM t1; |
| 57 | } db$i |
| 58 | } {1 2} |
| 59 | } |
| 60 | |
| 61 | |
| 62 | # Close the databases and erase the files. |
| 63 | # |
| 64 | for {set i 0} {$i<$N} {incr i} { |
| 65 | do_test manydb-3.$i { |
| 66 | db$i close |
| 67 | file delete -force $dbname($i) |
| 68 | } {} |
| 69 | } |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | finish_test |