blob: e281cb592e6c0acd5dc400e032489e43e297b260 [file] [log] [blame]
dan4965ebc2012-02-21 14:11:12 +00001# 2012 February 21
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11# This file implements regression tests for TCL interface to the
12# SQLite library.
13#
14
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17ifcapable !vtab { finish_test ; return }
18set ::testprefix fuzzerfault
19
drhe50db1c2013-04-25 14:31:46 +000020load_static_extension db fuzzer
dan4965ebc2012-02-21 14:11:12 +000021
22do_test 1-pre1 {
23 execsql {
24 CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
25 INSERT INTO x1_rules VALUES(0, 'a', 'b', 1);
26 INSERT INTO x1_rules VALUES(0, 'a', 'c', 2);
27 INSERT INTO x1_rules VALUES(0, 'a', 'd', 3);
28 }
29 faultsim_save_and_close
30} {}
dan99c7d462012-02-21 18:00:20 +000031do_faultsim_test 1 -prep {
dan4965ebc2012-02-21 14:11:12 +000032 faultsim_restore_and_reopen
mistachkin4eb9b722013-04-29 07:01:23 +000033 load_static_extension db fuzzer
dan4965ebc2012-02-21 14:11:12 +000034} -body {
35 execsql {
36 CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
37 SELECT word FROM x1 WHERE word MATCH 'xax';
38 }
39} -test {
40 faultsim_test_result {0 {xax xbx xcx xdx}} \
41 {1 {vtable constructor failed: x1}}
42}
43
dan99c7d462012-02-21 18:00:20 +000044do_test 2-pre1 {
45 faultsim_delete_and_reopen
mistachkin4eb9b722013-04-29 07:01:23 +000046 load_static_extension db fuzzer
dan99c7d462012-02-21 18:00:20 +000047 execsql {
48 CREATE TABLE x2_rules(ruleset, cFrom, cTo, cost);
49 INSERT INTO x2_rules VALUES(0, 'a', 'x', 1);
50 INSERT INTO x2_rules VALUES(0, 'b', 'x', 2);
51 INSERT INTO x2_rules VALUES(0, 'c', 'x', 3);
52 CREATE VIRTUAL TABLE x2 USING fuzzer(x2_rules);
53 }
54 faultsim_save_and_close
55} {}
56
57do_faultsim_test 2 -prep {
58 faultsim_restore_and_reopen
mistachkin4eb9b722013-04-29 07:01:23 +000059 load_static_extension db fuzzer
dan99c7d462012-02-21 18:00:20 +000060} -body {
61 execsql {
62 SELECT count(*) FROM x2 WHERE word MATCH 'abc';
63 }
64} -test {
65 faultsim_test_result {0 8} {1 {vtable constructor failed: x2}}
66}
67
68do_test 3-pre1 {
69 faultsim_delete_and_reopen
70 execsql {
71 CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
72 INSERT INTO x1_rules VALUES(0, 'a',
73 '123456789012345678901234567890a1234567890123456789', 10
74 );
75 }
76 faultsim_save_and_close
77} {}
78
79do_faultsim_test 3 -prep {
80 faultsim_restore_and_reopen
mistachkin4eb9b722013-04-29 07:01:23 +000081 load_static_extension db fuzzer
dan99c7d462012-02-21 18:00:20 +000082} -body {
83 execsql {
84 CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
85 SELECT count(*) FROM (SELECT * FROM x1 WHERE word MATCH 'a' LIMIT 2);
86 }
87} -test {
88 faultsim_test_result {0 2} {1 {vtable constructor failed: x1}}
89}
dan4965ebc2012-02-21 14:11:12 +000090
dana3944bc2021-02-27 15:32:02 +000091#-------------------------------------------------------------------------
92reset_db
93do_execsql_test 4.0 {
94 CREATE TABLE t1_a(a INTEFDR PRIMARY KEY, b TEXT);
95 CREATE TABLE t3_a(k FnTEGER PRIMARY KEY, v TEXT);
96 CREATE TABLE t3_b(k INTEÀ5R PRIMARY KEY, v TEXT);
97 CREATE VIEW t3 AS SELECT * FROM t3_a UNION ALL SELECT * FROM t3_b;
98}
99faultsim_save_and_close
100
101do_faultsim_test 4 -faults oom-t* -prep {
102 faultsim_restore_and_reopen
103} -body {
104 execsql {
105 SELECT 1 FROM t1_a LEFT JOIN t3 ON ((1+1) AND k=1)
106 }
107} -test {
108 faultsim_test_result {0 {}}
109}
dan4965ebc2012-02-21 14:11:12 +0000110
111finish_test