SQLite

Check-in [7c33eb5a5a]
Login

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

Overview
Comment:Change all.test, quick.test and permutations.test so that they use a separate interpreter for each test file.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7c33eb5a5add8fe76dd412ecab5b6ff8cd78a98d
User & Date: dan 2010-06-07 17:47:27.000
Context
2010-06-07
19:26
In os_unix.c, call munmap() to unmap a shared-memory region prior to closing the associated file descriptor. (check-in: 95cc976f15 user: dan tags: trunk)
17:47
Change all.test, quick.test and permutations.test so that they use a separate interpreter for each test file. (check-in: 7c33eb5a5a user: dan tags: trunk)
14:28
Refactor some of the global variables and commands used by tester.tcl. (check-in: c2edf8e17f user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/all.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.62 2009/01/06 18:43:51 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {
  catch {db close}
  show_memstats
}

if {[file exists ./sqlite_test_count]} {
  set COUNT [exec cat ./sqlite_test_count]
} else {
  set COUNT 1
}

if {[llength $argv]>0} {
  foreach {name value} $argv {
    switch -- $name {
      -count {
         set COUNT $value
      }
      -quick {
         set ISQUICK $value
      }
      -soak {
         set SOAKTEST $value
      }
      default {
         puts stderr "Unknown option: $name"
         exit
      }
    }
  }
}
set argv {}

# LeakList will hold a list of the number of unfreed mallocs after
# each round of the test.  This number should be constant.  If it
# grows, it may mean there is a memory leak in the library.
#
set LeakList {}

set EXCLUDE {}
lappend EXCLUDE all.test               ;# This file
lappend EXCLUDE async.test
lappend EXCLUDE crash.test             ;# Run separately later.
lappend EXCLUDE crash2.test            ;# Run separately later.
lappend EXCLUDE quick.test             ;# Alternate test driver script
lappend EXCLUDE veryquick.test         ;# Alternate test driver script
lappend EXCLUDE malloc.test            ;# Run separately later.
lappend EXCLUDE misuse.test            ;# Run separately later.
lappend EXCLUDE memleak.test           ;# Alternate test driver script
lappend EXCLUDE permutations.test      ;# Run separately later.
lappend EXCLUDE soak.test              ;# Takes a very long time (default 1 hr)
lappend EXCLUDE fts3.test              ;# Wrapper for muliple fts3*.tests
lappend EXCLUDE mallocAll.test         ;# Wrapper for running all malloc tests

# Files to include in the test.  If this list is empty then everything
# that is not in the EXCLUDE list is run.
#
set INCLUDE {
}

for {set Counter 0} {$Counter<$COUNT} {incr Counter} {
  foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
    set tail [file tail $testfile]
    if {[lsearch -exact $EXCLUDE $tail]>=0} continue
    if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
    reset_prng_state
    source $testfile
    catch {db close}
    if {$sqlite_open_file_count>0} {
      puts "$tail did not close all files: $sqlite_open_file_count"
      fail_test $tail
      set sqlite_open_file_count 0
    }
  }
  if {[info exists Leak]} {
    lappend LeakList $Leak
  }

  if {[set_test_counter errors]} break
}
set argv all
source $testdir/permutations.test
set argv ""

# Do one last test to look for a memory leak in the library.  This will
# only work if SQLite is compiled with the -DSQLITE_DEBUG=1 flag.
#
if {$LeakList!=""} {
  puts -nonewline memory-leak-test...
  incr_ntest
  foreach x $LeakList {
    if {$x!=[lindex $LeakList 0]} {
       puts " failed!"
       puts "Expected: all values to be the same"
       puts "     Got: $LeakList"
       fail_test memory-leak-test
       break
    }
  }
  puts " Ok"
}

# Run the crashtest only on unix and only once. If the library does not
# always create auto-vacuum databases, also run autovacuum_crash.test.
#
if {$::tcl_platform(platform)=="unix"} {
  source $testdir/crash.test

  source $testdir/crash2.test
  ifcapable !default_autovacuum {
    set argv autovacuum_crash
    source $testdir/permutations.test
    set argv ""
  }
}

# Run the malloc tests and the misuse test after memory leak detection.
# Both tests leak memory. Currently, misuse.test also leaks a handful of
# file descriptors. This is not considered a problem, but can cause tests
# in malloc.test to fail. So set the open-file count to zero before running
# malloc.test to get around this.
#
catch {source $testdir/misuse.test}
set sqlite_open_file_count 0
catch {source $testdir/malloc.test}

catch {db close}
set sqlite_open_file_count 0
really_finish_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
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



#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.62 2009/01/06 18:43:51 drh Exp $

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






if {[file exists ./sqlite_test_count]} {
  set COUNT [exec cat ./sqlite_test_count]
} else {
  set COUNT 1
}

if {[llength $argv]>0} {
  foreach {name value} $argv {
    switch -- $name {
      -count {
         set COUNT $value
      }
      -quick {
         set G(isquick) $value
      }
      -soak {
         set G(issoak) $value
      }
      default {
         puts stderr "Unknown option: $name"
         exit
      }
    }
  }
}
set argv {}







set EXCLUDE {}
lappend EXCLUDE all.test               ;# This file
lappend EXCLUDE async.test
lappend EXCLUDE crash.test             ;# Run separately later.
lappend EXCLUDE crash2.test            ;# Run separately later.
lappend EXCLUDE quick.test             ;# Alternate test driver script
lappend EXCLUDE veryquick.test         ;# Alternate test driver script

lappend EXCLUDE misuse.test            ;# Run separately later.
lappend EXCLUDE memleak.test           ;# Alternate test driver script
lappend EXCLUDE permutations.test      ;# Run separately later.
lappend EXCLUDE soak.test              ;# Takes a very long time (default 1 hr)
lappend EXCLUDE fts3.test              ;# Wrapper for muliple fts3*.tests
lappend EXCLUDE mallocAll.test         ;# Wrapper for running all malloc tests

# Files to include in the test.  If this list is empty then everything
# that is not in the EXCLUDE list is run.
#
set INCLUDE {
}

for {set Counter 0} {$Counter<$COUNT} {incr Counter} {
  foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
    set tail [file tail $testfile]
    if {[lsearch -exact $EXCLUDE $tail]>=0} continue
    if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
    reset_prng_state
    slave_test_file $testfile









  }

  if {[set_test_counter errors]} break
}
set argv all
source $testdir/permutations.test
set argv ""



















# Run the crashtest only on unix and only once. If the library does not
# always create auto-vacuum databases, also run autovacuum_crash.test.
#
if {$::tcl_platform(platform)=="unix"} {
  slave_test_file [file join $testdir crash.test]
  slave_test_file [file join $testdir crash2.test]

  ifcapable !default_autovacuum {
    set argv autovacuum_crash
    source $testdir/permutations.test
    set argv ""
  }
}

# Run the misuse test after memory leak detection. It may leak memory. 
# Currently, misuse.test also leaks a handful of file descriptors. This is 
# not considered a problem.


