blob: ded3d1e63347d96bc94511d6b72bc926ee712418 [file] [log] [blame]
drh344a6272006-06-26 12:50:09 +00001# 2006 June 25
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 attempts to check the library in an out-of-memory situation.
drh344a6272006-06-26 12:50:09 +000012#
drheee4c8c2008-02-18 22:24:57 +000013# $Id: malloc6.test,v 1.5 2008/02/18 22:24:58 drh Exp $
drh344a6272006-06-26 12:50:09 +000014
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
drheee4c8c2008-02-18 22:24:57 +000017source $testdir/malloc_common.tcl
drh344a6272006-06-26 12:50:09 +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 malloc6 tests: not compiled with -DSQLITE_MEMDEBUG..."
drh344a6272006-06-26 12:50:09 +000023 finish_test
24 return
25}
26
drh344a6272006-06-26 12:50:09 +000027
28set sqlite_os_trace 0
drhed138fb2007-08-22 22:04:37 +000029do_malloc_test malloc6-1 -tclprep {
drh344a6272006-06-26 12:50:09 +000030 db close
31} -tclbody {
32 if {[catch {sqlite3 db test.db}]} {
33 error "out of memory"
34 }
danielk1977ae72d982007-10-03 08:46:44 +000035 sqlite3_extended_result_codes db 1
drh344a6272006-06-26 12:50:09 +000036} -sqlbody {
37 DROP TABLE IF EXISTS t1;
38 CREATE TABLE IF NOT EXISTS t1(
39 a int, b float, c double, d text, e varchar(20),
40 primary key(a,b,c)
41 );
42 CREATE TABLE IF NOT EXISTS t1(
43 a int, b float, c double, d text, e varchar(20),
44 primary key(a,b,c)
45 );
46 DROP TABLE IF EXISTS t1;
47}
48
49# Ensure that no file descriptors were leaked.
50do_test malloc6-1.X {
51 catch {db close}
52 set sqlite_open_file_count
53} {0}
54
drh344a6272006-06-26 12:50:09 +000055finish_test