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 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script is automatic extension loading and the
13 # sqlite3_auto_extension() API.
15 # $Id: loadext2.test,v 1.3 2008/03/19 16:08:54 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 # Only run these tests if the approriate APIs are defined
21 # in the system under test.
27 if {[info command sqlite3_auto_extension_sqr]==""} {
33 # None of the extension are loaded by default.
35 do_test loadext2-1.1 {
39 } {1 {no such function: sqr}}
40 do_test loadext2-1.2 {
44 } {1 {no such function: cube}}
46 # Extensions loaders not currently registered
48 do_test loadext2-1.2.1 {
49 sqlite3_cancel_auto_extension_sqr
51 do_test loadext2-1.2.2 {
52 sqlite3_cancel_auto_extension_sqr
54 do_test loadext2-1.2.3 {
55 sqlite3_cancel_auto_extension_sqr
59 # Register auto-loaders. Still functions do not exist.
61 do_test loadext2-1.3 {
62 sqlite3_auto_extension_sqr
63 sqlite3_auto_extension_cube
67 } {1 {no such function: sqr}}
68 do_test loadext2-1.4 {
72 } {1 {no such function: cube}}
75 # Functions do exist in a new database connection
77 do_test loadext2-1.5 {
83 do_test loadext2-1.6 {
90 # Reset extension auto loading. Existing extensions still exist.
92 do_test loadext2-1.7.1 {
93 sqlite3_cancel_auto_extension_sqr
95 do_test loadext2-1.7.2 {
96 sqlite3_cancel_auto_extension_sqr
98 do_test loadext2-1.7.3 {
99 sqlite3_cancel_auto_extension_cube
101 do_test loadext2-1.7.4 {
102 sqlite3_cancel_auto_extension_cube
104 do_test loadext2-1.7.5 {
109 do_test loadext2-1.8 {
116 # Register only the sqr() function.
118 do_test loadext2-1.9 {
119 sqlite3_auto_extension_sqr
125 do_test loadext2-1.10 {
129 } {1 {no such function: cube}}
131 # Register only the cube() function.
133 do_test loadext2-1.11 {
134 sqlite3_reset_auto_extension
135 sqlite3_auto_extension_cube
140 } {1 {no such function: sqr}}
141 do_test loadext2-1.12 {
147 # Register a broken entry point.
149 do_test loadext2-1.13 {
150 sqlite3_auto_extension_broken
151 set rc [catch {sqlite3 db test.db} errmsg]
153 } {1 {automatic extension loading failed: broken autoext!}}
154 do_test loadext2-1.14 {
158 } {1 {no such function: sqr}}
159 do_test loadext2-1.15 {
166 sqlite3_reset_auto_extension
167 autoinstall_test_functions