#
slave_test_file [file join $testdir misuse.test]

finish_test




Changes to test/async.test.
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

rename finish_test async_really_finish_test
proc finish_test {} {
  catch {db close}
  catch {db2 close}
  catch {db3 close}
}
if {[info exists ISQUICK]} { set ASYNC_SAVE_ISQUICK $ISQUICK }
set ISQUICK 1

set ASYNC_INCLUDE {
  insert.test
  insert2.test
  insert3.test
  lock.test
  lock2.test







|
|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

rename finish_test async_really_finish_test
proc finish_test {} {
  catch {db close}
  catch {db2 close}
  catch {db3 close}
}
if {[info exists G(isquick)]} { set ASYNC_SAVE_ISQUICK $G(isquick) }
set G(isquick) 1

set ASYNC_INCLUDE {
  insert.test
  insert2.test
  insert3.test
  lock.test
  lock2.test
79
80
81
82
83
84
85
86
87
set sqlite3async_trace 0

rename do_test {}
rename async_really_do_test do_test
rename finish_test {}
rename async_really_finish_test finish_test

if {[info exists ASYNC_SAVE_ISQUICK]} { set ISQUICK $ASYNC_SAVE_ISQUICK }
finish_test







|

79
80
81
82
83
84
85
86
87
set sqlite3async_trace 0

rename do_test {}
rename async_really_do_test do_test
rename finish_test {}
rename async_really_finish_test finish_test

if {[info exists ASYNC_SAVE_ISQUICK]} { set G(isquick) $ASYNC_SAVE_ISQUICK }
finish_test
Changes to test/avtrans.test.
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
}

# Repeat the following group of tests 20 times for quick testing and
# 40 times for full testing.  Each iteration of the test makes table
# t3 a little larger, and thus takes a little longer, so doing 40 tests
# is more than 2.0 times slower than doing 20 tests.  Considerably more.
#
if {[info exists ISQUICK]} {
  set limit 20
} else {
  set limit 40
}

# Do rollbacks.  Make sure the signature does not change.
#







|







853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
}

# Repeat the following group of tests 20 times for quick testing and
# 40 times for full testing.  Each iteration of the test makes table
# t3 a little larger, and thus takes a little longer, so doing 40 tests
# is more than 2.0 times slower than doing 20 tests.  Considerably more.
#
if {[info exists G(isquick)]} {
  set limit 20
} else {
  set limit 40
}

# Do rollbacks.  Make sure the signature does not change.
#
Changes to test/corruptC.test.
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
db close
copy_file test.db test.bu
sqlite3 db test.db
set fsize [file size test.db]

# Set a quasi-random random seed. 
if {[info exists SOAKTEST]} {
  # If we are doing SOAK tests, we want a different
  # random seed for each run.  Ideally we would like 
  # to use [clock clicks] or something like that here.
  set qseed [file mtime test.db]
} else {
  # If we are not doing soak tests,
  # make it repeatable.







|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
db close
copy_file test.db test.bu
sqlite3 db test.db
set fsize [file size test.db]

# Set a quasi-random random seed. 
if {[info exists ::G(issoak)]} {
  # If we are doing SOAK tests, we want a different
  # random seed for each run.  Ideally we would like 
  # to use [clock clicks] or something like that here.
  set qseed [file mtime test.db]
} else {
  # If we are not doing soak tests,
  # make it repeatable.
Changes to test/fts2.test.
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
}
while {[set arg [lshift argv]] != ""} {
  switch -- $arg {
    -sharedpagercache {
      sqlite3_enable_shared_cache 1
    }
    -soak {
       set SOAKTEST 1
    }
    default {
      set argv [linsert $argv 0 $arg]
      break
    }
  }
}

set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
  return
}
rename finish_test really_finish_test
proc finish_test {} {}
set ISQUICK 1

set EXCLUDE {
  fts2.test
}

# Files to include in the test.  If this list is empty then everything
# that is not in the EXCLUDE list is run.







|
















|







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
}
while {[set arg [lshift argv]] != ""} {
  switch -- $arg {
    -sharedpagercache {
      sqlite3_enable_shared_cache 1
    }
    -soak {
       set G(issoak) 1
    }
    default {
      set argv [linsert $argv 0 $arg]
      break
    }
  }
}

set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
  return
}
rename finish_test really_finish_test
proc finish_test {} {}
set G(isquick) 1

set EXCLUDE {
  fts2.test
}

# Files to include in the test.  If this list is empty then everything
# that is not in the EXCLUDE list is run.
Changes to test/fts3.test.
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
}
while {[set arg [lshift argv]] != ""} {
  switch -- $arg {
    -sharedpagercache {
      sqlite3_enable_shared_cache 1
    }
    -soak {
       set SOAKTEST 1
    }
    default {
      set argv [linsert $argv 0 $arg]
      break
    }
  }
}

set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
  return
}
rename finish_test really_finish_test
proc finish_test {} {}
set ISQUICK 1

set EXCLUDE {
  fts3.test
  fts3malloc.test
  fts3rnd.test
}








|
















|







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
}
while {[set arg [lshift argv]] != ""} {
  switch -- $arg {
    -sharedpagercache {
      sqlite3_enable_shared_cache 1
    }
    -soak {
       set G(issoak) 1
    }
    default {
      set argv [linsert $argv 0 $arg]
      break
    }
  }
}

set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
  return
}
rename finish_test really_finish_test
proc finish_test {} {}
set G(isquick) 1

set EXCLUDE {
  fts3.test
  fts3malloc.test
  fts3rnd.test
}

Changes to test/fuzz.test.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

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

set ::REPEATS 5000

# If running quick.test, don't do so many iterations.
if {[info exists ::ISQUICK]} {
  if {$::ISQUICK} { set ::REPEATS 20 }
}

source $testdir/fuzz_common.tcl
expr srand(0)

#----------------------------------------------------------------
# These tests caused errors that were first caught by the tests







|
|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

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

set ::REPEATS 5000

# If running quick.test, don't do so many iterations.
if {[info exists ::G(isquick)]} {
  if {$::G(isquick)} { set ::REPEATS 20 }
}

source $testdir/fuzz_common.tcl
expr srand(0)

#----------------------------------------------------------------
# These tests caused errors that were first caught by the tests
Changes to test/fuzz_malloc.test.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  finish_test
  return
}

source $testdir/malloc_common.tcl
source $testdir/fuzz_common.tcl

if {[info exists ISQUICK]} {
  set ::REPEATS 20
} elseif {[info exists SOAKTEST]} {
  set ::REPEATS 100
} else {
  set ::REPEATS 40
}

#
# Usage: do_fuzzy_malloc_test <testname> ?<options>?







|

|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  finish_test
  return
}

source $testdir/malloc_common.tcl
source $testdir/fuzz_common.tcl

if {[info exists G(isquick)]} {
  set ::REPEATS 20
} elseif {[info exists G(issoak)]} {
  set ::REPEATS 100
} else {
  set ::REPEATS 40
}

