danielk1977 | 65839c6 | 2007-08-30 08:08:17 +0000 | [diff] [blame] | 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 | # |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 12 | # $Id: mallocD.test,v 1.6 2008/02/18 22:24:58 drh Exp $ |
danielk1977 | 65839c6 | 2007-08-30 08:08:17 +0000 | [diff] [blame] | 13 | |
| 14 | set testdir [file dirname $argv0] |
| 15 | source $testdir/tester.tcl |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 16 | source $testdir/malloc_common.tcl |
danielk1977 | 369ff42 | 2007-09-03 07:31:09 +0000 | [diff] [blame] | 17 | |
drh | dec6fae | 2007-09-03 17:02:50 +0000 | [diff] [blame] | 18 | # Only run these tests if memory debugging is turned on. |
| 19 | # |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 20 | if {!$MEMDEBUG} { |
drh | dec6fae | 2007-09-03 17:02:50 +0000 | [diff] [blame] | 21 | puts "Skipping mallocD tests: not compiled with -DSQLITE_MEMDEBUG..." |
| 22 | finish_test |
| 23 | return |
| 24 | } |
danielk1977 | 65839c6 | 2007-08-30 08:08:17 +0000 | [diff] [blame] | 25 | |
danielk1977 | bf26097 | 2008-01-22 11:50:13 +0000 | [diff] [blame] | 26 | db close |
danielk1977 | 65839c6 | 2007-08-30 08:08:17 +0000 | [diff] [blame] | 27 | sqlite3_simulate_device -char atomic |
danielk1977 | bf26097 | 2008-01-22 11:50:13 +0000 | [diff] [blame] | 28 | sqlite3 db test.db -vfs devsym |
danielk1977 | 65839c6 | 2007-08-30 08:08:17 +0000 | [diff] [blame] | 29 | |
| 30 | set PREP { |
| 31 | PRAGMA page_size = 1024; |
| 32 | CREATE TABLE abc(a, b, c); |
| 33 | } |
| 34 | |
| 35 | do_malloc_test mallocD-1 -sqlprep $PREP -sqlbody { |
| 36 | INSERT INTO abc VALUES(1, 2, 3); |
| 37 | } |
| 38 | |
| 39 | do_malloc_test mallocD-2 -sqlprep $PREP -sqlbody { |
| 40 | BEGIN; |
| 41 | INSERT INTO abc VALUES(1, 2, 3); |
| 42 | INSERT INTO abc VALUES(4, 5, 6); |
| 43 | ROLLBACK; |
| 44 | } |
| 45 | |
| 46 | do_malloc_test mallocD-3 -sqlprep $PREP -sqlbody { |
| 47 | BEGIN; |
| 48 | INSERT INTO abc VALUES(1, 2, 3); |
| 49 | INSERT INTO abc VALUES(4, 5, randstr(1500,1500)); |
| 50 | COMMIT; |
| 51 | } |
| 52 | |
danielk1977 | 5a8f937 | 2007-10-09 08:29:32 +0000 | [diff] [blame] | 53 | ifcapable attach { |
| 54 | do_malloc_test mallocD-4 -sqlprep $PREP -sqlbody { |
| 55 | ATTACH 'test2.db' AS aux; |
| 56 | BEGIN; |
| 57 | CREATE TABLE aux.def(d, e, f); |
| 58 | INSERT INTO abc VALUES(4, 5, 6); |
| 59 | COMMIT; |
| 60 | } |
danielk1977 | 65839c6 | 2007-08-30 08:08:17 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | sqlite3_simulate_device -char {} |
| 64 | |
| 65 | finish_test |