1# 2007 April 30 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 contains additional out-of-memory checks (see malloc.tcl). 12# 13# $Id: mallocA.test,v 1.3 2007/08/22 22:04:37 drh Exp $ 14 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17 18# Only run these tests if memory debugging is turned on. 19# 20ifcapable !memdebug { 21 puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..." 22 finish_test 23 return 24} 25 26source $testdir/malloc_common.tcl 27 28# Construct a test database 29# 30file delete -force test.db.bu 31db eval { 32 CREATE TABLE t1(a COLLATE NOCASE,b,c); 33 INSERT INTO t1 VALUES(1,2,3); 34 INSERT INTO t1 VALUES(1,2,4); 35 INSERT INTO t1 VALUES(2,3,4); 36 CREATE INDEX t1i1 ON t1(a); 37 CREATE INDEX t1i2 ON t1(b,c); 38 CREATE TABLE t2(x,y,z); 39} 40db close 41file copy test.db test.db.bu 42 43 44do_malloc_test 1 -testdb test.db.bu -sqlbody { 45 ANALYZE 46} 47do_malloc_test 2 -testdb test.db.bu -sqlbody { 48 REINDEX; 49} 50do_malloc_test 3 -testdb test.db.bu -sqlbody { 51 REINDEX t1; 52} 53do_malloc_test 4 -testdb test.db.bu -sqlbody { 54 REINDEX main.t1; 55} 56do_malloc_test 5 -testdb test.db.bu -sqlbody { 57 REINDEX nocase; 58} 59 60# Ensure that no file descriptors were leaked. 61do_test malloc-99.X { 62 catch {db close} 63 set sqlite_open_file_count 64} {0} 65 66file delete -force test.db.bu 67finish_test 68