1# 2# 2007 May 10 3# 4# The author disclaims copyright to this source code. In place of 5# a legal notice, here is a blessing: 6# 7# May you do good and not evil. 8# May you find forgiveness for yourself and forgive others. 9# May you share freely, never taking more than you give. 10# 11#*********************************************************************** 12# 13# This file tests malloc failures in concert with fuzzy SQL generation. 14# 15# $Id: fuzz_malloc.test,v 1.1 2007/05/30 10:36:47 danielk1977 Exp $ 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19source $testdir/fuzz_common.tcl 20source $testdir/malloc_common.tcl 21 22set ::REPEATS 20 23 24# 25# Usage: do_fuzzy_malloc_test <testname> ?<options>? 26# 27# -template 28# -repeats 29# 30proc do_fuzzy_malloc_test {testname args} { 31 set ::fuzzyopts(-repeats) $::REPEATS 32 array set ::fuzzyopts $args 33 34 for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} { 35 set ::sql [subst $::fuzzyopts(-template)] 36 # puts $::sql 37 foreach {rc res} [catchsql $::sql] {} 38 if {$rc==0} { 39 do_malloc_test $testname-$ii -sqlbody $::sql 40 } else { 41 incr ii -1 42 } 43 } 44} 45 46#---------------------------------------------------------------- 47# Test malloc failure during parsing (and execution) of a fuzzily 48# generated expressions. 49# 50do_fuzzy_malloc_test fuzzy_malloc-1 -template {Select [Expr]} 51 52sqlite_malloc_fail 0 53finish_test 54