SQLite

Check-in [1c19e8bdca]
Login

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

Overview
Comment:Fix a test bug introduce with the previous commit. (CVS 2203)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1c19e8bdca24484fcb9f068b38ebfbce3e24ada5
User & Date: danielk1977 2005-01-12 13:04:55.000
Context
2005-01-13
02:14
Fixes to 'configure' build system. Also extra coverage for main.c. (CVS 2204) (check-in: 8378455f32 user: danielk1977 tags: trunk)
2005-01-12
13:04
Fix a test bug introduce with the previous commit. (CVS 2203) (check-in: 1c19e8bdca user: danielk1977 tags: trunk)
12:44
Tests to improve coverage of main.c. (CVS 2202) (check-in: 4e28c82ada user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/malloc.test.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38













39
40
41
42
43
44
45
#***********************************************************************
# 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.16 2005/01/12 12:44:04 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]==""} {
   puts "Skipping malloc tests: not compiled with -DSQLITE_DEBUG..."
   finish_test
   return
}

# Usage: do_malloc_test <test number> <options...>
#
# The first argument, <test number>, is an integer used to name the
# tests executed by this proc. Options are as follows:
#
#     -tclprep          TCL script to run to prepare test.
#     -sqlprep          SQL script to run to prepare test.
#     -tclbody          TCL script to run with IO error simulation.
#     -sqlbody          TCL script to run with IO error simulation.













#
proc do_malloc_test {tn args} {
  array set ::mallocopts $args

  set ::go 1
  for {set ::n 1} {$::go} {incr ::n} {








|



















|
|
>
>
>
>
>
>
>
>
>
>
>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
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
#***********************************************************************
# 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.17 2005/01/12 13:04:55 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]==""} {
   puts "Skipping malloc tests: not compiled with -DSQLITE_DEBUG..."
   finish_test
   return
}

# Usage: do_malloc_test <test number> <options...>
#
# The first argument, <test number>, is an integer used to name the
# tests executed by this proc. Options are as follows:
#
#     -tclprep          TCL script to run to prepare test.
#     -sqlprep          SQL script to run to prepare test.
#     -tclbody          TCL script to run with malloc failure simulation.
#     -sqlbody          TCL script to run with malloc failure simulation.
#
# This command runs a series of tests to verify SQLite's ability
# to handle an out-of-memory condition gracefully. It is assumed
# that if this condition occurs a malloc() call will return a
# NULL pointer. Linux, for example, doesn't do that by default. See
# the "BUGS" section of malloc(3).
#
# Each iteration of a loop, the TCL commands in any argument passed
# to the -tclbody switch, followed by the SQL commands in any argument
# passed to the -sqlbody switch are executed. Each iteration the
# Nth call to sqliteMalloc() is made to fail, where N is increased
# each time the loop runs starting from 1. When all commands execute
# successfully, the loop ends.
#
proc do_malloc_test {tn args} {
  array set ::mallocopts $args

  set ::go 1
  for {set ::n 1} {$::go} {incr ::n} {

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
        if {!$v2} {puts "\nError message returned: $msg"}
        lappend v $v2
      }
    } {1 1}
  }
}

if 0 {

for {set go 1; set i 1} {$go} {incr i} {
  do_test malloc-1.$i {
     sqlite_malloc_fail 0
     catch {db close}
     catch {file delete -force test.db}
     catch {file delete -force test.db-journal}
     sqlite_malloc_fail $i [expr {$i%4}]







<
<







94
95
96
97
98
99
100


101
102
103
104
105
106
107
        if {!$v2} {puts "\nError message returned: $msg"}
        lappend v $v2
      }
    } {1 1}
  }
}



for {set go 1; set i 1} {$go} {incr i} {
  do_test malloc-1.$i {
     sqlite_malloc_fail 0
     catch {db close}
     catch {file delete -force test.db}
     catch {file delete -force test.db-journal}
     sqlite_malloc_fail $i [expr {$i%4}]
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
  CREATE TABLE abc1(a, b, c);
  CREATE TABLE test2.abc2(a, b, c);
} -sqlbody {
  BEGIN;
  INSERT INTO abc1 VALUES(1, 2, 3);
  INSERT INTO abc2 VALUES(1, 2, 3);
  COMMIT;
}

}

# This block tests malloc() failures that occur while opening a 
# connection to a database.
do_malloc_test 10 -sqlprep {
  CREATE TABLE abc(a, b, c);
} -tclbody {







<
<







466
467
468
469
470
471
472


473
474
475
476
477
478
479
  CREATE TABLE abc1(a, b, c);
  CREATE TABLE test2.abc2(a, b, c);
} -sqlbody {
  BEGIN;
  INSERT INTO abc1 VALUES(1, 2, 3);
  INSERT INTO abc2 VALUES(1, 2, 3);
  COMMIT;


}

# This block tests malloc() failures that occur while opening a 
# connection to a database.
do_malloc_test 10 -sqlprep {
  CREATE TABLE abc(a, b, c);
} -tclbody {
Changes to test/rollback.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is verifying that a rollback in one statement
# caused by an ON CONFLICT ROLLBACK clause aborts any other pending
# statements.
#
# $Id: rollback.test,v 1.1 2004/06/30 11:14:19 drh Exp $

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

db close
set DB [sqlite3 db test.db]








|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is verifying that a rollback in one statement
# caused by an ON CONFLICT ROLLBACK clause aborts any other pending
# statements.
#
# $Id: rollback.test,v 1.2 2005/01/12 13:04:55 danielk1977 Exp $

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

db close
set DB [sqlite3 db test.db]

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  sqlite3_step $STMT
} {SQLITE_ABORT}

# Restart the SELECT statement
#
do_test rollback-1.6 {
  sqlite3_reset $STMT
} {}
do_test rollback-1.7 {
  sqlite3_step $STMT
} {SQLITE_ROW}
do_test rollback-1.8 {
  sqlite3_step $STMT
} {SQLITE_ROW}
do_test rollback-1.9 {
  sqlite3_finalize $STMT
} {SQLITE_OK}

finish_test







|











60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  sqlite3_step $STMT
} {SQLITE_ABORT}

# Restart the SELECT statement
#
do_test rollback-1.6 {
  sqlite3_reset $STMT
} {SQLITE_OK}
do_test rollback-1.7 {
  sqlite3_step $STMT
} {SQLITE_ROW}
do_test rollback-1.8 {
  sqlite3_step $STMT
} {SQLITE_ROW}
do_test rollback-1.9 {
  sqlite3_finalize $STMT
} {SQLITE_OK}

finish_test