/ Check-in [0b22ce36]
Login

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

Overview
Comment:Add a couple of test cases to improve coverage testing. (CVS 3747)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0b22ce3637f87c453084c5bd994b6b19a0b014c0
User & Date: danielk1977 2007-03-29 17:07:53
Context
2007-03-29
17:28
Avoid calling OsDelete() on journal files when they are opened for temporary databases. Fix for #2255. (CVS 3748) check-in: e746832f user: danielk1977 tags: trunk
17:07
Add a couple of test cases to improve coverage testing. (CVS 3747) check-in: 0b22ce36 user: danielk1977 tags: trunk
16:30
Don't call ctype functions on hi-bit chars. Some platforms raise assertions when this occurs, and it's almost certainly not the right thing to do in the first place. (CVS 3746) check-in: f6c3abdc user: shess tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/malloc.test.

    10     10   #***********************************************************************
    11     11   # This file attempts to check the library in an out-of-memory situation.
    12     12   # When compiled with -DSQLITE_DEBUG=1, the SQLite library accepts a special
    13     13   # command (sqlite_malloc_fail N) which causes the N-th malloc to fail.  This
    14     14   # special feature is used to see what happens in the library if a malloc
    15     15   # were to really fail due to an out-of-memory situation.
    16     16   #
    17         -# $Id: malloc.test,v 1.38 2007/03/26 12:26:27 danielk1977 Exp $
           17  +# $Id: malloc.test,v 1.39 2007/03/29 17:07:53 danielk1977 Exp $
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   # Only run these tests if memory debugging is turned on.
    23     23   #
    24     24   if {[info command sqlite_malloc_stat]==""} {
................................................................................
   541    541       error "out of memory"
   542    542     }
   543    543   } -sqlbody {
   544    544     ATTACH DATABASE 'test2.db' AS t2;
   545    545     SELECT * FROM t1;
   546    546     DETACH DATABASE t2;
   547    547   } 
          548  +
          549  +# Test malloc failure whilst installing a foriegn key.
          550  +#
          551  +do_malloc_test 21 -sqlbody {
          552  +  CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b))
          553  +} 
   548    554   
   549    555   
   550    556   # Ensure that no file descriptors were leaked.
   551    557   do_test malloc-99.X {
   552    558     catch {db close}
   553    559     set sqlite_open_file_count
   554    560   } {0}
   555    561   
   556    562   puts open-file-count=$sqlite_open_file_count
   557    563   sqlite_malloc_fail 0
   558    564   finish_test

Changes to test/misc7.test.

     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13         -# $Id: misc7.test,v 1.1 2007/03/29 12:19:12 danielk1977 Exp $
           13  +# $Id: misc7.test,v 1.2 2007/03/29 17:07:53 danielk1977 Exp $
    14     14   
    15     15   set testdir [file dirname $argv0]
    16     16   source $testdir/tester.tcl
    17     17   
    18     18   do_test misc7-1 {
    19     19     c_misuse_test
    20     20   } {}
................................................................................
    22     22   do_test misc7-2 {
    23     23     c_realloc_test
    24     24   } {}
    25     25   
    26     26   do_test misc7-3 {
    27     27     c_collation_test
    28     28   } {}
           29  +
           30  +# Try to open a directory:
           31  +#
           32  +do_test misc7-4 {
           33  +  file delete mydir
           34  +  file mkdir mydir
           35  +  set rc [catch {
           36  +    sqlite3 db2 ./mydir
           37  +  } msg]
           38  +  list $rc $msg
           39  +} {1 {unable to open database file}}
           40  +
           41  +# Try to open a file with a directory where it's journal file should be.
           42  +#
           43  +do_test misc7-5 {
           44  +  file delete mydir
           45  +  file mkdir mydir-journal
           46  +  sqlite3 db2 ./mydir
           47  +  catchsql {
           48  +    CREATE TABLE abc(a, b, c);
           49  +  } db2
           50  +} {1 {unable to open database file}}
           51  +db2 close
           52  +
           53  +#--------------------------------------------------------------------
           54  +# The following tests, misc7-6.* test the libraries behaviour when
           55  +# it cannot open a file. To force this condition, we use up all the
           56  +# file-descriptors before running sqlite. This probably only works
           57  +# on unix.
           58  +#
           59  +
           60  +proc use_up_files {} {
           61  +  set ret [list]
           62  +  catch {
           63  +    while 1 { lappend ret [open test.db] }
           64  +  }
           65  +  return $ret
           66  +}
           67  +
           68  +execsql { CREATE TABLE abc(a PRIMARY KEY, b, c); }
           69  +db close
           70  +set fd_list [use_up_files]
           71  +
           72  +set ::go 1
           73  +set ::n 1
           74  +while {$::go} {
           75  +  catch {db close}
           76  +  do_test misc7-6.$::n {
           77  +    set rc [catch {
           78  +      sqlite db test.db
           79  +      db eval {
           80  +        BEGIN;
           81  +        INSERT INTO abc VALUES(1, 2, 3);
           82  +        INSERT INTO abc VALUES(2, 3, 4);
           83  +        INSERT INTO abc SELECT a+2, b, c FROM abc;
           84  +        COMMIT;
           85  +      }
           86  +    } msg]
           87  +    if {$rc == 0} {set ::go 0}
           88  +
           89  +    expr {$rc == 0 || ($rc == 1 && $msg eq "unable to open database file")}
           90  +  } 1
           91  +
           92  +  close [lindex $fd_list 0]
           93  +  set fd_list [lrange $fd_list 1 end]
           94  +  incr ::n
           95  +}
           96  +foreach fd $fd_list {
           97  +  close $fd
           98  +}
    29     99   
    30    100   finish_test
          101  +