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

Extend out-of-memory testing with fuzzily generated sql some. One fix for a problem found by the same. (CVS 4044)

FossilOrigin-Name: d2282e64f1320913797dfb4dae4db0428a15a200
This commit is contained in:
danielk1977
2007-05-31 08:20:43 +00:00
parent c9cf901d8c
commit 9afe689ea4
5 changed files with 48 additions and 15 deletions

View File

@ -12,7 +12,7 @@
#
# 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 $
# $Id: fuzz_malloc.test,v 1.2 2007/05/31 08:20:44 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -25,18 +25,26 @@ set ::REPEATS 20
# Usage: do_fuzzy_malloc_test <testname> ?<options>?
#
# -template
# -sqlprep
# -repeats
#
proc do_fuzzy_malloc_test {testname args} {
set ::fuzzyopts(-repeats) $::REPEATS
set ::fuzzyopts(-sqlprep) {}
array set ::fuzzyopts $args
sqlite_malloc_fail 0
db close
file delete test.db test.db-journal
sqlite3 db test.db
set ::prep $::fuzzyopts(-sqlprep)
execsql $::prep
for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {
set ::sql [subst $::fuzzyopts(-template)]
# puts $::sql
foreach {rc res} [catchsql $::sql] {}
foreach {rc res} [catchsql "$::sql"] {}
if {$rc==0} {
do_malloc_test $testname-$ii -sqlbody $::sql
do_malloc_test $testname-$ii -sqlbody $::sql -sqlprep $::prep
} else {
incr ii -1
}
@ -48,6 +56,26 @@ proc do_fuzzy_malloc_test {testname args} {
# generated expressions.
#
do_fuzzy_malloc_test fuzzy_malloc-1 -template {Select [Expr]}
do_fuzzy_malloc_test fuzzy_malloc-2 -template {[Select]}
set ::SQLPREP {
BEGIN;
CREATE TABLE abc(a, b, c);
CREATE TABLE def(a, b, c);
CREATE TABLE ghi(a, b, c);
INSERT INTO abc VALUES(1.5, 3, 'a short string');
INSERT INTO def VALUES(NULL, X'ABCDEF',
'a longer string. Long enough that it doesn''t fit in Mem.zShort');
INSERT INTO ghi VALUES(zeroblob(1000), 'hello world', -1257900987654321);
COMMIT;
}
set ::TableList [list abc def ghi]
set ::ColumnList [list a b c]
do_fuzzy_malloc_test fuzzy_malloc-3 \
-template {[Select]} \
-sqlprep $::SQLPREP
sqlite_malloc_fail 0
finish_test

View File

@ -12,7 +12,7 @@
# These were all discovered by fuzzy generation of SQL. Apart from
# that they have little in common.
#
# $Id: mallocB.test,v 1.1 2007/05/30 10:36:47 danielk1977 Exp $
# $Id: mallocB.test,v 1.2 2007/05/31 08:20:44 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -30,6 +30,7 @@ do_malloc_test mallocB-1 -sqlbody {SELECT - 456}
do_malloc_test mallocB-2 -sqlbody {SELECT - 456.1}
do_malloc_test mallocB-3 -sqlbody {SELECT random()}
do_malloc_test mallocB-4 -sqlbody {SELECT zeroblob(1000)}
do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;}
sqlite_malloc_fail 0
finish_test