xref: /sqlite-3.40.0/test/mallocG.test (revision eee4c8ca)
1c4dd3fd2Sdrh# 2007 Aug 29
2c4dd3fd2Sdrh#
3c4dd3fd2Sdrh# The author disclaims copyright to this source code.  In place of
4c4dd3fd2Sdrh# a legal notice, here is a blessing:
5c4dd3fd2Sdrh#
6c4dd3fd2Sdrh#    May you do good and not evil.
7c4dd3fd2Sdrh#    May you find forgiveness for yourself and forgive others.
8c4dd3fd2Sdrh#    May you share freely, never taking more than you give.
9c4dd3fd2Sdrh#
10c4dd3fd2Sdrh#***********************************************************************
11c4dd3fd2Sdrh#
12c4dd3fd2Sdrh# This test script checks malloc failures in various obscure operations.
13c4dd3fd2Sdrh#
14*eee4c8caSdrh# $Id: mallocG.test,v 1.3 2008/02/18 22:24:58 drh Exp $
15c4dd3fd2Sdrh
16c4dd3fd2Sdrhset testdir [file dirname $argv0]
17c4dd3fd2Sdrhsource $testdir/tester.tcl
18*eee4c8caSdrhsource $testdir/malloc_common.tcl
19c4dd3fd2Sdrh
20c4dd3fd2Sdrh# Only run these tests if memory debugging is turned on.
21c4dd3fd2Sdrh#
22*eee4c8caSdrhif {!$MEMDEBUG} {
23c4dd3fd2Sdrh   puts "Skipping mallocG tests: not compiled with -DSQLITE_MEMDEBUG..."
24c4dd3fd2Sdrh   finish_test
25c4dd3fd2Sdrh   return
26c4dd3fd2Sdrh}
27c4dd3fd2Sdrh
28c4dd3fd2Sdrh# Malloc failures while opening a database connection.
29c4dd3fd2Sdrh#
30c4dd3fd2Sdrhdo_malloc_test malloeG-1 -tclbody {
31c4dd3fd2Sdrh  db close
32c4dd3fd2Sdrh  sqlite3 db test.db
33c4dd3fd2Sdrh}
34c4dd3fd2Sdrh
35c4dd3fd2Sdrhdo_malloc_test mallocG-2 -sqlprep {
36c4dd3fd2Sdrh  CREATE TABLE t1(x, y);
37c4dd3fd2Sdrh  CREATE TABLE t2(x INTEGER PRIMARY KEY);
38c4dd3fd2Sdrh} -sqlbody {
39c4dd3fd2Sdrh  SELECT y FROM t1 WHERE x IN t2;
40c4dd3fd2Sdrh}
41c4dd3fd2Sdrh
4201495b99Sdrhdo_malloc_test mallocG-3 -sqlprep {
4301495b99Sdrh  CREATE TABLE t1(x UNIQUE);
4401495b99Sdrh  INSERT INTO t1 VALUES ('hello');
4501495b99Sdrh  INSERT INTO t1 VALUES ('out there');
4601495b99Sdrh} -sqlbody {
4701495b99Sdrh  SELECT * FROM t1
4801495b99Sdrh   WHERE x BETWEEN 'a' AND 'z'
4901495b99Sdrh     AND x BETWEEN 'c' AND 'w'
5001495b99Sdrh     AND x BETWEEN 'e' AND 'u'
5101495b99Sdrh     AND x BETWEEN 'g' AND 'r'
5201495b99Sdrh     AND x BETWEEN 'i' AND 'q'
5301495b99Sdrh     AND x BETWEEN 'i' AND 'm'
5401495b99Sdrh}
5501495b99Sdrh
56c4dd3fd2Sdrhfinish_test
57