mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Add tests for too-tiny appended DBs, clarify align macro.
FossilOrigin-Name: eb40a8dea6afe6890ddda989de83f3d4ae03b112bf78bfc818dfbd57cc5b5b2a
This commit is contained in:
@ -12,16 +12,19 @@
|
||||
# This file implements tests for the appendvfs extension.
|
||||
#
|
||||
# Tests performed:
|
||||
# avfs-1.0. Test that an appendvfs DB can be added to an empty file.
|
||||
# avfs-1.0. Test that an appendvfs DB can be added to an empty (ZLF) file.
|
||||
# avfs-1.1. Test that the DB can be read with correct content upon reopen.
|
||||
# avfs-1.2. Test that an appendvfs DB can be added to a simple text file.
|
||||
# avfs-1.3. Test that the DB can be read with correct content upon reopen.
|
||||
# avfs-1.4. Test that appended DB is aligned to default page boundary.
|
||||
# avfs-2.1. Test that the simple text file retains its initial text.
|
||||
# avfs-3.1. Test that the appendvfs can grow and shrink, remaining intact.
|
||||
# avfs-3.2. Test that appendvfs is intact after grow/shrink/close/reopen.
|
||||
# avfs-4.1. Test shell's ability to append to a non-appendvfs file.
|
||||
# avfs-4.2. Test shell's ability to append to empty or nonexistent file.
|
||||
# avfs-4.3. Test shell's ability to reopen and alter an appendvfs file.
|
||||
# avfs-5.1. Test appendvfs refusal to open too-tiny DB appended onto ZLF.
|
||||
# avfs-5.2. Test appendvfs refusal to open too-tiny DB appended on other.
|
||||
# ...
|
||||
# (more to come)
|
||||
|
||||
@ -115,9 +118,12 @@ do_test 1.3 {
|
||||
SELECT group_concat(a) as pets FROM (SELECT a FROM t1 ORDER BY a DESC);
|
||||
} { lappend results $pets }
|
||||
adb close
|
||||
lappend results [fosAvfs $fa]
|
||||
set ::result [join $results " | "]
|
||||
} {pig,dog,cat | 4096}
|
||||
} {pig,dog,cat}
|
||||
|
||||
do_test 1.4 {
|
||||
set ::result [fosAvfs $fa]
|
||||
} {4096}
|
||||
|
||||
do_test 2.1 {
|
||||
set in [open $::fa r]
|
||||
@ -248,6 +254,46 @@ do_test 4.3 {
|
||||
set ::result [join $res " | "]
|
||||
} {0 | 1 | 1}
|
||||
|
||||
do_test 5.1 {
|
||||
set fake "faketiny.sdb"
|
||||
forcedelete $fake
|
||||
set ofd [open $fake wb]
|
||||
puts -nonewline $ofd "SQLite format 3"
|
||||
puts -nonewline $ofd [binary format "c" 0]
|
||||
puts -nonewline $ofd "Start-Of-SQLite3-"
|
||||
puts -nonewline $ofd [binary format "W" 0]
|
||||
close $ofd
|
||||
if {[catch {sqlite3 adb "file:$fake?mode=rw$::vf" -uri 1}]} {
|
||||
set res "Open failed."
|
||||
} else {
|
||||
adb close
|
||||
set res "Opened when should not."
|
||||
}
|
||||
forcedelete $fake
|
||||
set ::result $res
|
||||
} {Open failed.}
|
||||
|
||||
do_test 5.2 {
|
||||
set fake "faketiny.sdb"
|
||||
forcedelete $fake
|
||||
set ofd [open $fake wb]
|
||||
set fakeAppendee "Dog ate my homework.\n"
|
||||
puts -nonewline $ofd $fakeAppendee
|
||||
puts -nonewline $ofd "SQLite format 3"
|
||||
puts -nonewline $ofd [binary format "c" 0]
|
||||
puts -nonewline $ofd "Start-Of-SQLite3-"
|
||||
puts -nonewline $ofd [binary format "W" [string length $fakeAppendee]]
|
||||
close $ofd
|
||||
if {[catch {sqlite3 adb "file:$fake?mode=rw$::vf" -uri 1}]} {
|
||||
set res "Open failed."
|
||||
} else {
|
||||
adb close
|
||||
set res "Opened when should not."
|
||||
}
|
||||
forcedelete $fake
|
||||
set ::result $res
|
||||
} {Open failed.}
|
||||
|
||||
forcedelete $::fa $::fza
|
||||
|
||||
unset -nocomplain ::fa ::fza ::tlo ::result ::randints
|
||||
|
Reference in New Issue
Block a user