mallocG.test 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # 2007 Aug 29
  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. #
  12. # This test script checks malloc failures in various obscure operations.
  13. #
  14. # $Id: mallocG.test,v 1.5 2008/08/01 18:47:02 drh Exp $
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. source $testdir/malloc_common.tcl
  18. # Only run these tests if memory debugging is turned on.
  19. #
  20. if {!$MEMDEBUG} {
  21. puts "Skipping mallocG tests: not compiled with -DSQLITE_MEMDEBUG..."
  22. finish_test
  23. return
  24. }
  25. # Malloc failures while opening a database connection.
  26. #
  27. do_malloc_test mallocG-1 -tclbody {
  28. db close
  29. sqlite3 db test.db
  30. }
  31. do_malloc_test mallocG-2 -sqlprep {
  32. CREATE TABLE t1(x, y);
  33. CREATE TABLE t2(x INTEGER PRIMARY KEY);
  34. } -sqlbody {
  35. SELECT y FROM t1 WHERE x IN t2;
  36. }
  37. do_malloc_test mallocG-3 -sqlprep {
  38. CREATE TABLE t1(x UNIQUE);
  39. INSERT INTO t1 VALUES ('hello');
  40. INSERT INTO t1 VALUES ('out there');
  41. } -sqlbody {
  42. SELECT * FROM t1
  43. WHERE x BETWEEN 'a' AND 'z'
  44. AND x BETWEEN 'c' AND 'w'
  45. AND x BETWEEN 'e' AND 'u'
  46. AND x BETWEEN 'g' AND 'r'
  47. AND x BETWEEN 'i' AND 'q'
  48. AND x BETWEEN 'i' AND 'm'
  49. }
  50. ifcapable !utf16 {
  51. finish_test
  52. return
  53. }
  54. proc utf16 {utf8} {
  55. set utf16 [encoding convertto unicode $utf8]
  56. append utf16 "\x00\x00"
  57. return $utf16
  58. }
  59. do_malloc_test mallocG-4 -tclbody {
  60. set rc [sqlite3_complete16 [utf16 "SELECT * FROM t1;"]]
  61. if {$rc==1} {set rc 0} {error "out of memory"}
  62. set rc
  63. }
  64. finish_test