xref: /sqlite-3.40.0/test/zipfilefault.test (revision 2f7260de)
1# 2018 January 30
2#
3# The author disclaims copyright to this source code.  In place of
4# a legal notice, here is a blessing:
5#
6#    May you do good and not evil.
7#    May you find forgiveness for yourself and forgive others.
8#    May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15source $testdir/malloc_common.tcl
16set testprefix zipfilefault
17
18ifcapable !vtab {
19  finish_test; return
20}
21if {[catch {load_static_extension db zipfile} error]} {
22  puts "Skipping zipfile2 tests, hit load error: $error"
23  finish_test; return
24}
25
26faultsim_save_and_close
27do_faultsim_test 1 -prep {
28  faultsim_restore_and_reopen
29  load_static_extension db zipfile
30  execsql { DROP TABLE IF EXISTS aaa }
31} -body {
32  execsql { CREATE VIRTUAL TABLE aaa USING zipfile('test.zip') }
33} -test {
34  faultsim_test_result {0 {}}
35}
36
37forcedelete test.zip
38sqlite3 db test.db
39load_static_extension db zipfile
40do_execsql_test 2.0 {
41  CREATE VIRTUAL TABLE setup USING zipfile('test.zip');
42  INSERT INTO setup(name, data) VALUES('a.txt', '1234567890');
43}
44
45do_faultsim_test 2 -faults oom* -body {
46  execsql { SELECT name,data FROM zipfile('test.zip') }
47} -test {
48  faultsim_test_result {0 {a.txt 1234567890}}
49}
50
51forcedelete test.zip
52reset_db
53load_static_extension db zipfile
54do_execsql_test 3.0 {
55  CREATE VIRTUAL TABLE setup USING zipfile('test.zip');
56  INSERT INTO setup(name, data) VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
57}
58
59do_faultsim_test 2 -faults oom* -body {
60  execsql { SELECT name,data FROM zipfile('test.zip') }
61} -test {
62  faultsim_test_result {0 {a.txt aaaaaaaaaaaaaaaaaaaaaaaaaaaa}}
63}
64
65
66finish_test
67
68