1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Many test cases fixed to work with encryption.

FossilOrigin-Name: d866fffb8b1af5003a8730ce7029d1edddb24d46
This commit is contained in:
drh
2016-03-14 17:05:04 +00:00
parent 7bd6b49a3e
commit af3906a798
19 changed files with 141 additions and 129 deletions

View File

@@ -23,6 +23,11 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix backup4
# The codec logic does not work for zero-length database files. A database
# file must contain at least one page in order to be recognized as an
# encrypted database.
do_not_use_codec
#-------------------------------------------------------------------------
# At one point this test was failing because [db] was using an out of
# date schema in test case 1.2.

View File

@@ -17,6 +17,10 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix close
# This module bypasses the "-key" logic in tester.tcl, so it cannot run
# with the codec enabled.
do_not_use_codec
do_execsql_test 1.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('one');

View File

@@ -18,10 +18,9 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#

View File

@@ -18,10 +18,9 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#

View File

@@ -19,10 +19,9 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#

View File

@@ -19,10 +19,9 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#

View File

@@ -18,10 +18,9 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#

View File

@@ -14,10 +14,9 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix corruptG
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#

View File

@@ -14,10 +14,10 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix corruptH
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
database_may_be_corrupt
# The corruption migrations tested by the code in this file are not detected

View File

@@ -19,10 +19,10 @@ if {[permutation]=="mmap"} {
return
}
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
database_may_be_corrupt
# Initialize the database.

View File

@@ -22,10 +22,10 @@ if {[permutation]=="mmap"} {
return
}
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec
# This module uses hard-coded offsets which do not work if the reserved_bytes
# value is nonzero.
if {[nonzero_reserved_bytes]} {finish_test; return;}
database_may_be_corrupt
# Initialize the database.

View File

