xref: /sqlite-3.40.0/test/attachmalloc.test (revision da57895f)
185c23c61Sdrh# 2005 September 19
285c23c61Sdrh#
385c23c61Sdrh# The author disclaims copyright to this source code.  In place of
485c23c61Sdrh# a legal notice, here is a blessing:
585c23c61Sdrh#
685c23c61Sdrh#    May you do good and not evil.
785c23c61Sdrh#    May you find forgiveness for yourself and forgive others.
885c23c61Sdrh#    May you share freely, never taking more than you give.
985c23c61Sdrh#
1085c23c61Sdrh#*************************************************************************
1185c23c61Sdrh# This file implements regression tests for SQLite library.  The
1285c23c61Sdrh# focus of this script is testing the ATTACH statement and
1385c23c61Sdrh# specifically out-of-memory conditions within that command.
1485c23c61Sdrh#
15*da57895fSdrh# $Id: attachmalloc.test,v 1.5 2007/08/27 23:48:24 drh Exp $
1685c23c61Sdrh#
1785c23c61Sdrh
1885c23c61Sdrhset testdir [file dirname $argv0]
1985c23c61Sdrhsource $testdir/tester.tcl
2085c23c61Sdrh
21*da57895fSdrhifcapable !memdebug {
22*da57895fSdrh  finish_test
23*da57895fSdrh  return
24*da57895fSdrh}
25*da57895fSdrh
26222a757dSdanielk1977source $testdir/malloc_common.tcl
2785c23c61Sdrh
2885c23c61Sdrhdo_malloc_test attachmalloc-1 -tclprep {
2985c23c61Sdrh  db close
3085c23c61Sdrh  for {set i 2} {$i<=4} {incr i} {
3185c23c61Sdrh    file delete -force test$i.db
3285c23c61Sdrh    file delete -force test$i.db-journal
3385c23c61Sdrh  }
3485c23c61Sdrh} -tclbody {
3585c23c61Sdrh  if {[catch {sqlite3 db test.db}]} {
3685c23c61Sdrh    error "out of memory"
3785c23c61Sdrh  }
3885c23c61Sdrh} -sqlbody {
3985c23c61Sdrh  ATTACH 'test2.db' AS two;
4085c23c61Sdrh  CREATE TABLE two.t1(x);
4185c23c61Sdrh  ATTACH 'test3.db' AS three;
4285c23c61Sdrh  CREATE TABLE three.t1(x);
4385c23c61Sdrh  ATTACH 'test4.db' AS four;
4485c23c61Sdrh  CREATE TABLE four.t1(x);
4585c23c61Sdrh}
4685c23c61Sdrh
4785c23c61Sdrhfinish_test
48