xref: /sqlite-3.40.0/test/mallocB.test (revision eee4c8ca)
1c9cf901dSdanielk1977# 2007 May 30
2c9cf901dSdanielk1977#
3c9cf901dSdanielk1977# The author disclaims copyright to this source code.  In place of
4c9cf901dSdanielk1977# a legal notice, here is a blessing:
5c9cf901dSdanielk1977#
6c9cf901dSdanielk1977#    May you do good and not evil.
7c9cf901dSdanielk1977#    May you find forgiveness for yourself and forgive others.
8c9cf901dSdanielk1977#    May you share freely, never taking more than you give.
9c9cf901dSdanielk1977#
10c9cf901dSdanielk1977#***********************************************************************
11c9cf901dSdanielk1977# This file contains additional out-of-memory checks (see malloc.tcl).
12c9cf901dSdanielk1977# These were all discovered by fuzzy generation of SQL. Apart from
13c9cf901dSdanielk1977# that they have little in common.
14c9cf901dSdanielk1977#
15e0fc5261Sdanielk1977#
16*eee4c8caSdrh# $Id: mallocB.test,v 1.9 2008/02/18 22:24:58 drh Exp $
17c9cf901dSdanielk1977
18c9cf901dSdanielk1977set testdir [file dirname $argv0]
19c9cf901dSdanielk1977source $testdir/tester.tcl
20c9cf901dSdanielk1977source $testdir/malloc_common.tcl
21c9cf901dSdanielk1977
22c9cf901dSdanielk1977# Only run these tests if memory debugging is turned on.
23c9cf901dSdanielk1977#
24*eee4c8caSdrhif {!$MEMDEBUG} {
255a3032b3Sdrh   puts "Skipping mallocB tests: not compiled with -DSQLITE_MEMDEBUG..."
26c9cf901dSdanielk1977   finish_test
27c9cf901dSdanielk1977   return
28c9cf901dSdanielk1977}
29ed138fb3Sdrhsource $testdir/malloc_common.tcl
30c9cf901dSdanielk1977
31c9cf901dSdanielk1977do_malloc_test mallocB-1 -sqlbody {SELECT - 456}
32c9cf901dSdanielk1977do_malloc_test mallocB-2 -sqlbody {SELECT - 456.1}
33c9cf901dSdanielk1977do_malloc_test mallocB-3 -sqlbody {SELECT random()}
34a7a8e14bSdanielk1977do_malloc_test mallocB-4 -sqlbody {SELECT length(zeroblob(1000))}
354152e677Sdanielk1977ifcapable subquery {
369afe689eSdanielk1977  do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;}
374152e677Sdanielk1977}
38c9cf901dSdanielk1977
39e0fc5261Sdanielk1977# The following test checks that there are no resource leaks following a
40e0fc5261Sdanielk1977# malloc() failure in sqlite3_set_auxdata().
41e0fc5261Sdanielk1977#
42e0fc5261Sdanielk1977# Note: This problem was not discovered by fuzzy generation of SQL. Not
43e0fc5261Sdanielk1977# that it really matters.
44e0fc5261Sdanielk1977#
45e0fc5261Sdanielk1977do_malloc_test mallocB-6 -sqlbody { SELECT test_auxdata('hello world'); }
46e0fc5261Sdanielk1977
473334e948Sdrhdo_malloc_test mallocB-7 -sqlbody {
483334e948Sdrh  SELECT strftime(hex(randomblob(50)) || '%Y', 'now')
493334e948Sdrh}
503334e948Sdrh
51c9cf901dSdanielk1977finish_test
52