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 # Register auto-loaders. Still functions do not exist.
48 do_test loadext2-1.3 {
49 sqlite3_auto_extension_sqr
50 sqlite3_auto_extension_cube
54 } {1 {no such function: sqr}}
55 do_test loadext2-1.4 {
59 } {1 {no such function: cube}}
62 # Functions do exist in a new database connection
64 do_test loadext2-1.5 {
70 do_test loadext2-1.6 {
77 # Reset extension auto loading. Existing extensions still exist.
79 do_test loadext2-1.7 {
80 sqlite3_reset_auto_extension
85 do_test loadext2-1.8 {
92 # Register only the sqr() function.
94 do_test loadext2-1.9 {
95 sqlite3_auto_extension_sqr
101 do_test loadext2-1.10 {
105 } {1 {no such function: cube}}
107 # Register only the cube() function.
109 do_test loadext2-1.11 {
110 sqlite3_reset_auto_extension
111 sqlite3_auto_extension_cube
116 } {1 {no such function: sqr}}
117 do_test loadext2-1.12 {
123 # Register a broken entry point.
125 do_test loadext2-1.13 {
126 sqlite3_auto_extension_broken
127 set rc [catch {sqlite3 db test.db} errmsg]
129 } {1 {automatic extension loading failed: broken autoext!}}
130 do_test loadext2-1.14 {
134 } {1 {no such function: sqr}}
135 do_test loadext2-1.15 {
142 sqlite3_reset_auto_extension
143 autoinstall_test_functions