xref: /sqlite-3.40.0/test/attachmalloc.test (revision da57895f)
1# 2005 September 19
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.  The
12# focus of this script is testing the ATTACH statement and
13# specifically out-of-memory conditions within that command.
14#
15# $Id: attachmalloc.test,v 1.5 2007/08/27 23:48:24 drh Exp $
16#
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21ifcapable !memdebug {
22  finish_test
23  return
24}
25
26source $testdir/malloc_common.tcl
27
28do_malloc_test attachmalloc-1 -tclprep {
29  db close
30  for {set i 2} {$i<=4} {incr i} {
31    file delete -force test$i.db
32    file delete -force test$i.db-journal
33  }
34} -tclbody {
35  if {[catch {sqlite3 db test.db}]} {
36    error "out of memory"
37  }
38} -sqlbody {
39  ATTACH 'test2.db' AS two;
40  CREATE TABLE two.t1(x);
41  ATTACH 'test3.db' AS three;
42  CREATE TABLE three.t1(x);
43  ATTACH 'test4.db' AS four;
44  CREATE TABLE four.t1(x);
45}
46
47finish_test
48