sl@0: # 2007 Aug 29 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: # sl@0: # This test script checks malloc failures in various obscure operations. sl@0: # sl@0: # $Id: mallocG.test,v 1.5 2008/08/01 18:47:02 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 mallocG tests: not compiled with -DSQLITE_MEMDEBUG..." sl@0: finish_test sl@0: return sl@0: } sl@0: sl@0: # Malloc failures while opening a database connection. sl@0: # sl@0: do_malloc_test mallocG-1 -tclbody { sl@0: db close sl@0: sqlite3 db test.db sl@0: } sl@0: sl@0: do_malloc_test mallocG-2 -sqlprep { sl@0: CREATE TABLE t1(x, y); sl@0: CREATE TABLE t2(x INTEGER PRIMARY KEY); sl@0: } -sqlbody { sl@0: SELECT y FROM t1 WHERE x IN t2; sl@0: } sl@0: sl@0: do_malloc_test mallocG-3 -sqlprep { sl@0: CREATE TABLE t1(x UNIQUE); sl@0: INSERT INTO t1 VALUES ('hello'); sl@0: INSERT INTO t1 VALUES ('out there'); sl@0: } -sqlbody { sl@0: SELECT * FROM t1 sl@0: WHERE x BETWEEN 'a' AND 'z' sl@0: AND x BETWEEN 'c' AND 'w' sl@0: AND x BETWEEN 'e' AND 'u' sl@0: AND x BETWEEN 'g' AND 'r' sl@0: AND x BETWEEN 'i' AND 'q' sl@0: AND x BETWEEN 'i' AND 'm' sl@0: } sl@0: sl@0: proc utf16 {utf8} { sl@0: set utf16 [encoding convertto unicode $utf8] sl@0: append utf16 "\x00\x00" sl@0: return $utf16 sl@0: } sl@0: sl@0: do_malloc_test mallocG-4 -tclbody { sl@0: set rc [sqlite3_complete16 [utf16 "SELECT * FROM t1;"]] sl@0: if {$rc==1} {set rc 0} {error "out of memory"} sl@0: set rc sl@0: } sl@0: sl@0: finish_test