gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/zipfilefault.test (about) 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 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 source $testdir/malloc_common.tcl 16 set testprefix zipfilefault 17 18 ifcapable !vtab { 19 finish_test; return 20 } 21 if {[catch {load_static_extension db zipfile} error]} { 22 puts "Skipping zipfile2 tests, hit load error: $error" 23 finish_test; return 24 } 25 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 } 31 } -body { 32 execsql { CREATE VIRTUAL TABLE aaa USING zipfile('test.zip') } 33 } -test { 34 faultsim_test_result {0 {}} 35 } 36 37 forcedelete test.zip 38 sqlite3 db test.db 39 load_static_extension db zipfile 40 do_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 45 do_faultsim_test 2.1 -faults oom* -body { 46 execsql { SELECT name,data FROM zipfile('test.zip') } 47 } -test { 48 faultsim_test_result {0 {a.txt 1234567890}} 49 } 50 ifcapable json1 { 51 do_faultsim_test 2.2 -faults oom* -body { 52 execsql { 53 SELECT json_extract( zipfile_cds(z), '$.version-made-by' ) 54 FROM zipfile('test.zip') 55 } 56 } -test { 57 faultsim_test_result {0 798} 58 } 59 } 60 61 forcedelete test.zip 62 reset_db 63 load_static_extension db zipfile 64 do_execsql_test 3.0 { 65 CREATE VIRTUAL TABLE setup USING zipfile('test.zip'); 66 INSERT INTO setup(name, data) VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); 67 } 68 69 do_faultsim_test 3 -faults oom* -body { 70 execsql { SELECT name,data FROM zipfile('test.zip') } 71 } -test { 72 faultsim_test_result {0 {a.txt aaaaaaaaaaaaaaaaaaaaaaaaaaaa}} 73 } 74 75 do_faultsim_test 4 -faults oom* -body { 76 execsql { 77 WITH c(n, d) AS ( 78 SELECT 1, 'aaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb' 79 ) 80 SELECT name, data FROM zipfile( 81 (SELECT zipfile(n, d) FROM c) 82 ); 83 } 84 } -test { 85 faultsim_test_result {0 {1 aaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb}} 86 } 87 88 reset_db 89 sqlite3_db_config_lookaside db 0 0 0 90 load_static_extension db zipfile 91 92 do_execsql_test 5.0 { 93 CREATE VIRTUAL TABLE setup USING zipfile('test.zip') 94 } 95 96 do_faultsim_test 5.1 -faults oom* -prep { 97 forcedelete test.zip 98 } -body { 99 execsql { 100 INSERT INTO setup(name, data) 101 VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); 102 } 103 } -test { 104 faultsim_test_result {0 {}} 105 } 106 107 do_faultsim_test 5.2 -faults oom* -prep { 108 forcedelete test.zip 109 } -body { 110 execsql { 111 INSERT INTO setup(name, data) VALUES('dir', NULL) 112 } 113 } -test { 114 faultsim_test_result {0 {}} 115 } 116 117 do_faultsim_test 5.3 -faults oom* -prep { 118 forcedelete test.zip 119 execsql { 120 DROP TABLE IF EXISTS setup; 121 BEGIN; 122 CREATE VIRTUAL TABLE setup USING zipfile('test.zip') 123 } 124 } -body { 125 execsql { 126 INSERT INTO setup(name, data) VALUES('dir', NULL) 127 } 128 } -test { 129 catchsql { COMMIT } 130 faultsim_test_result {0 {}} 131 } 132 133 do_faultsim_test 6.1 -faults oom* -body { 134 execsql { 135 WITH c(n, d) AS ( 136 VALUES('a.txt', '1234567890') UNION ALL 137 VALUES('dir', NULL) 138 ) 139 SELECT zipfile(n, d) IS NULL FROM c; 140 } 141 } -test { 142 faultsim_test_result {0 0} 143 } 144 145 set big [string repeat 0123456789 1000] 146 do_faultsim_test 6.2 -faults oom* -body { 147 execsql { 148 WITH c(n, d) AS ( 149 VALUES('a.txt', $big) 150 ) 151 SELECT zipfile(n, NULL, NULL, d, 0) IS NULL FROM c; 152 } 153 } -test { 154 faultsim_test_result {0 0} 155 } 156 157 do_faultsim_test 7.0 -faults oom* -prep { 158 catch { db close } 159 sqlite3 db "" 160 } -body { 161 load_static_extension db zipfile 162 } -test { 163 } 164 165 166 finish_test