blob: 1a30316e31e1ba5882b9f97d61e60e94efc7f13d [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#
danielk1977a1644fd2007-08-29 12:31:25 +000013# $Id: mallocA.test,v 1.4 2007/08/29 12:31:29 danielk1977 Exp $
drhcf1be452007-05-12 12:08:51 +000014
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17
18# Only run these tests if memory debugging is turned on.
19#
drhed138fb2007-08-22 22:04:37 +000020ifcapable !memdebug {
drhcf1be452007-05-12 12:08:51 +000021 puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
22 finish_test
23 return
24}
25
drhed138fb2007-08-22 22:04:37 +000026source $testdir/malloc_common.tcl
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}
danielk1977a1644fd2007-08-29 12:31:25 +000047do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody {
drh84f31122007-05-12 15:00:14 +000048 REINDEX;
49}
danielk1977a1644fd2007-08-29 12:31:25 +000050do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody {
drh84f31122007-05-12 15:00:14 +000051 REINDEX t1;
52}
danielk1977a1644fd2007-08-29 12:31:25 +000053do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody {
drh84f31122007-05-12 15:00:14 +000054 REINDEX main.t1;
55}
danielk1977a1644fd2007-08-29 12:31:25 +000056do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody {
drh84f31122007-05-12 15:00:14 +000057 REINDEX nocase;
58}
drhcf1be452007-05-12 12:08:51 +000059
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
drhcf1be452007-05-12 12:08:51 +000067finish_test