#
# Usage: do_fuzzy_malloc_test <testname> ?<options>?
Changes to test/jrnlmode.test.
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
    list [file exists test.db-journal] [file size test.db-journal]
  } {1 0}
}

ifcapable pragma {
  # These tests are not run as part of the "journaltest" permutation,
  # as the test_journal.c layer is incompatible with in-memory journaling.
  if {[catch {set ::permutations_test_prefix} z] || $z ne "journaltest"} {

    do_test jrnlmode-6.1 {
      execsql {
        PRAGMA journal_mode = truncate;
        CREATE TABLE t4(a, b);
        BEGIN;
          INSERT INTO t4 VALUES(1, 2);







|







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
    list [file exists test.db-journal] [file size test.db-journal]
  } {1 0}
}

ifcapable pragma {
  # These tests are not run as part of the "journaltest" permutation,
  # as the test_journal.c layer is incompatible with in-memory journaling.
  if {[permutation] ne "journaltest"} {

    do_test jrnlmode-6.1 {
      execsql {
        PRAGMA journal_mode = truncate;
        CREATE TABLE t4(a, b);
        BEGIN;
          INSERT INTO t4 VALUES(1, 2);
Changes to test/mallocAll.test.
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  }
}

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {}
set ISQUICK 1

set EXCLUDE {
  mallocAll.test
}

if {[sqlite3 -has-codec]} {
  # lappend EXCLUDE \







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  }
}

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {}
set G(isquick) 1

set EXCLUDE {
  mallocAll.test
}

if {[sqlite3 -has-codec]} {
  # lappend EXCLUDE \
Changes to test/permutations.test.
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
namespace eval ::perm {
  variable testmode [lindex $::argv 0]
  variable testfile [lindex $::argv 1]
}
set argv [lrange $argv 2 end]
#puts "PERM-DEBUG: testmode=$::perm::testmode tstfile=$::perm::testfile"

set ::permutations_presql ""
set ::permutations_test_prefix ""

if {$::perm::testmode eq "veryquick"} {
  set ::perm::testmode [list persistent_journal no_journal]
  set ISQUICK 1
}
if {$::perm::testmode eq "quick"} {
  set ::perm::testmode [list persistent_journal no_journal autovacuum_ioerr]
  set ISQUICK 1
}
if {$::perm::testmode eq "all" || $::perm::testmode eq ""} {
  set ::perm::testmode {
    memsubsys1 memsubsys2 singlethread multithread onefile utf16 exclusive
    persistent_journal persistent_journal_error no_journal no_journal_error
    autovacuum_ioerr no_mutex_try fullmutex journaltest inmemory_journal
    pcache0 pcache10 pcache50 pcache90 pcache100







<
<
<


|



|







20
21
22
23
24
25
26



27
28
29
30
31
32
33
34
35
36
37
38
39
40
namespace eval ::perm {
  variable testmode [lindex $::argv 0]
  variable testfile [lindex $::argv 1]
}
set argv [lrange $argv 2 end]
#puts "PERM-DEBUG: testmode=$::perm::testmode tstfile=$::perm::testfile"




if {$::perm::testmode eq "veryquick"} {
  set ::perm::testmode [list persistent_journal no_journal]
  set G(isquick) 1
}
if {$::perm::testmode eq "quick"} {
  set ::perm::testmode [list persistent_journal no_journal autovacuum_ioerr]
  set G(isquick) 1
}
if {$::perm::testmode eq "all" || $::perm::testmode eq ""} {
  set ::perm::testmode {
    memsubsys1 memsubsys2 singlethread multithread onefile utf16 exclusive
    persistent_journal persistent_journal_error no_journal no_journal_error
    autovacuum_ioerr no_mutex_try fullmutex journaltest inmemory_journal
    pcache0 pcache10 pcache50 pcache90 pcache100
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125



126





127
128
129
130
131
132
133
134
135
136
137
138





139
140
141
142
143
144
145
146
147
148

149

150
151
152
153
154
155
156
157

158
159



160
161
162
163
164
165
166
}
set ALLTESTS [lsort $ALLTESTS]
set WALTESTS [list]
foreach filename $ALLTESTS {
  if {[regexp {^wal} $filename]} {lappend WALTESTS $filename}
}

rename finish_test really_finish_test2
proc finish_test {} {}

rename do_test really_do_test

proc do_test {name args} {
  eval really_do_test [list "perm-$::permutations_test_prefix.$name"] $args
}

# Overload the [sqlite3] command
rename sqlite3 really_sqlite3
proc sqlite3 {args} {
  set r [eval really_sqlite3 $args]
  if { [llength $args] == 2 && $::permutations_presql ne "" } {
    [lindex $args 0] eval $::permutations_presql
  }
  set r
}

# run_tests OPTIONS
#
# where available options are:  
#

#       -initialize  SCRIPT                 (default "")
#       -shutdown    SCRIPT                 (default "")
#       -include     LIST-OF-FILES          (default $::ALLTESTS)
#       -exclude     LIST-OF-FILES          (default "")
#       -presql      SQL                    (default "")
#       -description TITLE                  (default "")
#
proc run_tests {name args} {
  set ::permutations_test_prefix $name
  set options(-shutdown) ""
  set options(-initialize) ""
  set options(-exclude) ""
  set options(-include) $::ALLTESTS
  set options(-presql) ""
  set options(-description) "no description supplied (fixme)"



  array set options $args





  #puts "PERM-DEBUG: name=$name testfile=$::perm::testfile"
  #puts "PERM-DEBUG: [array get options]"

  if {$::perm::testmode eq "targets"} {
    puts [format "% -20s %s" $name [string trim $options(-description)]]
    return
  }
  if {$::perm::testmode ne "" && [lsearch $::perm::testmode $name]<0} {
    puts "skipping permutation test $name..."
    return
  }






  uplevel $options(-initialize)
  set ::permutations_presql $options(-presql)

  foreach file [lsort $options(-include)] {
    if {[lsearch $options(-exclude) $file] < 0 &&
       ( $::perm::testfile eq "" ||
         $::perm::testfile eq $file ||
        "$::perm::testfile.test" eq $file )
    } {
      set ::perm::shared_cache_setting [shared_cache_setting]

      uplevel source $::testdir/$file

      if {$::perm::shared_cache_setting ne [shared_cache_setting]} {
        error "File $::testdir/$file changed the shared cache setting from $::perm::shared_cache_setting to [shared_cache_setting]"
      }
    } else {
      # puts "skipping file $file"
    }
  }


  uplevel $options(-shutdown)
  set ::permutations_test_prefix ""



}

proc shared_cache_setting {} {
  set ret 0
  catch {
    set ret [sqlite3_enable_shared_cache]
  }







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|



>





|


|
|
|
|
|
|
|
>
>
>

>
>
>
>
>












>
>
>
>
>

<








>
|
>








>

|
>
>
>







78
79
80
81
82
83
84



















85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
}
set ALLTESTS [lsort $ALLTESTS]
set WALTESTS [list]
foreach filename $ALLTESTS {
  if {[regexp {^wal} $filename]} {lappend WALTESTS $filename}
}




















# run_tests NAME OPTIONS
#
# where available options are:  
#
#       -description TITLE                  (default "")
#       -initialize  SCRIPT                 (default "")
#       -shutdown    SCRIPT                 (default "")
#       -include     LIST-OF-FILES          (default $::ALLTESTS)
#       -exclude     LIST-OF-FILES          (default "")
#       -presql      SQL                    (default "")
#       -options     LIST                   (default "")
#
proc run_tests {name args} {

  set default(-shutdown) ""
  set default(-initialize) ""
  set default(-exclude) ""
  set default(-include) $::ALLTESTS
  set default(-presql) ""
  set default(-description) "no description supplied (fixme)"
  set default(-options) ""

  array set options [array get default]
  array set options $args
  foreach k [array names options] {
    if {[info exists default($k)]==0} {
      error "Unknown option: $k"
    }
  }
  #puts "PERM-DEBUG: name=$name testfile=$::perm::testfile"
  #puts "PERM-DEBUG: [array get options]"

  if {$::perm::testmode eq "targets"} {
    puts [format "% -20s %s" $name [string trim $options(-description)]]
    return
  }
  if {$::perm::testmode ne "" && [lsearch $::perm::testmode $name]<0} {
    puts "skipping permutation test $name..."
    return
  }


  set ::G(perm:name)         $name
  set ::G(perm:presql)       $options(-presql)
  set ::G(perm:sqlite3_args) $options(-options)

  uplevel $options(-initialize)


  foreach file [lsort $options(-include)] {
    if {[lsearch $options(-exclude) $file] < 0 &&
       ( $::perm::testfile eq "" ||
         $::perm::testfile eq $file ||
        "$::perm::testfile.test" eq $file )
    } {
      set ::perm::shared_cache_setting [shared_cache_setting]

      slave_test_file $::testdir/$file

      if {$::perm::shared_cache_setting ne [shared_cache_setting]} {
        error "File $::testdir/$file changed the shared cache setting from $::perm::shared_cache_setting to [shared_cache_setting]"
      }
    } else {
      # puts "skipping file $file"
    }
  }


  uplevel $options(-shutdown)

  unset ::G(perm:name)
  unset ::G(perm:presql)
  unset ::G(perm:sqlite3_args)
}

proc shared_cache_setting {} {
  set ret 0
  catch {
    set ret [sqlite3_enable_shared_cache]
  }
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
  sqlite3_initialize
  autoinstall_test_functions
} -include ${perm-alt-pcache-testset}

run_tests "journaltest" -description {
  Check that pages are synced before being written (test_journal.c).
} -initialize {
  set ISQUICK 1
  catch {db close}
  register_jt_vfs -default ""
  #sqlite3_instvfs binarylog -default binarylog ostrace.bin
} -shutdown {
  #sqlite3_instvfs destroy binarylog
  unregister_jt_vfs
} -include $::ALLTESTS -exclude [concat $::WALTESTS {
  incrvacuum.test
  ioerr.test
  corrupt4.test 
  io.test 
  crash8.test 
  async4.test 
  bigfile.test
}]

if {[info commands register_demovfs] != ""} {
  run_tests "demovfs" -description {
    Check that pages are synced before being written (test_journal.c).
  } -initialize {
    register_demovfs
  } -shutdown {
    unregister_demovfs
  } -include {
    insert.test   insert2.test  insert3.test rollback.test 
    select1.test  select2.test  select3.test
  }
}

run_tests "wal" -description {
  Run tests with journal_mode=WAL
} -initialize {
  set ::savepoint6_iterations 100
} -shutdown {
  unset -nocomplain ::savepoint6_iterations
} -include {
  savepoint.test     savepoint2.test     savepoint6.test
  trans.test         avtrans.test
}

# End of tests
#############################################################################

if {$::perm::testmode eq "targets"} { puts "" ; exit }

# Restore the [sqlite3] command.
#
rename sqlite3 {}
rename really_sqlite3 sqlite3

# Restore the [finish_test] command.
#
rename finish_test ""
rename really_finish_test2 finish_test

# Restore the [do_test] command.
#
rename do_test ""
rename really_do_test do_test

finish_test







|


















|













|

|










<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776















777
  sqlite3_initialize
  autoinstall_test_functions
} -include ${perm-alt-pcache-testset}

run_tests "journaltest" -description {
  Check that pages are synced before being written (test_journal.c).
} -initialize {
  set G(isquick) 1
  catch {db close}
  register_jt_vfs -default ""
  #sqlite3_instvfs binarylog -default binarylog ostrace.bin
} -shutdown {
  #sqlite3_instvfs destroy binarylog
  unregister_jt_vfs
} -include $::ALLTESTS -exclude [concat $::WALTESTS {
  incrvacuum.test
  ioerr.test
  corrupt4.test 
  io.test 
  crash8.test 
  async4.test 
  bigfile.test
}]

if {[info commands register_demovfs] != ""} {
  run_tests "demovfs" -description {
    Check that the demovfs (code in test_demovfs.c) more or less works.
  } -initialize {
    register_demovfs
  } -shutdown {
    unregister_demovfs
  } -include {
    insert.test   insert2.test  insert3.test rollback.test 
    select1.test  select2.test  select3.test
  }
}

run_tests "wal" -description {
  Run tests with journal_mode=WAL
} -initialize {
  set ::G(savepoint6_iterations) 100
} -shutdown {
  unset -nocomplain ::G(savepoint6_iterations)
} -include {
  savepoint.test     savepoint2.test     savepoint6.test
  trans.test         avtrans.test
}

# End of tests
#############################################################################

if {$::perm::testmode eq "targets"} { puts "" ; exit }
















finish_test
Changes to test/quick.test.
1
2
3
4
5
6
7
8
9



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
#
#    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 runs all tests.
#
# $Id: quick.test,v 1.95 2009/03/16 14:48:19 danielk1977 Exp $




proc lshift {lvar} {
  upvar $lvar l
  set ret [lindex $l 0]
  set l [lrange $l 1 end]
  return $ret
}
while {[set arg [lshift argv]] != ""} {
  switch -- $arg {
    -sharedpagercache {
      sqlite3_enable_shared_cache 1
    }
    -soak {
       set SOAKTEST 1
    }
    -start {
       set STARTAT "[lshift argv]*"
    }
    default {
      set argv [linsert $argv 0 $arg]
      break
    }
  }
}

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {
  catch {db close}
  show_memstats
}
set ISQUICK 1

set EXCLUDE {
  all.test
  async.test
  async2.test
  async3.test
  backup_ioerr.test








|
>
>
>













|











<
<
<
<
<
<
<
|







1
2
3
4
5
6
7
8
9
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
#
#    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 runs all tests.
#

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

proc lshift {lvar} {
  upvar $lvar l
  set ret [lindex $l 0]
  set l [lrange $l 1 end]
  return $ret
}
while {[set arg [lshift argv]] != ""} {
  switch -- $arg {
    -sharedpagercache {
      sqlite3_enable_shared_cache 1
    }
    -soak {
       set G(issoak) 1
    }
    -start {
       set STARTAT "[lshift argv]*"
    }
    default {
      set argv [linsert $argv 0 $arg]
      break
    }
  }
}








set G(isquick) 1

set EXCLUDE {
  all.test
  async.test
  async2.test
  async3.test
  backup_ioerr.test
123
124
125
126
127
128
129










130
131
132
133
134
135
136
137
138
139



140


141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159

# it as a list of test files. Always run these files, even if they
# begin with "malloc*" or "ioerr*" or are part of the EXCLUDE list
# defined above.
#
set QUICKTEST_INCLUDE {}
catch { set QUICKTEST_INCLUDE $env(QUICKTEST_INCLUDE) }











foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
  set tail [file tail $testfile]
  if { [lsearch $QUICKTEST_INCLUDE $tail]<0 } {
    # If this is "veryquick.test", do not run any of the malloc or 
    # IO error simulations.
    if {[info exists ISVERYQUICK] && (
      [string match *malloc* $testfile] || [string match *ioerr* $testfile]
    ) } {
      continue
    }



    if {[lsearch -exact $EXCLUDE $tail]>=0} continue


  }
  if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
  if {[info exists STARTAT] && [string match $STARTAT $tail]} {unset STARTAT}
  if {[info exists STARTAT]} continue
  source $testfile
  catch {db close}
  if {$sqlite_open_file_count>0} {
    puts "$tail did not close all files: $sqlite_open_file_count"
    fail_test $tail
    set sqlite_open_file_count 0
  }
}
#set argv quick
#source $testdir/permutations.test
#set argv ""
source $testdir/misuse.test

set sqlite_open_file_count 0
really_finish_test








>
>
>
>
>
>
>
>
>
>


|
<
<
|
<
<
|
|
>
>
>
|
>
>
|
<
<
|
|
<
<
<
<
<


<
<
<
|

<
|
>
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138


139


140
141
142
143
144
145
146
147
148


149
150





151
152



153
154

155
156
# it as a list of test files. Always run these files, even if they
# begin with "malloc*" or "ioerr*" or are part of the EXCLUDE list
# defined above.
#
set QUICKTEST_INCLUDE {}
catch { set QUICKTEST_INCLUDE $env(QUICKTEST_INCLUDE) }

# Run all test files in directory $testdir, subject to the following:
#
#   1. If a test file is specified as part of the $INCLUDE or 
#      $QUICKTEST_INCLUDE list variables, run it.
#
#   2. If $INCLUDE is non-empty, and rule 1 does not apply to it, do not run it.
#
#   3. If a test file is specified as part of $EXCLUDE, and rule 1 does not
#      apply, do not run it.
#
foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
  set tail [file tail $testfile]



  if {[info exists STARTAT] && [string match $STARTAT $tail]} {unset STARTAT}


  if {[info exists STARTAT]} continue

  set run [expr {[llength $INCLUDE]==0}]
  if {[info exists ISVERYQUICK] && [string match *malloc* $tail]} { set run 0 }
  if {[info exists ISVERYQUICK] && [string match *ioerr* $tail]}  { set run 0 }
  if {[lsearch -exact $EXCLUDE $tail]>=0}                         { set run 0 }
  if {[lsearch -exact $INCLUDE $tail]>=0}                         { set run 1 }
  if {[lsearch -exact $QUICKTEST_INCLUDE $tail]>=0}               { set run 1 }



  if {$run} {
    slave_test_file $testfile





  }
}



slave_test_file $testdir/misuse.test


finish_test

Changes to test/rollback.test.
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
do_test rollback-1.8 {
  sqlite3_step $STMT
} {SQLITE_ROW}
do_test rollback-1.9 {
  sqlite3_finalize $STMT
} {SQLITE_OK}

set permutation ""
catch {set permutation $::permutations_test_prefix}
if {$tcl_platform(platform) == "unix" 
 && $permutation ne "onefile"
 && $permutation ne "inmemory_journal"
} {
  do_test rollback-2.1 {
    execsql {
      BEGIN;
      INSERT INTO t3 VALUES('hello world');
    }
    file copy -force test.db testA.db







<
<

|
|







75
76
77
78
79
80
81


82
83
84
85
86
87
88
89
90
91
do_test rollback-1.8 {
  sqlite3_step $STMT
} {SQLITE_ROW}
do_test rollback-1.9 {
  sqlite3_finalize $STMT
} {SQLITE_OK}



if {$tcl_platform(platform) == "unix" 
 && [permutation] ne "onefile"
 && [permutation] ne "inmemory_journal"
} {
  do_test rollback-2.1 {
    execsql {
      BEGIN;
      INSERT INTO t3 VALUES('hello world');
    }
    file copy -force test.db testA.db
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
  # 
  do_test rollback-2.2 {
    sqlite3 db2 testA.db
    execsql {
      SELECT distinct tbl_name FROM sqlite_master;
    } db2
  } {t1 t3}
  if {[lsearch {exclusive persistent_journal no_journal} $permutation]<0} {
    do_test rollback-2.3 {
      file exists testA.db-journal
    } 0
  }
  do_test rollback-2.4 {
    execsql {
      SELECT distinct tbl_name FROM sqlite_master;







|







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  # 
  do_test rollback-2.2 {
    sqlite3 db2 testA.db
    execsql {
      SELECT distinct tbl_name FROM sqlite_master;
    } db2
  } {t1 t3}
  if {[lsearch {exclusive persistent_journal no_journal} [permutation]]<0} {
    do_test rollback-2.3 {
      file exists testA.db-journal
    } 0
  }
  do_test rollback-2.4 {
    execsql {
      SELECT distinct tbl_name FROM sqlite_master;
Changes to test/rtree.test.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
set testdir [file dirname $argv0]
source $testdir/tester.tcl

rename finish_test rtree_finish_test
proc finish_test {} {}

set RTREE_EXCLUDE { }
if {[info exists ISQUICK] && $ISQUICK} { 
  set RTREE_EXCLUDE rtree3.test
}

set rtreedir [file join $testdir .. ext rtree]

foreach testfile [lsort -dictionary [glob -nocomplain $rtreedir/*.test]] {
  set tail [file tail $testfile]







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
set testdir [file dirname $argv0]
source $testdir/tester.tcl

rename finish_test rtree_finish_test
proc finish_test {} {}

set RTREE_EXCLUDE { }
if {[info exists G(isquick)] && $G(isquick)} { 
  set RTREE_EXCLUDE rtree3.test
}

set rtreedir [file join $testdir .. ext rtree]

foreach testfile [lsort -dictionary [glob -nocomplain $rtreedir/*.test]] {
  set tail [file tail $testfile]
Changes to test/savepoint6.test.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
set DATABASE_SCHEMA {
    PRAGMA auto_vacuum = incremental;
    CREATE TABLE t1(x, y);
    CREATE UNIQUE INDEX i1 ON t1(x);
    CREATE INDEX i2 ON t1(y);
}

if {0==[info exists ::savepoint6_iterations]} {
  set ::savepoint6_iterations 1000
}

#--------------------------------------------------------------------------
# In memory database state.
#
# ::lSavepoint is a list containing one entry for each active savepoint. The
# first entry in the list corresponds to the most recently opened savepoint.







|
|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
set DATABASE_SCHEMA {
    PRAGMA auto_vacuum = incremental;
    CREATE TABLE t1(x, y);
    CREATE UNIQUE INDEX i1 ON t1(x);
    CREATE INDEX i2 ON t1(y);
}

if {0==[info exists ::G(savepoint6_iterations)]} {
  set ::G(savepoint6_iterations) 1000
}

#--------------------------------------------------------------------------
# In memory database state.
#
# ::lSavepoint is a list containing one entry for each active savepoint. The
# first entry in the list corresponds to the most recently opened savepoint.
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
  set testname normal
  sqlite3 db test.db
} {
  if {[wal_is_wal_mode]} continue
  set testname tempdb
  sqlite3 db ""
} {
  if {[catch {set ::permutations_test_prefix} z] == 0 && $z eq "journaltest"} {
    continue
  }
  set testname nosync
  sqlite3 db test.db
  sql { PRAGMA synchronous = off }
} {
  set testname smallcache







|







226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
  set testname normal
  sqlite3 db test.db
} {
  if {[wal_is_wal_mode]} continue
  set testname tempdb
  sqlite3 db ""
} {
  if {[permutation] eq "journaltest"} {
    continue
  }
  set testname nosync
  sqlite3 db test.db
  sql { PRAGMA synchronous = off }
} {
  set testname smallcache
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
  do_test savepoint6-$testname.setup {
    savepoint one
    insert_rows [random_integers 100 1000]
    release one
    checkdb
  } {ok}
  
  for {set i 0} {$i < $::savepoint6_iterations} {incr i} {
    do_test savepoint6-$testname.$i.1 {
      savepoint_op
      checkdb
    } {ok}
  
    do_test savepoint6-$testname.$i.2 {
      database_op







|







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
  do_test savepoint6-$testname.setup {
    savepoint one
    insert_rows [random_integers 100 1000]
    release one
    checkdb
  } {ok}
  
  for {set i 0} {$i < $::G(savepoint6_iterations)} {incr i} {
    do_test savepoint6-$testname.$i.1 {
      savepoint_op
      checkdb
    } {ok}
  
    do_test savepoint6-$testname.$i.2 {
      database_op
Changes to test/select9.test.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# TODO Points:
#
#   * Are there any "column affinity" issues to consider?

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

#set ISQUICK 1

#-------------------------------------------------------------------------
# test_compound_select TESTNAME SELECT RESULT
#
#   This command is used to run multiple LIMIT/OFFSET test cases based on 
#   the single SELECT statement passed as the second argument. The SELECT
#   statement may not contain a LIMIT or OFFSET clause. This proc tests
#   many statements of the form:







<
<







21
22
23
24
25
26
27


28
29
30
31
32
33
34
# TODO Points:
#
#   * Are there any "column affinity" issues to consider?

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



#-------------------------------------------------------------------------
# test_compound_select TESTNAME SELECT RESULT
#
#   This command is used to run multiple LIMIT/OFFSET test cases based on 
#   the single SELECT statement passed as the second argument. The SELECT
#   statement may not contain a LIMIT or OFFSET clause. This proc tests
#   many statements of the form:
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  do_test $testname { 
    execsql $::compound_sql
  } $result
#return

  set iLimitIncr  1
  set iOffsetIncr 1
  if {[info exists ::ISQUICK] && $::ISQUICK && $nRow>=5} {
    set iOffsetIncr [expr $nRow / 5]
    set iLimitIncr [expr $nRow / 5]
  }

  set iLimitEnd   [expr $nRow+$iLimitIncr]
  set iOffsetEnd  [expr $nRow+$iOffsetIncr]








|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  do_test $testname { 
    execsql $::compound_sql
  } $result
#return

  set iLimitIncr  1
  set iOffsetIncr 1
  if {[info exists ::G(isquick)] && $::G(isquick) && $nRow>=5} {
    set iOffsetIncr [expr $nRow / 5]
    set iLimitIncr [expr $nRow / 5]
  }

  set iLimitEnd   [expr $nRow+$iLimitIncr]
  set iOffsetEnd  [expr $nRow+$iOffsetIncr]

Changes to test/soak.test.
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
set SOAKTESTS {
  fuzz.test
  fuzz_malloc.test
  trans.test
  corruptC.test
}

set ISQUICK 1

set soak_starttime  [clock seconds]
set soak_finishtime [expr {$soak_starttime + $TIMEOUT}]

# Loop until the timeout is reached or an error occurs.
#
for {set iRun 0} {[clock seconds] < $soak_finishtime} {incr iRun} {







|







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
set SOAKTESTS {
  fuzz.test
  fuzz_malloc.test
  trans.test
  corruptC.test
}

set G(isquick) 1

set soak_starttime  [clock seconds]
set soak_finishtime [expr {$soak_starttime + $TIMEOUT}]

# Loop until the timeout is reached or an error occurs.
#
for {set iRun 0} {[clock seconds] < $soak_finishtime} {incr iRun} {
Changes to test/tclsqlite.test.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
source $testdir/tester.tcl

# Check the error messages generated by tclsqlite
#
if {[sqlite3 -has-codec]} {
  set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?"
} else {
  set r "sqlite3 HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN?"
}
do_test tcl-1.1 {
  set v [catch {sqlite3 bogus} msg]
  regsub {really_sqlite3} $msg {sqlite3} msg
  lappend v $msg
} [list 1 "wrong # args: should be \"$r\""]
do_test tcl-1.2 {







|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
source $testdir/tester.tcl

# Check the error messages generated by tclsqlite
#
if {[sqlite3 -has-codec]} {
  set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?"
} else {
  set r "sqlite_orig HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN?"
}
do_test tcl-1.1 {
  set v [catch {sqlite3 bogus} msg]
  regsub {really_sqlite3} $msg {sqlite3} msg
  lappend v $msg
} [list 1 "wrong # args: should be \"$r\""]
do_test tcl-1.2 {
Changes to test/tempdb.test.
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

do_test tempdb-2.1 {
  # Set $::jrnl_in_memory if the journal file is expected to be in-memory.
  # Similarly, set $::subj_in_memory if the sub-journal file is expected
  # to be in memory. These variables are used to calculate the expected
  # number of open files in the test cases below.
  #
  set jrnl_in_memory [expr {
    [info exists ::permutations_test_prefix] &&
    $::permutations_test_prefix eq "inmemory_journal"
  }]
  set subj_in_memory [expr {$jrnl_in_memory || $TEMP_STORE == 3}]

  db close
  sqlite3 db test.db
} {}
do_test tempdb-2.2 {
  execsql {







|
<
<
<







54
55
56
57
58
59
60
61



62
63
64
65
66
67
68

do_test tempdb-2.1 {
  # Set $::jrnl_in_memory if the journal file is expected to be in-memory.
  # Similarly, set $::subj_in_memory if the sub-journal file is expected
  # to be in memory. These variables are used to calculate the expected
  # number of open files in the test cases below.
  #
  set jrnl_in_memory [expr {[permutation] eq "inmemory_journal"}]



  set subj_in_memory [expr {$jrnl_in_memory || $TEMP_STORE == 3}]

  db close
  sqlite3 db test.db
} {}
do_test tempdb-2.2 {
  execsql {
Changes to test/tester.tcl.
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
# Commands to run test cases:
#
#      do_ioerr_test          TESTNAME ARGS...
#      crashsql               ARGS...
#      integrity_check        TESTNAME ?DB?
#      do_test                TESTNAME SCRIPT EXPECTED
#
# Commands providing a lower level interface to the test counters:
#
#      set_test_counter       COUNTER ?VALUE?
#      omit_test              TESTNAME REASON
#      fail_test              TESTNAME
#      incr_ntest
#
# Command run at the end of each test file:
#
#      finish_test
#
# Commands to help create test files that run with the "WAL" permutation:

#
#      wal_is_wal_mode
#      wal_set_journal_mode   ?DB?
#      wal_check_journal_mode TESTNAME?DB?

#

# Set the precision of FP arithmatic used by the interpreter. And 
# configure SQLite to take database file locks on the page that begins
# 64KB into the database file instead of the one 1GB in. This means
# the code that handles that special case can be tested without creating
# very large database files.







|










|
>




>







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
# Commands to run test cases:
#
#      do_ioerr_test          TESTNAME ARGS...
#      crashsql               ARGS...
#      integrity_check        TESTNAME ?DB?
#      do_test                TESTNAME SCRIPT EXPECTED
#
# Commands providing a lower level interface to the global test counters:
#
#      set_test_counter       COUNTER ?VALUE?
#      omit_test              TESTNAME REASON
#      fail_test              TESTNAME
#      incr_ntest
#
# Command run at the end of each test file:
#
#      finish_test
#
# Commands to help create test files that run with the "WAL" and other
# permutations (see file permutations.test):
#
#      wal_is_wal_mode
#      wal_set_journal_mode   ?DB?
#      wal_check_journal_mode TESTNAME?DB?
#      permutation
#

# Set the precision of FP arithmatic used by the interpreter. And 
# configure SQLite to take database file locks on the page that begins
# 64KB into the database file instead of the one 1GB in. This means
# the code that handles that special case can be tested without creating
# very large database files.
83
84
85
86
87
88
89
90
91
92
93






94
95

96










97
98
99
100


101
102
103
104
105
106
107
#
#     sqlite3 db test.db
#
# becomes
#
#     sqlite3 db test.db -key {xyzzy}
#
if {[sqlite3 -has-codec] && [info command sqlite_orig]==""} {
  rename sqlite3 sqlite_orig
  proc sqlite3 {args} {
    if {[llength $args]==2 && [string index [lindex $args 0] 0]!="-"} {






      lappend args -key {xyzzy}
    }

    uplevel 1 sqlite_orig $args










  }
}

# The following block only runs the first time this file is sourced.


#
if {[info exists cmdlinearg]==0} {

  # Parse any options specified in the $argv array. This script accepts the 
  # following options: 
  #
  #   --pause







|



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



|
>
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#
#     sqlite3 db test.db
#
# becomes
#
#     sqlite3 db test.db -key {xyzzy}
#
if {[info command sqlite_orig]==""} {
  rename sqlite3 sqlite_orig
  proc sqlite3 {args} {
    if {[llength $args]==2 && [string index [lindex $args 0] 0]!="-"} {
      # This command is opening a new database connection.
      #
      if {[info exists ::G(perm:sqlite3_args)]} {
        set args [concat $args $::G(perm:sqlite3_args)]
      }
      if {[sqlite_orig -has-codec]} {
        lappend args -key {xyzzy}
      }

      uplevel 1 sqlite_orig $args

      if {[info exists ::G(perm:presql)]} {
        [lindex $args 0] eval $::G(perm:presql)
      }
    } else {
      # This command is not opening a new database connection. Pass the 
      # arguments through to the C implemenation as the are.
      #
      uplevel 1 sqlite_orig $args
    }
  }
}

# The following block only runs the first time this file is sourced. It
# does not run in slave interpreters (since the ::cmdlinearg array is
# populated before the test script is run in slave interpreters).
#
if {[info exists cmdlinearg]==0} {

  # Parse any options specified in the $argv array. This script accepts the 
  # following options: 
  #
  #   --pause
149
150
151
152
153
154
155



156
157
158
159
160



161
162
163
164
165
166
167
      default {
        lappend leftover $a
      }
    }
  }
  set argv $leftover




  sqlite3_shutdown 
  install_malloc_faultsim 1 
  sqlite3_initialize
  autoinstall_test_functions




  if {$cmdlinearg(binarylog)} {
    vfslog new binarylog {} vfslog.bin
  }

  # Set the backtrace depth, if malloc tracing is enabled.
  #
  if {$cmdlinearg(malloctrace)} {







>
>
>





>
>
>







170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
      default {
        lappend leftover $a
      }
    }
  }
  set argv $leftover

  # Install the malloc layer used to inject OOM errors. And the 'automatic'
  # extensions. This only needs to be done once for the process.
  #
  sqlite3_shutdown 
  install_malloc_faultsim 1 
  sqlite3_initialize
  autoinstall_test_functions

  # If the --binarylog option was specified, create the logging VFS. This
  # call installs the new VFS as the default for all SQLite connections.
  #
  if {$cmdlinearg(binarylog)} {
    vfslog new binarylog {} vfslog.bin
  }

  # Set the backtrace depth, if malloc tracing is enabled.
  #
  if {$cmdlinearg(malloctrace)} {
258
259
260
261
262
263
264





265
266
267
268
269
270
271
      if {[string match $pattern $name]} {
        set go 1
        break
      }
    }
  }
  if {!$go} return





  incr_ntest
  puts -nonewline $name...
  flush stdout
  if {[catch {uplevel #0 "$cmd;\n"} result]} {
    puts "\nError: $result"
    fail_test $name
  } elseif {[string compare $result $expected]} {







>
>
>
>
>







285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
      if {[string match $pattern $name]} {
        set go 1
        break
      }
    }
  }
  if {!$go} return

  if {[info exists ::G(perm:name)]} {
    set name "$::G(perm:name)-$name"
  }

  incr_ntest
  puts -nonewline $name...
  flush stdout
  if {[catch {uplevel #0 "$cmd;\n"} result]} {
    puts "\nError: $result"
    fail_test $name
  } elseif {[string compare $result $expected]} {
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035

1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065






1066
1067
1068
1069
1070
1071
1072
  }
  ifcapable trigger&&foreignkey {
    $db eval "PRAGMA foreign_keys = $pk"
  }
}

#-------------------------------------------------------------------------
# If a test script is executed with global variable 
# $::permutations_test_prefix set to "wal", then the tests are run
# in WAL mode. Otherwise, they should be run in rollback mode. The 
# following Tcl procs are used to make this less intrusive:

#
#   wal_set_journal_mode ?DB?
#
#     If running a WAL test, execute "PRAGMA journal_mode = wal" using
#     connection handle DB. Otherwise, this command is a no-op.
#
#   wal_check_journal_mode TESTNAME ?DB?
#
#     If running a WAL test, execute a tests case that fails if the main
#     database for connection handle DB is not currently a WAL database.
#     Otherwise (if not running a WAL permutation) this is a no-op.
#
#   wal_is_wal_mode
#   
#     Returns true if this test should be run in WAL mode. False otherwise.
# 
proc wal_is_wal_mode {} {
  expr { [catch {set ::permutations_test_prefix} v]==0 && $v == "wal" }
}
proc wal_set_journal_mode {{db db}} {
  if { [wal_is_wal_mode] } {
    $db eval "PRAGMA journal_mode = WAL"
  }
}
proc wal_check_journal_mode {testname {db db}} {
  if { [wal_is_wal_mode] } {
    $db eval { SELECT * FROM sqlite_master }
    do_test $testname [list $db eval "PRAGMA main.journal_mode"] {wal}
  }
}







#-------------------------------------------------------------------------
#
proc slave_test_script {script} {

  # Create the interpreter used to run the test script.
  interp create tinterp







|
<
|
|
>

















|












>
>
>
>
>
>







1057
1058
1059
1060
1061
1062
1063
1064

1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
  }
  ifcapable trigger&&foreignkey {
    $db eval "PRAGMA foreign_keys = $pk"
  }
}

#-------------------------------------------------------------------------
# If a test script is executed with global variable $::G(perm:name) set to

# "wal", then the tests are run in WAL mode. Otherwise, they should be run 
# in rollback mode. The following Tcl procs are used to make this less 
# intrusive:
#
#   wal_set_journal_mode ?DB?
#
#     If running a WAL test, execute "PRAGMA journal_mode = wal" using
#     connection handle DB. Otherwise, this command is a no-op.
#
#   wal_check_journal_mode TESTNAME ?DB?
#
#     If running a WAL test, execute a tests case that fails if the main
#     database for connection handle DB is not currently a WAL database.
#     Otherwise (if not running a WAL permutation) this is a no-op.
#
#   wal_is_wal_mode
#   
#     Returns true if this test should be run in WAL mode. False otherwise.
# 
proc wal_is_wal_mode {} {
  expr {[permutation] eq "wal"}
}
proc wal_set_journal_mode {{db db}} {
  if { [wal_is_wal_mode] } {
    $db eval "PRAGMA journal_mode = WAL"
  }
}
proc wal_check_journal_mode {testname {db db}} {
  if { [wal_is_wal_mode] } {
    $db eval { SELECT * FROM sqlite_master }
    do_test $testname [list $db eval "PRAGMA main.journal_mode"] {wal}
  }
}

proc permutation {} {
  set perm ""
  catch {set perm $::G(perm:name)}
  set perm
}

#-------------------------------------------------------------------------
#
proc slave_test_script {script} {

  # Create the interpreter used to run the test script.
  interp create tinterp
1082
1083
1084
1085
1086
1087
1088



1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100


1101
1102
1103








1104


1105
1106
1107
1108
1109
1110
1111
1112

  # The alias used to access the global test counters.
  tinterp alias set_test_counter set_test_counter

  # Set up the ::cmdlinearg array in the slave.
  interp eval tinterp [list array set ::cmdlinearg [array get ::cmdlinearg]]




  # Load the various test interfaces implemented in C.
  load_testfixture_extensions tinterp

  # Run the test script.
  interp eval tinterp $script

  # Delete the interpreter used to run the test script.
  interp delete tinterp
}

proc slave_test_file {file} {
  set zFile [file join $::testdir $file]


  set time [time {
    slave_test_script [list source $zFile]
  }]








  puts "time $file [lrange $time 0 1]"


}


# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
# to non-zero, then set the global variable $AUTOVACUUM to 1.
set AUTOVACUUM $sqlite_options(default_autovacuum)

source $testdir/thread_common.tcl







>
>
>










|
|
>
>



>
>
>
>
>
>
>
>
|
>
>








1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165

  # The alias used to access the global test counters.
  tinterp alias set_test_counter set_test_counter

  # Set up the ::cmdlinearg array in the slave.
  interp eval tinterp [list array set ::cmdlinearg [array get ::cmdlinearg]]

  # Set up the ::G array in the slave.
  interp eval tinterp [list array set ::G [array get ::G]]

  # Load the various test interfaces implemented in C.
  load_testfixture_extensions tinterp

  # Run the test script.
  interp eval tinterp $script

  # Delete the interpreter used to run the test script.
  interp delete tinterp
}

proc slave_test_file {zFile} {

  set ::sqlite_open_file_count 0

  set time [time {
    slave_test_script [list source $zFile]
  }]

  set tail [file tail $zFile]
  if {$::sqlite_open_file_count>0} {
    puts "$tail did not close all files: $::sqlite_open_file_count"
    fail_test $tail
    set ::sqlite_open_file_count 0
    exit
  }
  puts "time $tail [lrange $time 0 1]"

  show_memstats
}


# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
# to non-zero, then set the global variable $AUTOVACUUM to 1.
set AUTOVACUUM $sqlite_options(default_autovacuum)

source $testdir/thread_common.tcl
Changes to test/trans.test.
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# t3 a little larger, and thus takes a little longer, so doing 40 tests
# is more than 2.0 times slower than doing 20 tests.  Considerably more.
#
# Also, if temporary tables are stored in memory and the test pcache
# is in use, only 20 iterations. Otherwise the test pcache runs out
# of page slots and SQLite reports "out of memory".
#
if {[info exists ISQUICK] || (
  $TEMP_STORE==3 && [catch {set ::permutations_test_prefix} val]==0 && 
  [regexp {^pcache[[:digit:]]*$} $val]
) } {
  set limit 20
} elseif {[info exists SOAKTEST]} {
  set limit 100
} else {
  set limit 40
}

# Do rollbacks.  Make sure the signature does not change.
#







|
<
|


|







879
880
881
882
883
884
885
886

887
888
889
890
891
892
893
894
895
896
897
# t3 a little larger, and thus takes a little longer, so doing 40 tests
# is more than 2.0 times slower than doing 20 tests.  Considerably more.
#
# Also, if temporary tables are stored in memory and the test pcache
# is in use, only 20 iterations. Otherwise the test pcache runs out
# of page slots and SQLite reports "out of memory".
#
if {[info exists G(isquick)] || (

  $TEMP_STORE==3 && [regexp {^pcache[[:digit:]]*$} [permutation]]
) } {
  set limit 20
} elseif {[info exists G(issoak)]} {
  set limit 100
} else {
  set limit 40
}

# Do rollbacks.  Make sure the signature does not change.
#