@@ -25,6 +25,7 @@ ifcapable !crashtest {
finish_test
return
}
do_not_use_codec
do_test crash8-1.1 {
execsql {

View File

@@ -159,35 +159,37 @@ do_test e_vacuum-1.3.1.2 {
execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
} {1024 1}
# EVIDENCE-OF: R-08570-19916 However, when not in write-ahead log mode,
# the page_size and/or auto_vacuum properties of an existing database
# may be changed by using the page_size and/or pragma auto_vacuum
# pragmas and then immediately VACUUMing the database.
#
do_test e_vacuum-1.3.2.1 {
execsql { PRAGMA journal_mode = delete }
execsql { PRAGMA page_size = 2048 }
execsql { PRAGMA auto_vacuum = NONE }
execsql VACUUM
execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
} {2048 0}
# EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the
# auto_vacuum support property can be changed using VACUUM.
#
ifcapable wal {
do_test e_vacuum-1.3.3.1 {
execsql { PRAGMA journal_mode = wal }
execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
} {2048 0}
do_test e_vacuum-1.3.3.2 {
execsql { PRAGMA page_size = 1024 }
execsql { PRAGMA auto_vacuum = FULL }
execsql VACUUM
execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
} {2048 1}
if {![nonzero_reserved_bytes]} {
# EVIDENCE-OF: R-08570-19916 However, when not in write-ahead log mode,
# the page_size and/or auto_vacuum properties of an existing database
# may be changed by using the page_size and/or pragma auto_vacuum
# pragmas and then immediately VACUUMing the database.
#
do_test e_vacuum-1.3.2.1 {
execsql { PRAGMA journal_mode = delete }
execsql { PRAGMA page_size = 2048 }
execsql { PRAGMA auto_vacuum = NONE }
execsql VACUUM
execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
} {2048 0}
# EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the
# auto_vacuum support property can be changed using VACUUM.
#
ifcapable wal {
do_test e_vacuum-1.3.3.1 {
execsql { PRAGMA journal_mode = wal }
execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
} {2048 0}
do_test e_vacuum-1.3.3.2 {
execsql { PRAGMA page_size = 1024 }
execsql { PRAGMA auto_vacuum = FULL }
execsql VACUUM
execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
} {2048 1}
}
}
# EVIDENCE-OF: R-38001-03952 VACUUM only works on the main database. It
# is not possible to VACUUM an attached database file.
forcedelete test.db2

View File

@@ -516,45 +516,47 @@ det 5.13 "SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1" {
}
#-------------------------------------------------------------------------
# The following tests - eqp-6.* - test that the example C code on
# documentation page eqp.html works. The C code is duplicated in test1.c
# and wrapped in Tcl command [print_explain_query_plan]
#
set boilerplate {
proc explain_query_plan {db sql} {
set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY]
print_explain_query_plan $stmt
sqlite3_finalize $stmt
if {![nonzero_reserved_bytes]} {
#-------------------------------------------------------------------------
# The following tests - eqp-6.* - test that the example C code on
# documentation page eqp.html works. The C code is duplicated in test1.c
# and wrapped in Tcl command [print_explain_query_plan]
#
set boilerplate {
proc explain_query_plan {db sql} {
set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY]
print_explain_query_plan $stmt
sqlite3_finalize $stmt
}
sqlite3 db test.db
explain_query_plan db {%SQL%}
db close
exit
}
sqlite3 db test.db
explain_query_plan db {%SQL%}
db close
exit
}
# Do a "Print Explain Query Plan" test.
proc do_peqp_test {tn sql res} {
set fd [open script.tcl w]
puts $fd [string map [list %SQL% $sql] $::boilerplate]
close $fd
uplevel do_test $tn [list {
set fd [open "|[info nameofexec] script.tcl"]
set data [read $fd]
# Do a "Print Explain Query Plan" test.
proc do_peqp_test {tn sql res} {
set fd [open script.tcl w]
puts $fd [string map [list %SQL% $sql] $::boilerplate]
close $fd
set data
}] [list $res]
}
do_peqp_test 6.1 {
SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1
} [string trimleft {
uplevel do_test $tn [list {
set fd [open "|[info nameofexec] script.tcl"]
set data [read $fd]
close $fd
set data
}] [list $res]
}
do_peqp_test 6.1 {
SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1
} [string trimleft {
1 0 0 SCAN TABLE t1 USING COVERING INDEX i2
2 0 0 SCAN TABLE t2
2 0 0 USE TEMP B-TREE FOR ORDER BY
0 0 0 COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)
}]
}
#-------------------------------------------------------------------------
# The following tests - eqp-7.* - test that queries that use the OP_Count

View File

@@ -384,7 +384,7 @@ ifcapable vtab {
ifcapable attach {
do_test incrblob-5.1 {
forcedelete test2.db test2.db-journal
set ::size [expr [file size [info script]]]
set ::size [expr [file size $::cmdlinearg(INFO_SCRIPT)]]
execsql {
ATTACH 'test2.db' AS aux;
CREATE TABLE aux.files(name, text);
@@ -392,16 +392,16 @@ ifcapable attach {
}
set fd [db incrblob aux files text 1]
fconfigure $fd -translation binary
set fd2 [open [info script]]
set fd2 [open $::cmdlinearg(INFO_SCRIPT)]
fconfigure $fd2 -translation binary
puts -nonewline $fd [read $fd2]
close $fd
close $fd2
set ::text [db one {select text from aux.files}]
string length $::text
} [file size [info script]]
} [file size $::cmdlinearg(INFO_SCRIPT)]
do_test incrblob-5.2 {
set fd2 [open [info script]]
set fd2 [open $::cmdlinearg(INFO_SCRIPT)]
fconfigure $fd2 -translation binary
set ::data [read $fd2]
close $fd2
@@ -576,7 +576,7 @@ foreach {tn arg} {1 "" 2 -readonly} {
}
set fd [open [info script]]
set fd [open $::cmdlinearg(INFO_SCRIPT)]
fconfigure $fd -translation binary
set ::data [read $fd 14000]
close $fd

View File

@@ -24,12 +24,12 @@ ifcapable {!incrblob || !memdebug || !tclvar} {
source $testdir/malloc_common.tcl
unset -nocomplain ::fd ::data
set ::fd [open [info script]]
set ::fd [open $::cmdlinearg(INFO_SCRIPT)]
set ::data [read $::fd]
close $::fd
do_malloc_test 1 -tclprep {
set bytes [file size [info script]]
set bytes [file size $::cmdlinearg(INFO_SCRIPT)]
execsql {
CREATE TABLE blobs(k, v BLOB);
INSERT INTO blobs VALUES(1, zeroblob($::bytes));

View File

@@ -374,6 +374,12 @@ proc do_not_use_codec {} {
reset_db
}
# Return true if the "reserved_bytes" integer on database files is non-zero.
#
proc nonzero_reserved_bytes {} {
return [sqlite3 -has-codec]
}
# Print a HELP message and exit
#
proc print_help_and_quit {} {
@@ -521,6 +527,7 @@ if {[info exists cmdlinearg]==0} {
}
set testdir [file normalize $testdir]
set cmdlinearg(TESTFIXTURE_HOME) [pwd]
set cmdlinearg(INFO_SCRIPT) [file normalize [info script]]
set argv0 [file normalize $argv0]
if {$cmdlinearg(testdir)!=""} {
file mkdir $cmdlinearg(testdir)