aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/test/fuzz_malloc.test
diff options
context:
space:
mode:
authordan miller2007-10-20 02:49:29 +0000
committerdan miller2007-10-20 02:49:29 +0000
commite36d23a85ebff914d74bb541558c2b6082b78edb (patch)
tree54b58fdf162e78af64055282a6035c8d2443389d /libraries/sqlite/unix/sqlite-3.5.1/test/fuzz_malloc.test
parent* Fixed an issue whereby avatar chat distances were being calculated against ... (diff)
downloadopensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.zip
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.gz
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.bz2
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.xz
sqlite source (unix build) added to libraries
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/fuzz_malloc.test')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/test/fuzz_malloc.test93
1 files changed, 93 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/fuzz_malloc.test b/libraries/sqlite/unix/sqlite-3.5.1/test/fuzz_malloc.test
new file mode 100644
index 0000000..2d78807
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/test/fuzz_malloc.test
@@ -0,0 +1,93 @@
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.9 2007/09/03 15:42:48 drh Exp $
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20ifcapable !memdebug {
21 finish_test
22 return
23}
24
25source $testdir/malloc_common.tcl
26source $testdir/fuzz_common.tcl
27
28if {[info exists ISQUICK]} {
29 set ::REPEATS 20
30} elseif {[info exists SOAKTEST]} {
31 set ::REPEATS 100
32} else {
33 set ::REPEATS 40
34}
35
36#
37# Usage: do_fuzzy_malloc_test <testname> ?<options>?
38#
39# -template
40# -sqlprep
41# -repeats
42#
43proc do_fuzzy_malloc_test {testname args} {
44 set ::fuzzyopts(-repeats) $::REPEATS
45 set ::fuzzyopts(-sqlprep) {}
46 array set ::fuzzyopts $args
47
48 sqlite3_memdebug_fail -1
49 db close
50 file delete test.db test.db-journal
51 sqlite3 db test.db
52 set ::prep $::fuzzyopts(-sqlprep)
53 execsql $::prep
54 set jj 0
55 for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {
56 expr srand($jj)
57 incr jj
58 set ::sql [subst $::fuzzyopts(-template)]
59 foreach {rc res} [catchsql "$::sql"] {}
60 if {$rc==0} {
61 do_malloc_test $testname-$ii -sqlbody $::sql -sqlprep $::prep
62 } else {
63 incr ii -1
64 }
65 }
66}
67
68#----------------------------------------------------------------
69# Test malloc failure during parsing (and execution) of a fuzzily
70# generated expressions.
71#
72do_fuzzy_malloc_test fuzzy_malloc-1 -template {Select [Expr]}
73do_fuzzy_malloc_test fuzzy_malloc-2 -template {[Select]}
74
75set ::SQLPREP {
76 BEGIN;
77 CREATE TABLE abc(a, b, c);
78 CREATE TABLE def(a, b, c);
79 CREATE TABLE ghi(a, b, c);
80 INSERT INTO abc VALUES(1.5, 3, 'a short string');
81 INSERT INTO def VALUES(NULL, X'ABCDEF',
82 'a longer string. Long enough that it doesn''t fit in Mem.zShort');
83 INSERT INTO ghi VALUES(zeroblob(1000), 'hello world', -1257900987654321);
84 COMMIT;
85}
86set ::TableList [list abc def ghi]
87set ::ColumnList [list a b c]
88
89do_fuzzy_malloc_test fuzzy_malloc-3 \
90 -template {[Select]} \
91 -sqlprep $::SQLPREP
92
93finish_test