blob: 08f6930215f53e6f9041181129d7e833359c60f3 [file] [log] [blame]
drhcf1be452007-05-12 12:08:51 +00001# 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#
drheee4c8c2008-02-18 22:24:57 +000013# $Id: mallocA.test,v 1.8 2008/02/18 22:24:58 drh Exp $
drhcf1be452007-05-12 12:08:51 +000014
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
drheee4c8c2008-02-18 22:24:57 +000017source $testdir/malloc_common.tcl
drhcf1be452007-05-12 12:08:51 +000018
19# Only run these tests if memory debugging is turned on.
20#
drheee4c8c2008-02-18 22:24:57 +000021if {!$MEMDEBUG} {
drh5a3032b2007-09-03 16:12:09 +000022 puts "Skipping mallocA tests: not compiled with -DSQLITE_MEMDEBUG..."
drhcf1be452007-05-12 12:08:51 +000023 finish_test
24 return
25}
26
drhcf1be452007-05-12 12:08:51 +000027
28# Construct a test database
29#
30file delete -force test.db.bu
31db eval {
drh84f31122007-05-12 15:00:14 +000032 CREATE TABLE t1(a COLLATE NOCASE,b,c);
drhcf1be452007-05-12 12:08:51 +000033 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
drhcf1be452007-05-12 12:08:51 +000042
43
danielk1977a1644fd2007-08-29 12:31:25 +000044do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody {
drhcf1be452007-05-12 12:08:51 +000045 ANALYZE
46}
danielk1977b8b4bfa2007-11-15 13:10:22 +000047do_malloc_test mallocA-1.1 -testdb test.db.bu -sqlbody {
48 ANALYZE t1
49}
50do_malloc_test mallocA-1.2 -testdb test.db.bu -sqlbody {
51 ANALYZE main
52}
53do_malloc_test mallocA-1.3 -testdb test.db.bu -sqlbody {
54 ANALYZE main.t1
55}
danielk19774152e672007-09-12 17:01:45 +000056ifcapable reindex {
57 do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody {
58 REINDEX;
59 }
60 do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody {
61 REINDEX t1;
62 }
63 do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody {
64 REINDEX main.t1;
65 }
66 do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody {
67 REINDEX nocase;
68 }
drh84f31122007-05-12 15:00:14 +000069}
drhcf1be452007-05-12 12:08:51 +000070
71# Ensure that no file descriptors were leaked.
72do_test malloc-99.X {
73 catch {db close}
74 set sqlite_open_file_count
75} {0}
76
77file delete -force test.db.bu
drhcf1be452007-05-12 12:08:51 +000078finish_test