author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
# 2006 August 23 |
sl@0 | 2 |
# |
sl@0 | 3 |
# The author disclaims copyright to this source code. In place of |
sl@0 | 4 |
# a legal notice, here is a blessing: |
sl@0 | 5 |
# |
sl@0 | 6 |
# May you do good and not evil. |
sl@0 | 7 |
# May you find forgiveness for yourself and forgive others. |
sl@0 | 8 |
# May you share freely, never taking more than you give. |
sl@0 | 9 |
# |
sl@0 | 10 |
#*********************************************************************** |
sl@0 | 11 |
# This file implements regression tests for SQLite library. The |
sl@0 | 12 |
# focus of this script is automatic extension loading and the |
sl@0 | 13 |
# sqlite3_auto_extension() API. |
sl@0 | 14 |
# |
sl@0 | 15 |
# $Id: loadext2.test,v 1.3 2008/03/19 16:08:54 drh Exp $ |
sl@0 | 16 |
|
sl@0 | 17 |
set testdir [file dirname $argv0] |
sl@0 | 18 |
source $testdir/tester.tcl |
sl@0 | 19 |
|
sl@0 | 20 |
# Only run these tests if the approriate APIs are defined |
sl@0 | 21 |
# in the system under test. |
sl@0 | 22 |
# |
sl@0 | 23 |
ifcapable !load_ext { |
sl@0 | 24 |
finish_test |
sl@0 | 25 |
return |
sl@0 | 26 |
} |
sl@0 | 27 |
if {[info command sqlite3_auto_extension_sqr]==""} { |
sl@0 | 28 |
finish_test |
sl@0 | 29 |
return |
sl@0 | 30 |
} |
sl@0 | 31 |
|
sl@0 | 32 |
|
sl@0 | 33 |
# None of the extension are loaded by default. |
sl@0 | 34 |
# |
sl@0 | 35 |
do_test loadext2-1.1 { |
sl@0 | 36 |
catchsql { |
sl@0 | 37 |
SELECT sqr(2) |
sl@0 | 38 |
} |
sl@0 | 39 |
} {1 {no such function: sqr}} |
sl@0 | 40 |
do_test loadext2-1.2 { |
sl@0 | 41 |
catchsql { |
sl@0 | 42 |
SELECT cube(2) |
sl@0 | 43 |
} |
sl@0 | 44 |
} {1 {no such function: cube}} |
sl@0 | 45 |
|
sl@0 | 46 |
# Register auto-loaders. Still functions do not exist. |
sl@0 | 47 |
# |
sl@0 | 48 |
do_test loadext2-1.3 { |
sl@0 | 49 |
sqlite3_auto_extension_sqr |
sl@0 | 50 |
sqlite3_auto_extension_cube |
sl@0 | 51 |
catchsql { |
sl@0 | 52 |
SELECT sqr(2) |
sl@0 | 53 |
} |
sl@0 | 54 |
} {1 {no such function: sqr}} |
sl@0 | 55 |
do_test loadext2-1.4 { |
sl@0 | 56 |
catchsql { |
sl@0 | 57 |
SELECT cube(2) |
sl@0 | 58 |
} |
sl@0 | 59 |
} {1 {no such function: cube}} |
sl@0 | 60 |
|
sl@0 | 61 |
|
sl@0 | 62 |
# Functions do exist in a new database connection |
sl@0 | 63 |
# |
sl@0 | 64 |
do_test loadext2-1.5 { |
sl@0 | 65 |
sqlite3 db test.db |
sl@0 | 66 |
catchsql { |
sl@0 | 67 |
SELECT sqr(2) |
sl@0 | 68 |
} |
sl@0 | 69 |
} {0 4.0} |
sl@0 | 70 |
do_test loadext2-1.6 { |
sl@0 | 71 |
catchsql { |
sl@0 | 72 |
SELECT cube(2) |
sl@0 | 73 |
} |
sl@0 | 74 |
} {0 8.0} |
sl@0 | 75 |
|
sl@0 | 76 |
|
sl@0 | 77 |
# Reset extension auto loading. Existing extensions still exist. |
sl@0 | 78 |
# |
sl@0 | 79 |
do_test loadext2-1.7 { |
sl@0 | 80 |
sqlite3_reset_auto_extension |
sl@0 | 81 |
catchsql { |
sl@0 | 82 |
SELECT sqr(2) |
sl@0 | 83 |
} |
sl@0 | 84 |
} {0 4.0} |
sl@0 | 85 |
do_test loadext2-1.8 { |
sl@0 | 86 |
catchsql { |
sl@0 | 87 |
SELECT cube(2) |
sl@0 | 88 |
} |
sl@0 | 89 |
} {0 8.0} |
sl@0 | 90 |
|
sl@0 | 91 |
|
sl@0 | 92 |
# Register only the sqr() function. |
sl@0 | 93 |
# |
sl@0 | 94 |
do_test loadext2-1.9 { |
sl@0 | 95 |
sqlite3_auto_extension_sqr |
sl@0 | 96 |
sqlite3 db test.db |
sl@0 | 97 |
catchsql { |
sl@0 | 98 |
SELECT sqr(2) |
sl@0 | 99 |
} |
sl@0 | 100 |
} {0 4.0} |
sl@0 | 101 |
do_test loadext2-1.10 { |
sl@0 | 102 |
catchsql { |
sl@0 | 103 |
SELECT cube(2) |
sl@0 | 104 |
} |
sl@0 | 105 |
} {1 {no such function: cube}} |
sl@0 | 106 |
|
sl@0 | 107 |
# Register only the cube() function. |
sl@0 | 108 |
# |
sl@0 | 109 |
do_test loadext2-1.11 { |
sl@0 | 110 |
sqlite3_reset_auto_extension |
sl@0 | 111 |
sqlite3_auto_extension_cube |
sl@0 | 112 |
sqlite3 db test.db |
sl@0 | 113 |
catchsql { |
sl@0 | 114 |
SELECT sqr(2) |
sl@0 | 115 |
} |
sl@0 | 116 |
} {1 {no such function: sqr}} |
sl@0 | 117 |
do_test loadext2-1.12 { |
sl@0 | 118 |
catchsql { |
sl@0 | 119 |
SELECT cube(2) |
sl@0 | 120 |
} |
sl@0 | 121 |
} {0 8.0} |
sl@0 | 122 |
|
sl@0 | 123 |
# Register a broken entry point. |
sl@0 | 124 |
# |
sl@0 | 125 |
do_test loadext2-1.13 { |
sl@0 | 126 |
sqlite3_auto_extension_broken |
sl@0 | 127 |
set rc [catch {sqlite3 db test.db} errmsg] |
sl@0 | 128 |
lappend rc $errmsg |
sl@0 | 129 |
} {1 {automatic extension loading failed: broken autoext!}} |
sl@0 | 130 |
do_test loadext2-1.14 { |
sl@0 | 131 |
catchsql { |
sl@0 | 132 |
SELECT sqr(2) |
sl@0 | 133 |
} |
sl@0 | 134 |
} {1 {no such function: sqr}} |
sl@0 | 135 |
do_test loadext2-1.15 { |
sl@0 | 136 |
catchsql { |
sl@0 | 137 |
SELECT cube(2) |
sl@0 | 138 |
} |
sl@0 | 139 |
} {0 8.0} |
sl@0 | 140 |
|
sl@0 | 141 |
|
sl@0 | 142 |
sqlite3_reset_auto_extension |
sl@0 | 143 |
autoinstall_test_functions |
sl@0 | 144 |
finish_test |