aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/tool/omittest.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/tool/omittest.tcl')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/tool/omittest.tcl176
1 files changed, 176 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/tool/omittest.tcl b/libraries/sqlite/unix/sqlite-3.5.1/tool/omittest.tcl
new file mode 100644
index 0000000..9fcbfdb
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/tool/omittest.tcl
@@ -0,0 +1,176 @@
1
2set rcsid {$Id: omittest.tcl,v 1.3 2007/09/14 16:20:01 danielk1977 Exp $}
3
4# Documentation for this script. This may be output to stderr
5# if the script is invoked incorrectly.
6set ::USAGE_MESSAGE {
7This Tcl script is used to test the various compile time options
8available for omitting code (the SQLITE_OMIT_xxx options). It
9should be invoked as follows:
10
11 <script> ?-makefile PATH-TO-MAKEFILE?
12
13The default value for ::MAKEFILE is "../Makefile.linux.gcc".
14
15This script builds the testfixture program and runs the SQLite test suite
16once with each SQLITE_OMIT_ option defined and then once with all options
17defined together. Each run is performed in a seperate directory created
18as a sub-directory of the current directory by the script. The output
19of the build is saved in <sub-directory>/build.log. The output of the
20test-suite is saved in <sub-directory>/test.log.
21
22Almost any SQLite makefile (except those generated by configure - see below)
23should work. The following properties are required:
24
25 * The makefile should support the "testfixture" target.
26 * The makefile should support the "test" target.
27 * The makefile should support the variable "OPTS" as a way to pass
28 options from the make command line to lemon and the C compiler.
29
30More precisely, the following two invocations must be supported:
31
32 make -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1"
33 make -f $::MAKEFILE test
34
35Makefiles generated by the sqlite configure program cannot be used as
36they do not respect the OPTS variable.
37}
38
39
40# Build a testfixture executable and run quick.test using it. The first
41# parameter is the name of the directory to create and use to run the
42# test in. The second parameter is a list of OMIT symbols to define
43# when doing so. For example:
44#
45# run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW}
46#
47#
48proc run_quick_test {dir omit_symbol_list} {
49 # Compile the value of the OPTS Makefile variable.
50 set opts "-DSQLITE_MEMDEBUG=2 -DSQLITE_DEBUG -DOS_UNIX"
51 foreach sym $omit_symbol_list {
52 append opts " -D${sym}=1"
53 }
54
55 # Create the directory and do the build. If an error occurs return
56 # early without attempting to run the test suite.
57 file mkdir $dir
58 puts -nonewline "Building $dir..."
59 flush stdout
60 set rc [catch {
61 exec make -C $dir -f $::MAKEFILE testfixture OPTS=$opts >& $dir/build.log
62 }]
63 if {$rc} {
64 puts "No good. See $dir/build.log."
65 return
66 } else {
67 puts "Ok"
68 }
69
70 # Create an empty file "$dir/sqlite3". This is to trick the makefile out
71 # of trying to build the sqlite shell. The sqlite shell won't build
72 # with some of the OMIT options (i.e OMIT_COMPLETE).
73 if {![file exists $dir/sqlite3]} {
74 set wr [open $dir/sqlite3 w]
75 puts $wr "dummy"
76 close $wr
77 }
78
79 # Run the test suite.
80 puts -nonewline "Testing $dir..."
81 flush stdout
82 set rc [catch {
83 exec make -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log
84 }]
85 if {$rc} {
86 puts "No good. See $dir/test.log."
87 } else {
88 puts "Ok"
89 }
90}
91
92
93# This proc processes the command line options passed to this script.
94# Currently the only option supported is "-makefile", default
95# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
96# option.
97#
98proc process_options {argv} {
99 set ::MAKEFILE ../Makefile.linux-gcc ;# Default value
100 for {set i 0} {$i < [llength $argv]} {incr i} {
101 switch -- [lindex $argv $i] {
102 -makefile {
103 incr i
104 set ::MAKEFILE [lindex $argv $i]
105 }
106
107 default {
108 puts stderr [string trim $::USAGE_MESSAGE]
109 exit -1
110 }
111 }
112 set ::MAKEFILE [file normalize $::MAKEFILE]
113 }
114}
115
116# Main routine.
117#
118
119proc main {argv} {
120 # List of SQLITE_OMIT_XXX symbols supported by SQLite.
121 set ::SYMBOLS [list \
122 SQLITE_OMIT_ALTERTABLE \
123 SQLITE_OMIT_AUTHORIZATION \
124 SQLITE_OMIT_AUTOINCREMENT \
125 SQLITE_OMIT_AUTOVACUUM \
126 SQLITE_OMIT_BLOB_LITERAL \
127 SQLITE_OMIT_COMPLETE \
128 SQLITE_OMIT_COMPOUND_SELECT \
129 SQLITE_OMIT_CONFLICT_CLAUSE \
130 SQLITE_OMIT_DATETIME_FUNCS \
131 SQLITE_OMIT_EXPLAIN \
132 SQLITE_OMIT_FLOATING_POINT \
133 SQLITE_OMIT_FOREIGN_KEY \
134 SQLITE_OMIT_INCRBLOB \
135 SQLITE_OMIT_INTEGRITY_CHECK \
136 SQLITE_OMIT_MEMORYDB \
137 SQLITE_OMIT_PAGER_PRAGMAS \
138 SQLITE_OMIT_PRAGMA \
139 SQLITE_OMIT_PROGRESS_CALLBACK \
140 SQLITE_OMIT_REINDEX \
141 SQLITE_OMIT_SCHEMA_PRAGMAS \
142 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
143 SQLITE_OMIT_SUBQUERY \
144 SQLITE_OMIT_TCL_VARIABLE \
145 SQLITE_OMIT_TRIGGER \
146 SQLITE_OMIT_UTF16 \
147 SQLITE_OMIT_VACUUM \
148 SQLITE_OMIT_VIEW \
149 SQLITE_OMIT_VIRTUALTABLE \
150 ]
151
152 # Process any command line options.
153 process_options $argv
154
155 # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
156 # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
157 # and the latter is currently incompatible with the test suite (this should
158 # be fixed, but it will be a lot of work).
159 set allsyms [list]
160 foreach s $::SYMBOLS {
161 if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
162 lappend allsyms $s
163 }
164 }
165 run_quick_test test_OMIT_EVERYTHING $allsyms
166
167 # Now try one quick.test with each of the OMIT symbols defined. Included
168 # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
169 # know they will fail. It's good to be reminded of this from time to time.
170 foreach sym $::SYMBOLS {
171 set dirname "test_[string range $sym 7 end]"
172 run_quick_test $dirname $sym
173 }
174}
175
176main $argv