blob: 66af10be23a9ef0a07ddc6804108f114ecff6e04 [file] [log] [blame]
drh762e5842005-10-03 15:11:08 +00001# 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
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21set N 300
22
23# Create a bunch of random database names
24#
25unset -nocomplain dbname
26unset -nocomplain used
27for {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#
39for {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#
52for {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#
64for {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
74finish_test