omittest.tcl 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. set rcsid {$Id: omittest.tcl,v 1.8 2008/10/13 15:35:09 drh Exp $}
  2. # Documentation for this script. This may be output to stderr
  3. # if the script is invoked incorrectly.
  4. set ::USAGE_MESSAGE {
  5. This Tcl script is used to test the various compile time options
  6. available for omitting code (the SQLITE_OMIT_xxx options). It
  7. should be invoked as follows:
  8. <script> ?test-symbol? ?-makefile PATH-TO-MAKEFILE? ?-skip_run?
  9. The default value for ::MAKEFILE is "../Makefile.linux.gcc".
  10. If -skip_run option is given then only the compile part is attempted.
  11. This script builds the testfixture program and runs the SQLite test suite
  12. once with each SQLITE_OMIT_ option defined and then once with all options
  13. defined together. Each run is performed in a seperate directory created
  14. as a sub-directory of the current directory by the script. The output
  15. of the build is saved in <sub-directory>/build.log. The output of the
  16. test-suite is saved in <sub-directory>/test.log.
  17. Almost any SQLite makefile (except those generated by configure - see below)
  18. should work. The following properties are required:
  19. * The makefile should support the "testfixture" target.
  20. * The makefile should support the "test" target.
  21. * The makefile should support the variable "OPTS" as a way to pass
  22. options from the make command line to lemon and the C compiler.
  23. More precisely, the following two invocations must be supported:
  24. $::MAKEBIN -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1"
  25. $::MAKEBIN -f $::MAKEFILE test
  26. Makefiles generated by the sqlite configure program cannot be used as
  27. they do not respect the OPTS variable.
  28. }
  29. # Build a testfixture executable and run quick.test using it. The first
  30. # parameter is the name of the directory to create and use to run the
  31. # test in. The second parameter is a list of OMIT symbols to define
  32. # when doing so. For example:
  33. #
  34. # run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW}
  35. #
  36. #
  37. proc run_quick_test {dir omit_symbol_list} {
  38. # Compile the value of the OPTS Makefile variable.
  39. set opts ""
  40. if {$::tcl_platform(platform)=="windows"} {
  41. append opts "OPTS += -DSQLITE_OS_WIN=1\n"
  42. set target "testfixture.exe"
  43. } else {
  44. append opts "OPTS += -DSQLITE_OS_UNIX=1\n"
  45. }
  46. foreach sym $omit_symbol_list {
  47. append opts "OPTS += -D${sym}=1\n"
  48. }
  49. # Create the directory and do the build. If an error occurs return
  50. # early without attempting to run the test suite.
  51. file mkdir $dir
  52. puts -nonewline "Building $dir..."
  53. flush stdout
  54. catch {
  55. file copy -force ./config.h $dir
  56. file copy -force ./libtool $dir
  57. }
  58. set fd [open $::MAKEFILE]
  59. set mkfile [read $fd]
  60. close $fd
  61. regsub {\ninclude} $mkfile "\n$opts\ninclude" mkfile
  62. set fd [open $dir/makefile w]
  63. puts $fd $mkfile
  64. close $fd
  65. set rc [catch {
  66. exec $::MAKEBIN -C $dir -f makefile clean $::TARGET >& $dir/build.log
  67. }]
  68. if {$rc} {
  69. puts "No good. See $dir/build.log."
  70. return
  71. } else {
  72. puts "Ok"
  73. }
  74. # Create an empty file "$dir/sqlite3". This is to trick the makefile out
  75. # of trying to build the sqlite shell. The sqlite shell won't build
  76. # with some of the OMIT options (i.e OMIT_COMPLETE).
  77. set sqlite3_dummy $dir/sqlite3
  78. if {$::tcl_platform(platform)=="windows"} {
  79. append sqlite3_dummy ".exe"
  80. }
  81. if {![file exists $sqlite3_dummy]} {
  82. set wr [open $sqlite3_dummy w]
  83. puts $wr "dummy"
  84. close $wr
  85. }
  86. if {$::SKIP_RUN} {
  87. puts "Skip testing $dir."
  88. } else {
  89. # Run the test suite.
  90. puts -nonewline "Testing $dir..."
  91. flush stdout
  92. set rc [catch {
  93. exec $::MAKEBIN -C $dir -f makefile test >& $dir/test.log
  94. }]
  95. if {$rc} {
  96. puts "No good. See $dir/test.log."
  97. } else {
  98. puts "Ok"
  99. }
  100. }
  101. }
  102. # This proc processes the command line options passed to this script.
  103. # Currently the only option supported is "-makefile", default
  104. # "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
  105. # option.
  106. #
  107. proc process_options {argv} {
  108. set ::MAKEBIN make ;# Default value
  109. if {$::tcl_platform(platform)=="windows"} {
  110. set ::MAKEFILE ./Makefile ;# Default value on Windows
  111. } else {
  112. set ::MAKEFILE ./Makefile.linux-gcc ;# Default value
  113. }
  114. set ::SKIP_RUN 0 ;# Default to attempt test
  115. set ::TARGET testfixture ;# Default thing to build
  116. for {set i 0} {$i < [llength $argv]} {incr i} {
  117. switch -- [lindex $argv $i] {
  118. -makefile {
  119. incr i
  120. set ::MAKEFILE [lindex $argv $i]
  121. }
  122. -nmake {
  123. set ::MAKEBIN nmake
  124. set ::MAKEFILE ./Makefile.msc
  125. }
  126. -target {
  127. incr i
  128. set ::TARGET [lindex $argv $i]
  129. }
  130. -skip_run {
  131. set ::SKIP_RUN 1
  132. }
  133. default {
  134. if {[info exists ::SYMBOL]} {
  135. puts stderr [string trim $::USAGE_MESSAGE]
  136. exit -1
  137. }
  138. set ::SYMBOL [lindex $argv $i]
  139. }
  140. }
  141. set ::MAKEFILE [file normalize $::MAKEFILE]
  142. }
  143. }
  144. # Main routine.
  145. #
  146. proc main {argv} {
  147. # List of SQLITE_OMIT_XXX symbols supported by SQLite.
  148. set ::OMIT_SYMBOLS [list \
  149. SQLITE_OMIT_ALTERTABLE \
  150. SQLITE_OMIT_ANALYZE \
  151. SQLITE_OMIT_ATTACH \
  152. SQLITE_OMIT_AUTHORIZATION \
  153. SQLITE_OMIT_AUTOINCREMENT \
  154. SQLITE_OMIT_AUTOINIT \
  155. SQLITE_OMIT_AUTOMATIC_INDEX \
  156. SQLITE_OMIT_AUTORESET \
  157. SQLITE_OMIT_AUTOVACUUM \
  158. SQLITE_OMIT_BETWEEN_OPTIMIZATION \
  159. SQLITE_OMIT_BLOB_LITERAL \
  160. SQLITE_OMIT_BTREECOUNT \
  161. SQLITE_OMIT_BUILTIN_TEST \
  162. SQLITE_OMIT_CAST \
  163. SQLITE_OMIT_CHECK \
  164. SQLITE_OMIT_COMPILEOPTION_DIAGS \
  165. SQLITE_OMIT_COMPLETE \
  166. SQLITE_OMIT_COMPOUND_SELECT \
  167. SQLITE_OMIT_DATETIME_FUNCS \
  168. SQLITE_OMIT_DECLTYPE \
  169. SQLITE_OMIT_DEPRECATED \
  170. SQLITE_OMIT_EXPLAIN \
  171. SQLITE_OMIT_FLAG_PRAGMAS \
  172. SQLITE_OMIT_FLOATING_POINT \
  173. SQLITE_OMIT_FOREIGN_KEY \
  174. SQLITE_OMIT_GET_TABLE \
  175. SQLITE_OMIT_INCRBLOB \
  176. SQLITE_OMIT_INTEGRITY_CHECK \
  177. SQLITE_OMIT_LIKE_OPTIMIZATION \
  178. SQLITE_OMIT_LOAD_EXTENSION \
  179. SQLITE_OMIT_LOCALTIME \
  180. SQLITE_OMIT_LOOKASIDE \
  181. SQLITE_OMIT_MEMORYDB \
  182. SQLITE_OMIT_OR_OPTIMIZATION \
  183. SQLITE_OMIT_PAGER_PRAGMAS \
  184. SQLITE_OMIT_PRAGMA \
  185. SQLITE_OMIT_PROGRESS_CALLBACK \
  186. SQLITE_OMIT_QUICKBALANCE \
  187. SQLITE_OMIT_REINDEX \
  188. SQLITE_OMIT_SCHEMA_PRAGMAS \
  189. SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
  190. SQLITE_OMIT_SHARED_CACHE \
  191. SQLITE_OMIT_SUBQUERY \
  192. SQLITE_OMIT_TCL_VARIABLE \
  193. SQLITE_OMIT_TEMPDB \
  194. SQLITE_OMIT_TRACE \
  195. SQLITE_OMIT_TRIGGER \
  196. SQLITE_OMIT_TRUNCATE_OPTIMIZATION \
  197. SQLITE_OMIT_UNIQUE_ENFORCEMENT \
  198. SQLITE_OMIT_UTF16 \
  199. SQLITE_OMIT_VACUUM \
  200. SQLITE_OMIT_VIEW \
  201. SQLITE_OMIT_VIRTUALTABLE \
  202. SQLITE_OMIT_WAL \
  203. SQLITE_OMIT_WSD \
  204. SQLITE_OMIT_XFER_OPT \
  205. ]
  206. set ::ENABLE_SYMBOLS [list \
  207. SQLITE_DISABLE_DIRSYNC \
  208. SQLITE_DISABLE_LFS \
  209. SQLITE_ENABLE_ATOMIC_WRITE \
  210. SQLITE_ENABLE_COLUMN_METADATA \
  211. SQLITE_ENABLE_EXPENSIVE_ASSERT \
  212. SQLITE_ENABLE_FTS3 \
  213. SQLITE_ENABLE_FTS3_PARENTHESIS \
  214. SQLITE_ENABLE_FTS4 \
  215. SQLITE_ENABLE_IOTRACE \
  216. SQLITE_ENABLE_LOAD_EXTENSION \
  217. SQLITE_ENABLE_LOCKING_STYLE \
  218. SQLITE_ENABLE_MEMORY_MANAGEMENT \
  219. SQLITE_ENABLE_MEMSYS3 \
  220. SQLITE_ENABLE_MEMSYS5 \
  221. SQLITE_ENABLE_OVERSIZE_CELL_CHECK \
  222. SQLITE_ENABLE_RTREE \
  223. SQLITE_ENABLE_STAT3 \
  224. SQLITE_ENABLE_UNLOCK_NOTIFY \
  225. SQLITE_ENABLE_UPDATE_DELETE_LIMIT \
  226. ]
  227. # Process any command line options.
  228. process_options $argv
  229. if {[info exists ::SYMBOL] } {
  230. set sym $::SYMBOL
  231. if {[lsearch $::OMIT_SYMBOLS $sym]<0 && [lsearch $::ENABLE_SYMBOLS $sym]<0} {
  232. puts stderr "No such symbol: $sym"
  233. exit -1
  234. }
  235. set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
  236. run_quick_test $dirname $sym
  237. } else {
  238. # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
  239. # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
  240. # and the latter is currently incompatible with the test suite (this should
  241. # be fixed, but it will be a lot of work).
  242. set allsyms [list]
  243. foreach s $::OMIT_SYMBOLS {
  244. if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
  245. lappend allsyms $s
  246. }
  247. }
  248. run_quick_test test_OMIT_EVERYTHING $allsyms
  249. # Now try one quick.test with each of the OMIT symbols defined. Included
  250. # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
  251. # know they will fail. It's good to be reminded of this from time to time.
  252. foreach sym $::OMIT_SYMBOLS {
  253. set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
  254. run_quick_test $dirname $sym
  255. }
  256. # Try the ENABLE/DISABLE symbols one at a time.
  257. # We don't do them all at once since some are conflicting.
  258. foreach sym $::ENABLE_SYMBOLS {
  259. set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
  260. run_quick_test $dirname $sym
  261. }
  262. }
  263. }
  264. main $argv