1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Add some extra tests for malloc failure during expression parsing and execution using fuzzily generated SQL. (CVS 4043)

FossilOrigin-Name: 7522d2fb3204d107b8b4816d7f39c88741f20230
This commit is contained in:
danielk1977
2007-05-30 10:36:47 +00:00
parent 5453b8da9e
commit c9cf901d8c
13 changed files with 624 additions and 500 deletions

53
test/fuzz_malloc.test Normal file
View File

@ -0,0 +1,53 @@
#
# 2007 May 10
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file tests malloc failures in concert with fuzzy SQL generation.
#
# $Id: fuzz_malloc.test,v 1.1 2007/05/30 10:36:47 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/fuzz_common.tcl
source $testdir/malloc_common.tcl
set ::REPEATS 20
#
# Usage: do_fuzzy_malloc_test <testname> ?<options>?
#
# -template
# -repeats
#
proc do_fuzzy_malloc_test {testname args} {
set ::fuzzyopts(-repeats) $::REPEATS
array set ::fuzzyopts $args
for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {
set ::sql [subst $::fuzzyopts(-template)]
# puts $::sql
foreach {rc res} [catchsql $::sql] {}
if {$rc==0} {
do_malloc_test $testname-$ii -sqlbody $::sql
} else {
incr ii -1
}
}
}
#----------------------------------------------------------------
# Test malloc failure during parsing (and execution) of a fuzzily
# generated expressions.
#
do_fuzzy_malloc_test fuzzy_malloc-1 -template {Select [Expr]}
sqlite_malloc_fail 0
finish_test