Create initial tests for appendvfs, and make it available as a statically loaded extension.

FossilOrigin-Name: 9f33d45179f5985bd4c4f7582e94f5833a63f853c8cdc19f39cf7e3ee70177d0
This commit is contained in:
larrybr 2021-03-06 23:36:47 +00:00
parent 1f8f131a8b
commit 1b22ad8ae6
6 changed files with 91 additions and 10 deletions

View File

@ -440,6 +440,7 @@ TESTSRC += \
$(TOP)/ext/expert/sqlite3expert.c \
$(TOP)/ext/expert/test_expert.c \
$(TOP)/ext/misc/amatch.c \
$(TOP)/ext/misc/appendvfs.c \
$(TOP)/ext/misc/carray.c \
$(TOP)/ext/misc/cksumvfs.c \
$(TOP)/ext/misc/closure.c \

View File

@ -361,6 +361,7 @@ TESTSRC = \
TESTSRC += \
$(TOP)/ext/misc/amatch.c \
$(TOP)/ext/misc/carray.c \
$(TOP)/ext/misc/appendvfs.c \
$(TOP)/ext/misc/cksumvfs.c \
$(TOP)/ext/misc/closure.c \
$(TOP)/ext/misc/csv.c \

View File

@ -1,9 +1,9 @@
C Merge\slast\sday\sof\strunk\schanges,\sreverify\sbuild.
D 2021-03-05T20:52:19.916
C Create\sinitial\stests\sfor\sappendvfs,\sand\smake\sit\savailable\sas\sa\sstatically\sloaded\sextension.
D 2021-03-06T23:36:47.524
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F Makefile.in 047036a560b7db51e7b7e459cd12cbe80e10ca5420b0ea5ddda023b44ab46466
F Makefile.in fe6cc1db11e02b308f3ab0ec2504344697b9eaaa410fa73f48d16a143462e5d3
F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241
F Makefile.msc ad07bbd645132533e1fd7164a03acfa9afecda378b3787c10f62ab4c7c45e6ea
F README.md 1514a365ffca3c138e00c5cc839906108a01011a6b082bad19b09781e3aa498a
@ -464,7 +464,7 @@ F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
F main.mk 32765eed1aa69739a876b7e1632a092188106f99e8ad6c9d30ea982f4f9b3a46
F main.mk 2c2a5c91eefeacc400a3e19018250fa8d9d236b49395e8e15bf0045ebdb71510
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@ -552,7 +552,7 @@ F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a3
F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F src/tclsqlite.c 986b6391f02cd9b53c1d688be55899f6ffddeb8e8014cd83c1b73ff912579a71
F src/test1.c 07f60dfe9574720268abf97757b1d62894e959e3db4a530e4988367be06c5f14
F src/test1.c cff43d8e21be543b77651b4d2caf49bd6488fee220f8540ecd9f71d13169dbd1
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644
F src/test4.c 7c4420e01c577b5c4add2cb03119743b1a357543d347773b9e717195ea967159
@ -699,6 +699,7 @@ F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf
F test/autoindex5.test a5d72fe8c217cc0ea356dc6fa06a282a8a3fc53aa807709d79dba07a8f248102
F test/autovacuum.test 0831cd34e14695d297187f7f6519265e3121c5b0a1720e548e86829e796129e9
F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4
F test/avfs.test 810ecf3b0ad344e917ea6bcfb599a1ac5aa6913b6eefe57f2c72c1414fa6cf24
F test/avtrans.test b7dc25459ecbd86c6fa9c606ee3068f59d81e225118617dcf2bbb6ded2ade89e
F test/backcompat.test 3e64cedda754c778ef6bbe417b6e7a295e662a4d
F test/backup.test dd4a5ff756e3df3931dacb1791db0584d4bad989
@ -1909,7 +1910,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 7f0f2eacdb496f7f36865ba62164a48edb324a3c6baede736b4e7edf5e8b0fdb 83dab8b358b6832a221a58e74dd5e99b9cdea4eee65124bb6799881e867d989c
R 261d589d0844d523eb8c45af3f152dcc
P 1d67ed1c98a6bc49cce6bdc156bd6f22b3f37d33226bd62430a43aa5318f5781
R 0eeba06122e9adb743a0f3263a3e03e9
U larrybr
Z fdae5c4e59947cb56e8a88d5f84b7f6e
Z 120f7ec5fcb8ab1d7c797ea6341bc2db

View File

@ -1 +1 @@
1d67ed1c98a6bc49cce6bdc156bd6f22b3f37d33226bd62430a43aa5318f5781
9f33d45179f5985bd4c4f7582e94f5833a63f853c8cdc19f39cf7e3ee70177d0

View File

@ -7494,6 +7494,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
Tcl_Obj *CONST objv[]
){
extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_appendvfs_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_carray_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_csv_init(sqlite3*,char**,const sqlite3_api_routines*);
@ -7523,6 +7524,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*);
} aExtension[] = {
{ "amatch", sqlite3_amatch_init },
{ "appendvfs", sqlite3_appendvfs_init },
{ "carray", sqlite3_carray_init },
{ "closure", sqlite3_closure_init },
{ "csv", sqlite3_csv_init },
@ -7571,7 +7573,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
}else{
rc = SQLITE_OK;
}
if( rc!=SQLITE_OK || zErrMsg ){
if( (rc!=SQLITE_OK && rc!=SQLITE_OK_LOAD_PERMANENTLY) || zErrMsg ){
Tcl_AppendResult(interp, "initialization of ", zName, " failed: ", zErrMsg,
(char*)0);
sqlite3_free(zErrMsg);

76
test/avfs.test Normal file
View File

@ -0,0 +1,76 @@
# 2021-03-06
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# 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 tests for the appendvfs extension.
#
# Tests performed:
# avfs-1. Test that an appendvfs DB can be added to a simple text file.
# avfs-2. Test that the DB can be read with correct content upon reopen.
# avfs-3. Test that the simple text file retains its initial text.
# ...
# (more to come)
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix avfs
load_static_extension db appendvfs
set ::fa file1.adb
set ::result {}
do_test 1.0 {
set results {}
forcedelete $::fa
set out [open $::fa wb]
set ::tlo { "Just some text," "and more text," "ending at 3 lines." }
puts $out [join $::tlo "\n"]
close $out
set adbSz [file size $::fa]
sqlite3 adb "file:$::fa?mode=rwc&vfs=apndvfs" -uri 1
adb eval {
PRAGMA page_size=512;
CREATE TABLE t1(a TEXT);
INSERT INTO t1 VALUES ('dog'),('cat');
SELECT group_concat(a) as pets FROM t1;
} { lappend results $pets }
adb close
set adaSz [file size $::fa]
lappend results "Bytes before/after $adbSz/$adaSz"
set ::result [join $results " | "]
} {dog,cat | Bytes before/after 50/5145}
do_test 2.0 {
set results {}
sqlite3 adb "file:$::fa?mode=rw&vfs=apndvfs" -uri 1
adb eval {
SELECT group_concat(a) as pets FROM t1;
} { lappend results $pets }
adb close
set ::result [join $results " | "]
} {dog,cat}
do_test 3.0 {
set in [open $::fa r]
set tli [list [gets $in] [gets $in] [gets $in]]
close $in
if { [join $tli ":"] ne [join $::tlo ":"] } {
set ::result "Appendee changed."
} else {
set ::result "Appendee intact."
}
} {Appendee intact.}
unset ::fa ::tlo ::result
# forcedelete $::fa
finish_test