3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 source $testdir/malloc_common.tcl
16 set testprefix zipfilefault
21 if {[catch {load_static_extension db zipfile} error]} {
22 puts "Skipping zipfile2 tests, hit load error: $error"
26 faultsim_save_and_close
27 do_faultsim_test 1 -prep {
28 faultsim_restore_and_reopen
29 load_static_extension db zipfile
30 execsql { DROP TABLE IF EXISTS aaa }
32 execsql { CREATE VIRTUAL TABLE aaa USING zipfile('test.zip') }
34 faultsim_test_result {0 {}}
39 load_static_extension db zipfile
41 CREATE VIRTUAL TABLE setup USING zipfile('test.zip');
42 INSERT INTO setup(name, data) VALUES('a.txt', '1234567890');
45 do_faultsim_test 2.1 -faults oom* -body {
46 execsql { SELECT name,data FROM zipfile('test.zip') }
48 faultsim_test_result {0 {a.txt 1234567890}}
51 do_faultsim_test 2.2 -faults oom* -body {
53 SELECT json_extract( zipfile_cds(z), '$.version-made-by' )
54 FROM zipfile('test.zip')
57 faultsim_test_result {0 798}
63 load_static_extension db zipfile
65 CREATE VIRTUAL TABLE setup USING zipfile('test.zip');
66 INSERT INTO setup(name, data) VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
69 do_faultsim_test 3 -faults oom* -body {
70 execsql { SELECT name,data FROM zipfile('test.zip') }
72 faultsim_test_result {0 {a.txt aaaaaaaaaaaaaaaaaaaaaaaaaaaa}}
75 do_faultsim_test 4 -faults oom* -body {
78 SELECT 1, 'aaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb'
80 SELECT name, data FROM zipfile(
81 (SELECT zipfile(n, d) FROM c)
85 faultsim_test_result {0 {1 aaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb}}
89 sqlite3_db_config_lookaside db 0 0 0
90 load_static_extension db zipfile
93 CREATE VIRTUAL TABLE setup USING zipfile('test.zip')
96 do_faultsim_test 5.1 -faults oom* -prep {
100 INSERT INTO setup(name, data)
101 VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
104 faultsim_test_result {0 {}}
107 do_faultsim_test 5.2 -faults oom* -prep {
111 INSERT INTO setup(name, data) VALUES('dir', NULL)
114 faultsim_test_result {0 {}}
117 do_faultsim_test 5.3 -faults oom* -prep {
120 DROP TABLE IF EXISTS setup;
122 CREATE VIRTUAL TABLE setup USING zipfile('test.zip')
126 INSERT INTO setup(name, data) VALUES('dir', NULL)
130 faultsim_test_result {0 {}}
133 do_faultsim_test 6.1 -faults oom* -body {
136 VALUES('a.txt', '1234567890') UNION ALL
139 SELECT zipfile(n, d) IS NULL FROM c;
142 faultsim_test_result {0 0}
145 set big [string repeat 0123456789 1000]
146 do_faultsim_test 6.2 -faults oom* -body {
149 VALUES('a.txt', $big)
151 SELECT zipfile(n, NULL, NULL, d, 0) IS NULL FROM c;
154 faultsim_test_result {0 0}
157 do_faultsim_test 7.0 -faults oom* -prep {
161 load_static_extension db zipfile