OLD | NEW |
1 # 2011 March 25 | 1 # 2011 March 25 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
11 # This file implements regression tests for TCL interface to the | 11 # This file implements regression tests for TCL interface to the |
12 # SQLite library. | 12 # SQLite library. |
13 # | 13 # |
14 # The focus of the tests is the word-fuzzer virtual table. | 14 # The focus of the tests is the word-fuzzer virtual table. |
15 # | 15 # |
16 | 16 |
17 set testdir [file dirname $argv0] | 17 set testdir [file dirname $argv0] |
18 source $testdir/tester.tcl | 18 source $testdir/tester.tcl |
19 | 19 |
20 ifcapable !vtab { | 20 ifcapable !vtab { |
21 finish_test | 21 finish_test |
22 return | 22 return |
23 } | 23 } |
24 | 24 |
25 set ::testprefix fuzzer1 | 25 set ::testprefix fuzzer1 |
26 | |
27 load_static_extension db fuzzer | 26 load_static_extension db fuzzer |
28 | 27 |
29 # Check configuration errors. | 28 # Check configuration errors. |
30 # | 29 # |
31 do_catchsql_test fuzzer1-1.1 { | 30 do_catchsql_test fuzzer1-1.1 { |
32 CREATE VIRTUAL TABLE f USING fuzzer; | 31 CREATE VIRTUAL TABLE f USING fuzzer; |
33 } {1 {fuzzer: wrong number of CREATE VIRTUAL TABLE arguments}} | 32 } {1 {fuzzer: wrong number of CREATE VIRTUAL TABLE arguments}} |
34 | 33 |
35 do_catchsql_test fuzzer1-1.2 { | 34 do_catchsql_test fuzzer1-1.2 { |
36 CREATE VIRTUAL TABLE f USING fuzzer(one, two); | 35 CREATE VIRTUAL TABLE f USING fuzzer(one, two); |
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 do_execsql_test 5.5.3 { | 1641 do_execsql_test 5.5.3 { |
1643 DROP TABLE IF EXISTS x; | 1642 DROP TABLE IF EXISTS x; |
1644 DELETE FROM "fuzzer [x] rules table"; | 1643 DELETE FROM "fuzzer [x] rules table"; |
1645 INSERT INTO "fuzzer [x] rules table" VALUES((1<<32)+100, 'x', 'y', 2); | 1644 INSERT INTO "fuzzer [x] rules table" VALUES((1<<32)+100, 'x', 'y', 2); |
1646 } | 1645 } |
1647 do_catchsql_test 5.5.4 { | 1646 do_catchsql_test 5.5.4 { |
1648 CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table'); | 1647 CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table'); |
1649 } {1 {fuzzer: ruleset must be between 0 and 2147483647}} | 1648 } {1 {fuzzer: ruleset must be between 0 and 2147483647}} |
1650 | 1649 |
1651 #------------------------------------------------------------------------- | 1650 #------------------------------------------------------------------------- |
1652 # This test uses a fuzzer table with many rules. There is one rule to | |
1653 # map each possible two character string, where characters are lower-case | |
1654 # letters used in the English language, to all other possible two character | |
1655 # strings. In total, (26^4)-(26^2) mappings (the subtracted term represents | |
1656 # the no-op mappings discarded automatically by the fuzzer). | |
1657 # | |
1658 # | |
1659 do_execsql_test 6.1.1 { | |
1660 DROP TABLE IF EXISTS x1; | |
1661 DROP TABLE IF EXISTS x1_rules; | |
1662 CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost); | |
1663 } | |
1664 puts "This test is slow - perhaps around 7 seconds on an average pc" | |
1665 do_test 6.1.2 { | |
1666 set LETTERS {a b c d e f g h i j k l m n o p q r s t u v w x y z} | |
1667 set cost 1 | |
1668 db transaction { | |
1669 foreach c1 $LETTERS { | |
1670 foreach c2 $LETTERS { | |
1671 foreach c3 $LETTERS { | |
1672 foreach c4 $LETTERS { | |
1673 db eval {INSERT INTO x1_rules VALUES(0, $c1||$c2, $c3||$c4, $cost)} | |
1674 set cost [expr ($cost%1000) + 1] | |
1675 } | |
1676 } | |
1677 } | |
1678 } | |
1679 db eval {UPDATE x1_rules SET cost = 20 WHERE cost<20 AND cFrom!='xx'} | |
1680 } | |
1681 } {} | |
1682 | |
1683 do_execsql_test 6.2 { | |
1684 SELECT count(*) FROM x1_rules WHERE cTo!=cFrom; | |
1685 } [expr 26*26*26*26 - 26*26] | |
1686 | |
1687 do_execsql_test 6.2.1 { | |
1688 CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules); | |
1689 SELECT word FROM x1 WHERE word MATCH 'xx' LIMIT 10; | |
1690 } {xx hw hx hy hz ia ib ic id ie} | |
1691 do_execsql_test 6.2.2 { | |
1692 SELECT cTo FROM x1_rules WHERE cFrom='xx' | |
1693 ORDER BY cost asc, rowid asc LIMIT 9; | |
1694 } {hw hx hy hz ia ib ic id ie} | |
1695 | |
1696 #------------------------------------------------------------------------- | |
1697 # Test using different types of quotes with CREATE VIRTUAL TABLE | 1651 # Test using different types of quotes with CREATE VIRTUAL TABLE |
1698 # arguments. | 1652 # arguments. |
1699 # | 1653 # |
1700 do_execsql_test 7.1 { | 1654 do_execsql_test 7.1 { |
1701 CREATE TABLE [x2 "rules] (a, b, c, d); | 1655 CREATE TABLE [x2 "rules] (a, b, c, d); |
1702 INSERT INTO [x2 "rules] VALUES(0, 'a', 'b', 5); | 1656 INSERT INTO [x2 "rules] VALUES(0, 'a', 'b', 5); |
1703 } | 1657 } |
1704 foreach {tn sql} { | 1658 foreach {tn sql} { |
1705 1 { CREATE VIRTUAL TABLE x2 USING fuzzer( [x2 "rules] ) } | 1659 1 { CREATE VIRTUAL TABLE x2 USING fuzzer( [x2 "rules] ) } |
1706 2 { CREATE VIRTUAL TABLE x2 USING fuzzer( "x2 ""rules" ) } | 1660 2 { CREATE VIRTUAL TABLE x2 USING fuzzer( "x2 ""rules" ) } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 } {} | 1811 } {} |
1858 | 1812 |
1859 do_execsql_test 10.3 { | 1813 do_execsql_test 10.3 { |
1860 INSERT INTO x5_rules VALUES(0, 'a', '0.1.2.3.4.5.6.7.8.9.a', 1); | 1814 INSERT INTO x5_rules VALUES(0, 'a', '0.1.2.3.4.5.6.7.8.9.a', 1); |
1861 DROP TABLE x5; | 1815 DROP TABLE x5; |
1862 CREATE VIRTUAL TABLE x5 USING fuzzer(x5_rules); | 1816 CREATE VIRTUAL TABLE x5 USING fuzzer(x5_rules); |
1863 SELECT length(word) FROM x5 WHERE word MATCH 'a' LIMIT 50; | 1817 SELECT length(word) FROM x5 WHERE word MATCH 'a' LIMIT 50; |
1864 } {1 21 41 61 81} | 1818 } {1 21 41 61 81} |
1865 | 1819 |
1866 finish_test | 1820 finish_test |
OLD | NEW |