fuzzerfault.test 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # 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. set testdir [file dirname $argv0]
  15. source $testdir/tester.tcl
  16. ifcapable !vtab { finish_test ; return }
  17. set ::testprefix fuzzerfault
  18. load_static_extension db fuzzer
  19. do_test 1-pre1 {
  20. execsql {
  21. CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
  22. INSERT INTO x1_rules VALUES(0, 'a', 'b', 1);
  23. INSERT INTO x1_rules VALUES(0, 'a', 'c', 2);
  24. INSERT INTO x1_rules VALUES(0, 'a', 'd', 3);
  25. }
  26. faultsim_save_and_close
  27. } {}
  28. do_faultsim_test 1 -prep {
  29. faultsim_restore_and_reopen
  30. load_static_extension db fuzzer
  31. } -body {
  32. execsql {
  33. CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
  34. SELECT word FROM x1 WHERE word MATCH 'xax';
  35. }
  36. } -test {
  37. faultsim_test_result {0 {xax xbx xcx xdx}} \
  38. {1 {vtable constructor failed: x1}}
  39. }
  40. do_test 2-pre1 {
  41. faultsim_delete_and_reopen
  42. load_static_extension db fuzzer
  43. execsql {
  44. CREATE TABLE x2_rules(ruleset, cFrom, cTo, cost);
  45. INSERT INTO x2_rules VALUES(0, 'a', 'x', 1);
  46. INSERT INTO x2_rules VALUES(0, 'b', 'x', 2);
  47. INSERT INTO x2_rules VALUES(0, 'c', 'x', 3);
  48. CREATE VIRTUAL TABLE x2 USING fuzzer(x2_rules);
  49. }
  50. faultsim_save_and_close
  51. } {}
  52. do_faultsim_test 2 -prep {
  53. faultsim_restore_and_reopen
  54. load_static_extension db fuzzer
  55. } -body {
  56. execsql {
  57. SELECT count(*) FROM x2 WHERE word MATCH 'abc';
  58. }
  59. } -test {
  60. faultsim_test_result {0 8} {1 {vtable constructor failed: x2}}
  61. }
  62. do_test 3-pre1 {
  63. faultsim_delete_and_reopen
  64. execsql {
  65. CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
  66. INSERT INTO x1_rules VALUES(0, 'a',
  67. '123456789012345678901234567890a1234567890123456789', 10
  68. );
  69. }
  70. faultsim_save_and_close
  71. } {}
  72. do_faultsim_test 3 -prep {
  73. faultsim_restore_and_reopen
  74. load_static_extension db fuzzer
  75. } -body {
  76. execsql {
  77. CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
  78. SELECT count(*) FROM (SELECT * FROM x1 WHERE word MATCH 'a' LIMIT 2);
  79. }
  80. } -test {
  81. faultsim_test_result {0 2} {1 {vtable constructor failed: x1}}
  82. }
  83. finish_test