/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to test/malloc.test.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
541
542
543
544
545
546
547






548
549
550
551
552
553
554
555
556
557
558
#***********************************************************************
# This file attempts to check the library in an out-of-memory situation.
# When compiled with -DSQLITE_DEBUG=1, the SQLite library accepts a special
# command (sqlite_malloc_fail N) 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.38 2007/03/26 12:26:27 danielk1977 Exp $

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

# Only run these tests if memory debugging is turned on.
#
if {[info command sqlite_malloc_stat]==""} {
................................................................................
    error "out of memory"
  }
} -sqlbody {
  ATTACH DATABASE 'test2.db' AS t2;
  SELECT * FROM t1;
  DETACH DATABASE t2;
} 








# 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
sqlite_malloc_fail 0
finish_test







|







 







>
>
>
>
>
>











10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
#***********************************************************************
# This file attempts to check the library in an out-of-memory situation.
# When compiled with -DSQLITE_DEBUG=1, the SQLite library accepts a special
# command (sqlite_malloc_fail N) 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.39 2007/03/29 17:07:53 danielk1977 Exp $

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

# Only run these tests if memory debugging is turned on.
#
if {[info command sqlite_malloc_stat]==""} {
................................................................................
    error "out of memory"
  }
} -sqlbody {
  ATTACH DATABASE 'test2.db' AS t2;
  SELECT * FROM t1;
  DETACH DATABASE t2;
} 

# Test malloc failure whilst installing a foriegn key.
#
do_malloc_test 21 -sqlbody {
  CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b))
} 


# 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
sqlite_malloc_fail 0
finish_test

Changes to test/misc7.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
22
23
24
25
26
27
28
29






































































30

#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: misc7.test,v 1.1 2007/03/29 12:19:12 danielk1977 Exp $

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

do_test misc7-1 {
  c_misuse_test
} {}
................................................................................
do_test misc7-2 {
  c_realloc_test
} {}

do_test misc7-3 {
  c_collation_test
} {}







































































finish_test








|







 








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

>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: misc7.test,v 1.2 2007/03/29 17:07:53 danielk1977 Exp $

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

do_test misc7-1 {
  c_misuse_test
} {}
................................................................................
do_test misc7-2 {
  c_realloc_test
} {}

do_test misc7-3 {
  c_collation_test
} {}

# Try to open a directory:
#
do_test misc7-4 {
  file delete mydir
  file mkdir mydir
  set rc [catch {
    sqlite3 db2 ./mydir
  } msg]
  list $rc $msg
} {1 {unable to open database file}}

# Try to open a file with a directory where it's journal file should be.
#
do_test misc7-5 {
  file delete mydir
  file mkdir mydir-journal
  sqlite3 db2 ./mydir
  catchsql {
    CREATE TABLE abc(a, b, c);
  } db2
} {1 {unable to open database file}}
db2 close

#--------------------------------------------------------------------
# The following tests, misc7-6.* test the libraries behaviour when
# it cannot open a file. To force this condition, we use up all the
# file-descriptors before running sqlite. This probably only works
# on unix.
#

proc use_up_files {} {
  set ret [list]
  catch {
    while 1 { lappend ret [open test.db] }
  }
  return $ret
}

execsql { CREATE TABLE abc(a PRIMARY KEY, b, c); }
db close
set fd_list [use_up_files]

set ::go 1
set ::n 1
while {$::go} {
  catch {db close}
  do_test misc7-6.$::n {
    set rc [catch {
      sqlite db test.db
      db eval {
        BEGIN;
        INSERT INTO abc VALUES(1, 2, 3);
        INSERT INTO abc VALUES(2, 3, 4);
        INSERT INTO abc SELECT a+2, b, c FROM abc;
        COMMIT;
      }
    } msg]
    if {$rc == 0} {set ::go 0}

    expr {$rc == 0 || ($rc == 1 && $msg eq "unable to open database file")}
  } 1

  close [lindex $fd_list 0]
  set fd_list [lrange $fd_list 1 end]
  incr ::n
}
foreach fd $fd_list {
  close $fd
}

finish_test