Add test cases for the fileio extension.

FossilOrigin-Name: 8634333127c4d868d3ec27e88b5818f6479774f3
This commit is contained in:
drh 2014-06-16 12:44:32 +00:00
parent 40e75cb6f6
commit 51ed298364
7 changed files with 91 additions and 10 deletions

View File

@ -393,6 +393,7 @@ TESTSRC = \
TESTSRC += \
$(TOP)/ext/misc/amatch.c \
$(TOP)/ext/misc/closure.c \
$(TOP)/ext/misc/fileio.c \
$(TOP)/ext/misc/fuzzer.c \
$(TOP)/ext/misc/ieee754.c \
$(TOP)/ext/misc/nextchar.c \

View File

@ -862,6 +862,7 @@ TESTSRC = \
TESTEXT = \
$(TOP)\ext\misc\amatch.c \
$(TOP)\ext\misc\closure.c \
$(TOP)\ext\misc\fileio.c \
$(TOP)\ext\misc\fuzzer.c \
$(TOP)\ext\misc\ieee754.c \
$(TOP)\ext\misc\nextchar.c \

View File

@ -277,6 +277,7 @@ TESTSRC = \
TESTSRC += \
$(TOP)/ext/misc/amatch.c \
$(TOP)/ext/misc/closure.c \
$(TOP)/ext/misc/fileio.c \
$(TOP)/ext/misc/fuzzer.c \
$(TOP)/ext/misc/ieee754.c \
$(TOP)/ext/misc/nextchar.c \

View File

@ -1,9 +1,9 @@
C Add\sthe\sfileio.c\sloadable\sextension,\sthat\simplements\sreadfile()\sand\swritefile()\nSQL\sfunctions.
D 2014-06-13T13:43:25.488
C Add\stest\scases\sfor\sthe\sfileio\sextension.
D 2014-06-16T12:44:32.986
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in dd2b1aba364ff9b05de41086f74407f285c57670
F Makefile.in ed5e4aae4799f724699d5509fac2977786414dbb
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F Makefile.msc 52911c6bfeaf9b40f47ef4615ab66d98ab0f2b3d
F Makefile.msc b5ff082a24cd1e0694a0001891e13e3b56c8ef31
F Makefile.vxworks 034289efa9d591b04b1a73598623119c306cbba0
F README.md 64f270c43c38c46de749e419c22f0ae2f4499fe8
F VERSION 9f823c026c6a32fc5f84d212a8aae0a221dba45c
@ -146,7 +146,7 @@ F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt f439556c5ce01ced70987e5ee86549a45165d9ff
F main.mk cfa185eed4e0f7e9d28a2e3167cecaa9d6cb39f3
F main.mk 0cb97ec3285474651736053ee741145ef8c5185f
F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea
F mkopcodeh.awk c6b3fa301db6ef7ac916b14c60868aeaec1337b5
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
@ -232,7 +232,7 @@ F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c e87c99e28a145943666b51b212dacae35fcea0bd
F src/test1.c 4edf8810c86d77ae7ac6d56d563965a9beeea2ce
F src/test1.c 3c8bc491d2f8de5adbbf306533cefc343c733927
F src/test2.c 98049e51a17dc62606a99a9eb95ee477f9996712
F src/test3.c 1c0e5d6f080b8e33c1ce8b3078e7013fdbcd560c
F src/test4.c 9b32d22f5f150abe23c1830e2057c4037c45b3df
@ -466,6 +466,7 @@ F test/exclusive2.test 32798111aae78a5deec980eee383213f189df308
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
F test/exists.test 8f7b27b61c2fbe5822f0a1f899c715d14e416e30
F test/expr.test 67c9fd6f8f829e239dc8b0f4a08a73c08b09196d
F test/extension01.test 06b3c61d9c87e262b2a3b61abc080be5b29e1eb4
F test/fallocate.test 3e979af17dfa7e5e9dda5eba1a696c04fa9d47f7
F test/filectrl.test 14fa712e42c4cb791e09dfd58a6a03efb47ef13a
F test/filefmt.test cb34663f126cbc2d358af552dcaf5c72769b0146
@ -1176,7 +1177,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P d5c17d1a423321f766616d82c9b27ef87c1d5afd
R 1805f6a0ae3bbffdcfbcff54f7b6c6b0
P 0ca104d821d5841ab0754113be074c520cf07f23
R ccaa3e1a4ad97ab90dbd1c64a76fa424
U drh
Z 904e0ffbd1a81754412e5093211c823c
Z a84943f6024adba9b7ed1466702addbc

View File

@ -1 +1 @@
0ca104d821d5841ab0754113be074c520cf07f23
8634333127c4d868d3ec27e88b5818f6479774f3

View File

@ -6281,6 +6281,7 @@ static int tclLoadStaticExtensionCmd(
){
extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*);
@ -6295,6 +6296,7 @@ static int tclLoadStaticExtensionCmd(
} aExtension[] = {
{ "amatch", sqlite3_amatch_init },
{ "closure", sqlite3_closure_init },
{ "fileio", sqlite3_fileio_init },
{ "fuzzer", sqlite3_fuzzer_init },
{ "ieee754", sqlite3_ieee_init },
{ "nextchar", sqlite3_nextchar_init },

75
test/extension01.test Normal file
View File

@ -0,0 +1,75 @@
# 2014-06-16
#
# 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 various small extensions.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix extension01
load_static_extension db fileio
do_test 1.0 {
forcedelete file1.txt
set out [open ./file1.txt wb]
puts -nonewline $out "This is a text file without a line ending"
close $out
db eval {
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
INSERT INTO t1 VALUES(1, readfile('./file1.txt'));
SELECT * FROM t1;
}
} {1 {This is a text file without a line ending}}
do_test 1.1 {
forcedelete file2.txt
db nullvalue nil
db eval {
DELETE FROM t1;
INSERT INTO t1 VALUES(2, readfile(NULL)),(3, readfile('file2.txt'));
SELECT a, b, typeof(b) FROM t1;
}
} {2 nil null 3 nil null}
do_test 1.2 {
db eval {
SELECT writefile('./file2.txt', 'A second test line');
}
} {18}
do_test 1.3 {
set in [open ./file2.txt rb]
set x [read $in]
close $in
list $x [file size file2.txt]
} {{A second test line} 18}
do_test 1.4 {
db eval {
SELECT writefile('./file2.txt', NULL);
}
} {0}
do_test 1.5 {
file size ./file2.txt
} {0}
do_test 1.6 {
file attributes ./file2.txt -permissions r--r--r--
db eval {
SELECT writefile('./file2.txt', 'Another test');
}
} {nil}
do_test 1.7 {
file attributes ./file2.txt -permissions rw-r--r--
db eval {
SELECT writefile(NULL, 'Another test');
}
} {nil}
finish_test