/ Check-in [000aedb0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add a malloc failure test case that covers a few previously untested lines in pager.c (CVS 6154)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:000aedb0471b5f5a69e7b61f5e1d4b2644994f32
User & Date: danielk1977 2009-01-10 11:10:19
Context
2009-01-10
11:13
Fix a bug in the previous commit - use SQL comments instead of Tcl comments in SQL blocks. (CVS 6155) check-in: 3d7a8de2 user: danielk1977 tags: trunk
11:10
Add a malloc failure test case that covers a few previously untested lines in pager.c (CVS 6154) check-in: 000aedb0 user: danielk1977 tags: trunk
2009-01-09
21:41
Coverage improvements in pragma.c. Change the __DARWIN__ macro to __APPLE__, which is available by default on Leopard. (CVS 6153) check-in: 64c56226 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/malloc.test.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
673
674
675
676
677
678
679






























680
681
682
683
684
685
686
687
688
689
# This file attempts to check the behavior of the SQLite library in 
# an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, 
# the SQLite library accepts a special command (sqlite3_memdebug_fail N C)
# which causes the N-th malloc to fail.  This special feature is used
# to see what happens in the library if a malloc were to really fail
# due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.70 2008/11/21 09:43:20 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl


# Only run these tests if memory debugging is turned on.
#
................................................................................

do_malloc_test 29 -sqlprep {
  CREATE TABLE t1(a TEXT, b TEXT);
} -sqlbody {
  INSERT INTO t1 VALUES(1, -234);
  INSERT INTO t1 SELECT * FROM t1 UNION ALL SELECT * FROM t1;
}
































# Ensure that no file descriptors were leaked.
do_test malloc-99.X {
  catch {db close}
  set sqlite_open_file_count
} {0}

puts open-file-count=$sqlite_open_file_count
finish_test







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
# This file attempts to check the behavior of the SQLite library in 
# an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, 
# the SQLite library accepts a special command (sqlite3_memdebug_fail N C)
# which causes the N-th malloc to fail.  This special feature is used
# to see what happens in the library if a malloc were to really fail
# due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.71 2009/01/10 11:10:19 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl


# Only run these tests if memory debugging is turned on.
#
................................................................................

do_malloc_test 29 -sqlprep {
  CREATE TABLE t1(a TEXT, b TEXT);
} -sqlbody {
  INSERT INTO t1 VALUES(1, -234);
  INSERT INTO t1 SELECT * FROM t1 UNION ALL SELECT * FROM t1;
}

do_malloc_test 29 -tclprep {
  db eval {
    CREATE TABLE t1(x PRIMARY KEY);
    INSERT INTO t1 VALUES(randstr(500,500));
    INSERT INTO t1 VALUES(randstr(500,500));
    INSERT INTO t1 VALUES(randstr(500,500));
  }
  db close
  sqlite3 db test.db

  # The DELETE command in the following block moves the overflow pages that
  # are part of the primary key index to the free-list. But it does not
  # actually load the content of the pages. This leads to the peculiar
  # situation where cache entries exist, but are not populated with data.
  # They are populated next time they are requested by the b-tree layer.
  #
  db eval {
    BEGIN;
      DELETE FROM t1;
    ROLLBACK;
  }
} -sqlbody {
  # This statement requires the 'no-content' pages loaded by the DELETE
  # statement above. When requesting the pages, the content is loaded
  # from the database file. The point of this test case is to test handling
  # of malloc errors (including SQLITE_IOERR_NOMEM errors) when loading
  # the content.
  SELECT * FROM t1 ORDER BY x;
}


# Ensure that no file descriptors were leaked.
do_test malloc-99.X {
  catch {db close}
  set sqlite_open_file_count
} {0}

puts open-file-count=$sqlite_open_file_count
finish_test