15daa6b53e
within the same transaction. And add other zipfile test. FossilOrigin-Name: 48f1c556994d7f8f359c649a1da81eec02306106b68946a9a20b276742c4610d
133 lines
3.0 KiB
Plaintext
133 lines
3.0 KiB
Plaintext
# 2018 January 30
|
|
#
|
|
# 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.
|
|
#
|
|
#***********************************************************************
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
source $testdir/malloc_common.tcl
|
|
set testprefix zipfilefault
|
|
|
|
ifcapable !vtab {
|
|
finish_test; return
|
|
}
|
|
if {[catch {load_static_extension db zipfile} error]} {
|
|
puts "Skipping zipfile2 tests, hit load error: $error"
|
|
finish_test; return
|
|
}
|
|
|
|
faultsim_save_and_close
|
|
do_faultsim_test 1 -prep {
|
|
faultsim_restore_and_reopen
|
|
load_static_extension db zipfile
|
|
execsql { DROP TABLE IF EXISTS aaa }
|
|
} -body {
|
|
execsql { CREATE VIRTUAL TABLE aaa USING zipfile('test.zip') }
|
|
} -test {
|
|
faultsim_test_result {0 {}}
|
|
}
|
|
|
|
forcedelete test.zip
|
|
sqlite3 db test.db
|
|
load_static_extension db zipfile
|
|
do_execsql_test 2.0 {
|
|
CREATE VIRTUAL TABLE setup USING zipfile('test.zip');
|
|
INSERT INTO setup(name, data) VALUES('a.txt', '1234567890');
|
|
}
|
|
|
|
do_faultsim_test 2.1 -faults oom* -body {
|
|
execsql { SELECT name,data FROM zipfile('test.zip') }
|
|
} -test {
|
|
faultsim_test_result {0 {a.txt 1234567890}}
|
|
}
|
|
do_faultsim_test 2.2 -faults oom* -body {
|
|
execsql {
|
|
SELECT json_extract( zipfile_cds(z), '$.version-made-by' )
|
|
FROM zipfile('test.zip')
|
|
}
|
|
} -test {
|
|
faultsim_test_result {0 798}
|
|
}
|
|
|
|
forcedelete test.zip
|
|
reset_db
|
|
load_static_extension db zipfile
|
|
do_execsql_test 3.0 {
|
|
CREATE VIRTUAL TABLE setup USING zipfile('test.zip');
|
|
INSERT INTO setup(name, data) VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
|
}
|
|
|
|
do_faultsim_test 3 -faults oom* -body {
|
|
execsql { SELECT name,data FROM zipfile('test.zip') }
|
|
} -test {
|
|
faultsim_test_result {0 {a.txt aaaaaaaaaaaaaaaaaaaaaaaaaaaa}}
|
|
}
|
|
|
|
do_faultsim_test 4 -faults oom* -body {
|
|
execsql {
|
|
WITH c(n, d) AS (
|
|
SELECT 1, 'aaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb'
|
|
)
|
|
SELECT name, data FROM zipfile(
|
|
(SELECT zipfile(n, d) FROM c)
|
|
);
|
|
}
|
|
} -test {
|
|
faultsim_test_result {0 {1 aaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb}}
|
|
}
|
|
|
|
reset_db
|
|
load_static_extension db zipfile
|
|
|
|
do_execsql_test 5.0 {
|
|
CREATE VIRTUAL TABLE setup USING zipfile('test.zip')
|
|
}
|
|
|
|
do_faultsim_test 5.1 -faults oom* -prep {
|
|
forcedelete test.zip
|
|
} -body {
|
|
execsql {
|
|
INSERT INTO setup(name, data)
|
|
VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
|
}
|
|
} -test {
|
|
faultsim_test_result {0 {}}
|
|
}
|
|
|
|
do_faultsim_test 5.2 -faults oom* -prep {
|
|
forcedelete test.zip
|
|
} -body {
|
|
execsql {
|
|
INSERT INTO setup(name, data) VALUES('dir', NULL)
|
|
}
|
|
} -test {
|
|
faultsim_test_result {0 {}}
|
|
}
|
|
|
|
do_faultsim_test 5.3 -faults oom* -prep {
|
|
forcedelete test.zip
|
|
execsql {
|
|
DROP TABLE IF EXISTS setup;
|
|
BEGIN;
|
|
CREATE VIRTUAL TABLE setup USING zipfile('test.zip')
|
|
}
|
|
} -body {
|
|
execsql {
|
|
INSERT INTO setup(name, data) VALUES('dir', NULL)
|
|
}
|
|
} -test {
|
|
catchsql { COMMIT }
|
|
faultsim_test_result {0 {}}
|
|
}
|
|
|
|
|
|
finish_test
|
|
|