sl@0: # 2006 June 25
sl@0: #
sl@0: # The author disclaims copyright to this source code.  In place of
sl@0: # a legal notice, here is a blessing:
sl@0: #
sl@0: #    May you do good and not evil.
sl@0: #    May you find forgiveness for yourself and forgive others.
sl@0: #    May you share freely, never taking more than you give.
sl@0: #
sl@0: #***********************************************************************
sl@0: # This file attempts to check the library in an out-of-memory situation.
sl@0: #
sl@0: # $Id: malloc6.test,v 1.5 2008/02/18 22:24:58 drh Exp $
sl@0: 
sl@0: set testdir [file dirname $argv0]
sl@0: source $testdir/tester.tcl
sl@0: source $testdir/malloc_common.tcl
sl@0: 
sl@0: # Only run these tests if memory debugging is turned on.
sl@0: #
sl@0: if {!$MEMDEBUG} {
sl@0:    puts "Skipping malloc6 tests: not compiled with -DSQLITE_MEMDEBUG..."
sl@0:    finish_test
sl@0:    return
sl@0: }
sl@0: 
sl@0: 
sl@0: set sqlite_os_trace 0
sl@0: do_malloc_test malloc6-1 -tclprep {
sl@0:   db close
sl@0: } -tclbody {
sl@0:   if {[catch {sqlite3 db test.db}]} {
sl@0:     error "out of memory"
sl@0:   }
sl@0:   sqlite3_extended_result_codes db 1
sl@0: } -sqlbody {
sl@0:   DROP TABLE IF EXISTS t1;
sl@0:   CREATE TABLE IF NOT EXISTS t1(
sl@0:      a int, b float, c double, d text, e varchar(20),
sl@0:      primary key(a,b,c)
sl@0:   );
sl@0:   CREATE TABLE IF NOT EXISTS t1(
sl@0:      a int, b float, c double, d text, e varchar(20),
sl@0:      primary key(a,b,c)
sl@0:   );
sl@0:   DROP TABLE IF EXISTS t1;
sl@0: } 
sl@0: 
sl@0: # Ensure that no file descriptors were leaked.
sl@0: do_test malloc6-1.X {
sl@0:   catch {db close}
sl@0:   set sqlite_open_file_count
sl@0: } {0}
sl@0: 
sl@0: finish_test