Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/sqlite/src/test/loadext.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2006 July 14 1 # 2006 July 14
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this script is extension loading. 12 # focus of this script is extension loading.
13 # 13 #
14 # $Id: loadext.test,v 1.17 2009/03/20 09:09:37 danielk1977 Exp $ 14 # $Id: loadext.test,v 1.17 2009/03/20 09:09:37 danielk1977 Exp $
15 15
16 set testdir [file dirname $argv0] 16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl 17 source $testdir/tester.tcl
18 18
19 ifcapable !load_ext { 19 ifcapable !load_ext {
20 finish_test 20 finish_test
21 return 21 return
22 } 22 }
23 23
24 # The name of the test extension varies by operating system. 24 # The name of the test extension varies by operating system.
25 # 25 #
26 if {$::tcl_platform(platform) eq "windows" || $::tcl_platform(platform) eq "os2" } { 26 if {$::tcl_platform(platform) eq "windows"} {
27 set testextension ./testloadext.dll 27 set testextension ./testloadext.dll
28 } else { 28 } else {
29 set testextension ./libtestloadext.so 29 set testextension ./libtestloadext.so
30 } 30 }
31 set gcc_shared "-shared -fPIC" 31 set gcc_shared "-shared -fPIC"
32 if {$::tcl_platform(os) eq "Darwin"} { 32 if {$::tcl_platform(os) eq "Darwin"} {
33 set gcc_shared -dynamiclib 33 set gcc_shared -dynamiclib
34 } 34 }
35 35
36 # The error messages tested by this file are operating system dependent 36 # The error messages tested by this file are operating system dependent
(...skipping 22 matching lines...) Expand all
59 {%s: cannot open shared object file: No such file or directory} 59 {%s: cannot open shared object file: No such file or directory}
60 set dlerror_notadll {%s: file too short} 60 set dlerror_notadll {%s: file too short}
61 set dlerror_nosymbol {%s: undefined symbol: %s} 61 set dlerror_nosymbol {%s: undefined symbol: %s}
62 62
63 if {$::tcl_platform(os) eq "Darwin"} { 63 if {$::tcl_platform(os) eq "Darwin"} {
64 set dlerror_nosuchfile {dlopen(%s, 10): image not found} 64 set dlerror_nosuchfile {dlopen(%s, 10): image not found}
65 set dlerror_notadll {dlopen(%1$s, 10): no suitable image found.*} 65 set dlerror_notadll {dlopen(%1$s, 10): no suitable image found.*}
66 set dlerror_nosymbol {dlsym(XXX, %2$s): symbol not found} 66 set dlerror_nosymbol {dlsym(XXX, %2$s): symbol not found}
67 } 67 }
68 68
69 if {$::tcl_platform(platform) eq "windows"} {
70 set dlerror_nosuchfile {The specified module could not be found.*}
71 set dlerror_notadll {%%1 is not a valid Win32 application.*}
72 set dlerror_nosymbol {The specified procedure could not be found.*}
73 }
74
69 # Make sure the test extension actually exists. If it does not 75 # Make sure the test extension actually exists. If it does not
70 # exist, try to create it. If unable to create it, then skip this 76 # exist, try to create it. If unable to create it, then skip this
71 # test file. 77 # test file.
72 # 78 #
73 if {![file exists $testextension]} { 79 if {![file exists $testextension]} {
74 set srcdir [file dir $testdir]/src 80 set srcdir [file dir $testdir]/src
75 set testextsrc $srcdir/test_loadext.c 81 set testextsrc $srcdir/test_loadext.c
76 82
77 set cmdline [concat exec gcc $gcc_shared] 83 set cmdline [concat exec gcc $gcc_shared]
78 lappend cmdline -Wall -I$srcdir -I. -g $testextsrc -o $testextension 84 lappend cmdline -Wall -I$srcdir -I. -g $testextsrc -o $testextension
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } db2 133 } db2
128 } {0 0.5} 134 } {0 0.5}
129 135
130 db2 close 136 db2 close
131 sqlite3 db test.db 137 sqlite3 db test.db
132 sqlite3_enable_load_extension db 1 138 sqlite3_enable_load_extension db 1
133 139
134 # Try to load an extension for which the file does not exist. 140 # Try to load an extension for which the file does not exist.
135 # 141 #
136 do_test loadext-2.1 { 142 do_test loadext-2.1 {
137 file delete -force ${testextension}xx 143 forcedelete ${testextension}xx
138 set rc [catch { 144 set rc [catch {
139 sqlite3_load_extension db "${testextension}xx" 145 sqlite3_load_extension db "${testextension}xx"
140 } msg] 146 } msg]
141 list $rc $msg 147 list $rc $msg
142 } [list 1 [format $dlerror_nosuchfile ${testextension}xx]] 148 } /[list 1 [format $dlerror_nosuchfile ${testextension}xx.*]]/
143 149
144 # Try to load an extension for which the file is not a shared object 150 # Try to load an extension for which the file is not a shared object
145 # 151 #
146 do_test loadext-2.2 { 152 do_test loadext-2.2 {
147 set fd [open "${testextension}xx" w] 153 set fd [open "./notasharedlib.so" w]
154 puts $fd blah
155 close $fd
156 set fd [open "./notasharedlib.dll" w]
148 puts $fd blah 157 puts $fd blah
149 close $fd 158 close $fd
150 set rc [catch { 159 set rc [catch {
151 sqlite3_load_extension db "${testextension}xx" 160 sqlite3_load_extension db "./notasharedlib"
152 } msg] 161 } msg]
153 set expected_error_pattern [format $dlerror_notadll ${testextension}xx] 162 list $rc $msg
154 list $rc [string match $expected_error_pattern $msg] 163 } /[list 1 [format $dlerror_notadll ./notasharedlib.*]]/
155 } [list 1 1]
156 164
157 # Try to load an extension for which the file is present but the 165 # Try to load an extension for which the file is present but the
158 # entry point is not. 166 # entry point is not.
159 # 167 #
160 do_test loadext-2.3 { 168 do_test loadext-2.3 {
161 set rc [catch { 169 set rc [catch {
162 sqlite3_load_extension db $testextension icecream 170 sqlite3_load_extension db $testextension icecream
163 } msg] 171 } msg]
164 if {$::tcl_platform(os) eq "Darwin"} { 172 if {$::tcl_platform(os) eq "Darwin"} {
165 regsub {0x[1234567890abcdefABCDEF]*} $msg XXX msg 173 regsub {0x[1234567890abcdefABCDEF]*} $msg XXX msg
166 } 174 }
167 list $rc $msg 175 list $rc $msg
168 } [list 1 [format $dlerror_nosymbol $testextension icecream]] 176 } /[list 1 [format $dlerror_nosymbol $testextension icecream]]/
169 177
170 # Try to load an extension for which the entry point fails (returns non-zero) 178 # Try to load an extension for which the entry point fails (returns non-zero)
171 # 179 #
172 do_test loadext-2.4 { 180 do_test loadext-2.4 {
173 set rc [catch { 181 set rc [catch {
174 sqlite3_load_extension db $testextension testbrokenext_init 182 sqlite3_load_extension db $testextension testbrokenext_init
175 } msg] 183 } msg]
176 list $rc $msg 184 list $rc $msg
177 } {1 {error during initialization: broken!}} 185 } {1 {error during initialization: broken!}}
178 186
(...skipping 10 matching lines...) Expand all
189 } 197 }
190 } {1 {no such function: half}} 198 } {1 {no such function: half}}
191 do_test loadext-3.2 { 199 do_test loadext-3.2 {
192 set res [catchsql { 200 set res [catchsql {
193 SELECT load_extension($::testextension) 201 SELECT load_extension($::testextension)
194 }] 202 }]
195 if {$::tcl_platform(os) eq "Darwin"} { 203 if {$::tcl_platform(os) eq "Darwin"} {
196 regsub {0x[1234567890abcdefABCDEF]*} $res XXX res 204 regsub {0x[1234567890abcdefABCDEF]*} $res XXX res
197 } 205 }
198 set res 206 set res
199 } [list 1 [format $dlerror_nosymbol $testextension sqlite3_extension_init]] 207 } /[list 1 [format $dlerror_nosymbol $testextension sqlite3_.*_init]]/
200 do_test loadext-3.3 { 208 do_test loadext-3.3 {
201 catchsql { 209 catchsql {
202 SELECT load_extension($::testextension,'testloadext_init') 210 SELECT load_extension($::testextension,'testloadext_init')
203 } 211 }
204 } {0 {{}}} 212 } {0 {{}}}
205 do_test loadext-3.4 { 213 do_test loadext-3.4 {
206 catchsql { 214 catchsql {
207 SELECT half(5); 215 SELECT half(5);
208 } 216 }
209 } {0 2.5} 217 } {0 2.5}
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 source $testdir/malloc_common.tcl 266 source $testdir/malloc_common.tcl
259 267
260 268
261 # Malloc failure in sqlite3_auto_extension and sqlite3_load_extension 269 # Malloc failure in sqlite3_auto_extension and sqlite3_load_extension
262 # 270 #
263 do_malloc_test loadext-5 -tclprep { 271 do_malloc_test loadext-5 -tclprep {
264 sqlite3_reset_auto_extension 272 sqlite3_reset_auto_extension
265 } -tclbody { 273 } -tclbody {
266 if {[autoinstall_test_functions]==7} {error "out of memory"} 274 if {[autoinstall_test_functions]==7} {error "out of memory"}
267 } 275 }
268 do_malloc_test loadext-6 -tclbody { 276
269 db enable_load_extension 1 277 # On Windows, this malloc test must be skipped because the winDlOpen
270 sqlite3_load_extension db $::testextension testloadext_init 278 # function itself can fail due to "out of memory" conditions.
279 #
280 if {$::tcl_platform(platform) ne "windows"} {
281 do_malloc_test loadext-6 -tclbody {
282 db enable_load_extension 1
283 sqlite3_load_extension db $::testextension testloadext_init
284 }
271 } 285 }
286
272 autoinstall_test_functions 287 autoinstall_test_functions
273 288
274 finish_test 289 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698