aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/test/manydb.test
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/manydb.test')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/test/manydb.test91
1 files changed, 91 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/manydb.test b/libraries/sqlite/unix/sqlite-3.5.1/test/manydb.test
new file mode 100644
index 0000000..9af5465
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/test/manydb.test
@@ -0,0 +1,91 @@
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.3 2006/01/11 01:08:34 drh Exp $
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21set N 300
22
23# First test how many file descriptors are available for use. To open a
24# database for writing SQLite requires 3 file descriptors (the database, the
25# journal and the directory).
26set filehandles {}
27catch {
28 for {set i 0} {$i<($N * 3)} {incr i} {
29 lappend filehandles [open testfile.1 w]
30 }
31}
32foreach fd $filehandles {
33 close $fd
34}
35catch {
36 file delete -force testfile.1
37}
38set N [expr $i / 3]
39
40# Create a bunch of random database names
41#
42unset -nocomplain dbname
43unset -nocomplain used
44for {set i 0} {$i<$N} {incr i} {
45 while 1 {
46 set name test-[format %08x [expr {int(rand()*0x7fffffff)}]].db
47 if {[info exists used($name)]} continue
48 set dbname($i) $name
49 set used($name) $i
50 break
51 }
52}
53
54# Create a bunch of databases
55#
56for {set i 0} {$i<$N} {incr i} {
57 do_test manydb-1.$i {
58 sqlite3 db$i $dbname($i)
59 execsql {
60 CREATE TABLE t1(a,b);
61 BEGIN;
62 INSERT INTO t1 VALUES(1,2);
63 } db$i
64 } {}
65}
66
67# Finish the transactions
68#
69for {set i 0} {$i<$N} {incr i} {
70 do_test manydb-2.$i {
71 execsql {
72 COMMIT;
73 SELECT * FROM t1;
74 } db$i
75 } {1 2}
76}
77
78
79# Close the databases and erase the files.
80#
81for {set i 0} {$i<$N} {incr i} {
82 do_test manydb-3.$i {
83 db$i close
84 file delete -force $dbname($i)
85 } {}
86}
87
88
89
90
91finish_test