omittest.tcl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. # Documentation for this script. This may be output to stderr
  2. # if the script is invoked incorrectly.
  3. set ::USAGE_MESSAGE {
  4. This Tcl script is used to test the various compile time options
  5. available for omitting code (the SQLITE_OMIT_xxx options). It
  6. should be invoked as follows:
  7. <script> ?test-symbol? ?-makefile PATH-TO-MAKEFILE? ?-skip_run?
  8. The default value for ::MAKEFILE is "../Makefile.linux.gcc".
  9. If -skip_run option is given then only the compile part is attempted.
  10. This script builds the testfixture program and runs the SQLite test suite
  11. once with each SQLITE_OMIT_ option defined and then once with all options
  12. defined together. Each run is performed in a seperate directory created
  13. as a sub-directory of the current directory by the script. The output
  14. of the build is saved in <sub-directory>/build.log. The output of the
  15. test-suite is saved in <sub-directory>/test.log.
  16. Almost any SQLite makefile (except those generated by configure - see below)
  17. should work. The following properties are required:
  18. * The makefile should support the "testfixture" target.
  19. * The makefile should support the "test" target.
  20. * The makefile should support the variable "OPTS" as a way to pass
  21. options from the make command line to lemon and the C compiler.
  22. More precisely, the following two invocations must be supported:
  23. $::MAKEBIN -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1"
  24. $::MAKEBIN -f $::MAKEFILE test
  25. Makefiles generated by the sqlite configure program cannot be used as
  26. they do not respect the OPTS variable.
  27. }
  28. # Build a testfixture executable and run quick.test using it. The first
  29. # parameter is the name of the directory to create and use to run the
  30. # test in. The second parameter is a list of OMIT symbols to define
  31. # when doing so. For example:
  32. #
  33. # run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW}
  34. #
  35. #
  36. proc run_quick_test {dir omit_symbol_list} {
  37. # Compile the value of the OPTS Makefile variable.
  38. set opts ""
  39. if {$::tcl_platform(platform)=="windows"} {
  40. append opts "OPTS += -DSQLITE_OS_WIN=1\n"
  41. set target "testfixture.exe"
  42. } else {
  43. append opts "OPTS += -DSQLITE_OS_UNIX=1\n"
  44. }
  45. foreach sym $omit_symbol_list {
  46. append opts "OPTS += -D${sym}=1\n"
  47. }
  48. # Create the directory and do the build. If an error occurs return
  49. # early without attempting to run the test suite.
  50. file mkdir $dir
  51. puts -nonewline "Building $dir..."
  52. flush stdout
  53. catch {
  54. file copy -force ./config.h $dir
  55. file copy -force ./libtool $dir
  56. }
  57. set fd [open $::MAKEFILE]
  58. set mkfile [read $fd]
  59. close $fd
  60. regsub {\ninclude} $mkfile "\n$opts\ninclude" mkfile
  61. set fd [open $dir/makefile w]
  62. puts $fd $mkfile
  63. close $fd
  64. set rc [catch {
  65. exec $::MAKEBIN -C $dir -f makefile clean $::TARGET >& $dir/build.log
  66. }]
  67. if {$rc} {
  68. puts "No good. See $dir/build.log."
  69. return
  70. } else {
  71. puts "Ok"
  72. }
  73. # Create an empty file "$dir/sqlite3". This is to trick the makefile out
  74. # of trying to build the sqlite shell. The sqlite shell won't build
  75. # with some of the OMIT options (i.e OMIT_COMPLETE).
  76. set sqlite3_dummy $dir/sqlite3
  77. if {$::tcl_platform(platform)=="windows"} {
  78. append sqlite3_dummy ".exe"
  79. }
  80. if {![file exists $sqlite3_dummy]} {
  81. set wr [open $sqlite3_dummy w]
  82. puts $wr "dummy"
  83. close $wr
  84. }
  85. if {$::SKIP_RUN} {
  86. # puts "Skip testing $dir."
  87. } else {
  88. # Run the test suite.
  89. puts -nonewline "Testing $dir..."
  90. flush stdout
  91. set rc [catch {
  92. exec $::MAKEBIN -C $dir -f makefile test >& $dir/test.log
  93. }]
  94. if {$rc} {
  95. puts "No good. See $dir/test.log."
  96. } else {
  97. puts "Ok"
  98. }
  99. }
  100. }
  101. # This proc processes the command line options passed to this script.
  102. # Currently the only option supported is "-makefile", default
  103. # "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
  104. # option.
  105. #
  106. proc process_options {argv} {
  107. set ::MAKEBIN make ;# Default value
  108. if {$::tcl_platform(platform)=="windows"} {
  109. set ::MAKEFILE ./Makefile ;# Default value on Windows
  110. } else {
  111. set ::MAKEFILE ./Makefile.linux-gcc ;# Default value
  112. }
  113. set ::SKIP_RUN 1 ;# Default to attempt test
  114. set ::TARGET testfixture ;# Default thing to build
  115. for {set i 0} {$i < [llength $argv]} {incr i} {
  116. switch -regexp -- [lindex $argv $i] {
  117. -{1,2}makefile {
  118. incr i
  119. set ::MAKEFILE [lindex $argv $i]
  120. }
  121. -{1,2}nmake {
  122. set ::MAKEBIN nmake
  123. set ::MAKEFILE ./Makefile.msc
  124. }
  125. -{1,2}target {
  126. incr i
  127. set ::TARGET [lindex $argv $i]
  128. }
  129. -{1,2}skip_run {
  130. set ::SKIP_RUN 1
  131. }
  132. -{1,2}run {
  133. set ::SKIP_RUN 0
  134. }
  135. -{1,2}help {
  136. puts $::USAGE_MESSAGE
  137. exit
  138. }
  139. -.* {
  140. puts stderr "Unknown option: [lindex $argv i]"
  141. puts stderr $::USAGE_MESSAGE
  142. exit 1
  143. }
  144. default {
  145. if {[info exists ::SYMBOL]} {
  146. puts stderr [string trim $::USAGE_MESSAGE]
  147. exit -1
  148. }
  149. set ::SYMBOL [lindex $argv $i]
  150. }
  151. }
  152. set ::MAKEFILE [file normalize $::MAKEFILE]
  153. }
  154. }
  155. # Main routine.
  156. #
  157. proc main {argv} {
  158. # List of SQLITE_OMIT_XXX symbols supported by SQLite.
  159. set ::OMIT_SYMBOLS [list \
  160. SQLITE_OMIT_ALTERTABLE \
  161. SQLITE_OMIT_ANALYZE \
  162. SQLITE_OMIT_ATTACH \
  163. SQLITE_OMIT_AUTHORIZATION \
  164. SQLITE_OMIT_AUTOINCREMENT \
  165. SQLITE_OMIT_AUTOINIT \
  166. SQLITE_OMIT_AUTOMATIC_INDEX \
  167. SQLITE_OMIT_AUTORESET \
  168. SQLITE_OMIT_AUTOVACUUM \
  169. SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS \
  170. SQLITE_OMIT_BETWEEN_OPTIMIZATION \
  171. SQLITE_OMIT_BLOB_LITERAL \
  172. SQLITE_OMIT_CASE_SENSITIVE_LIKE_PRAGMA \
  173. SQLITE_OMIT_CAST \
  174. SQLITE_OMIT_CHECK \
  175. SQLITE_OMIT_COMPILEOPTION_DIAGS \
  176. SQLITE_OMIT_COMPLETE \
  177. SQLITE_OMIT_COMPOUND_SELECT \
  178. SQLITE_OMIT_CONFLICT_CLAUSE \
  179. SQLITE_OMIT_CTE \
  180. SQLITE_OMIT_DATETIME_FUNCS \
  181. SQLITE_OMIT_DECLTYPE \
  182. SQLITE_OMIT_DEPRECATED \
  183. SQLITE_OMIT_DESERIALIZE \
  184. SQLITE_OMIT_DISKIO \
  185. SQLITE_OMIT_EXPLAIN \
  186. SQLITE_OMIT_FLAG_PRAGMAS \
  187. SQLITE_OMIT_FLOATING_POINT \
  188. SQLITE_OMIT_FOREIGN_KEY \
  189. SQLITE_OMIT_GENERATED_COLUMNS \
  190. SQLITE_OMIT_GET_TABLE \
  191. SQLITE_OMIT_HEX_INTEGER \
  192. SQLITE_OMIT_INCRBLOB \
  193. SQLITE_OMIT_INTEGRITY_CHECK \
  194. SQLITE_OMIT_INTROSPECTION_PRAGMAS \
  195. SQLITE_OMIT_JSON \
  196. SQLITE_OMIT_LIKE_OPTIMIZATION \
  197. SQLITE_OMIT_LOAD_EXTENSION \
  198. SQLITE_OMIT_LOCALTIME \
  199. SQLITE_OMIT_LOOKASIDE \
  200. SQLITE_OMIT_MEMORYDB \
  201. SQLITE_OMIT_OR_OPTIMIZATION \
  202. SQLITE_OMIT_PAGER_PRAGMAS \
  203. SQLITE_OMIT_PARSER_TRACE \
  204. SQLITE_OMIT_POPEN \
  205. SQLITE_OMIT_PRAGMA \
  206. SQLITE_OMIT_PROGRESS_CALLBACK \
  207. SQLITE_OMIT_QUICKBALANCE \
  208. SQLITE_OMIT_RANDOMNESS \
  209. SQLITE_OMIT_REINDEX \
  210. SQLITE_OMIT_SCHEMA_PRAGMAS \
  211. SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
  212. SQLITE_OMIT_SHARED_CACHE \
  213. SQLITE_OMIT_SHUTDOWN_DIRECTORIES \
  214. SQLITE_OMIT_SUBQUERY \
  215. SQLITE_OMIT_TCL_VARIABLE \
  216. SQLITE_OMIT_TEMPDB \
  217. SQLITE_OMIT_TEST_CONTROL \
  218. SQLITE_OMIT_TRACE \
  219. SQLITE_OMIT_TRIGGER \
  220. SQLITE_OMIT_TRUNCATE_OPTIMIZATION \
  221. SQLITE_OMIT_TWOSIZE_LOOKASIDE \
  222. SQLITE_OMIT_UPSERT \
  223. SQLITE_OMIT_UTF \
  224. SQLITE_OMIT_VACUUM \
  225. SQLITE_OMIT_VIEW \
  226. SQLITE_OMIT_VIRTUALTABLE \
  227. SQLITE_OMIT_WAL \
  228. SQLITE_OMIT_WINDOWFUNC \
  229. SQLITE_OMIT_WSD \
  230. SQLITE_OMIT_XFER_OPT \
  231. ]
  232. set ::ENABLE_SYMBOLS [list \
  233. SQLITE_ALLOW_ROWID_IN_VIEW \
  234. SQLITE_DISABLE_DIRSYNC \
  235. SQLITE_DISABLE_FTS \
  236. SQLITE_DISABLE_INTRINSIC \
  237. SQLITE_DISABLE_LFS \
  238. SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS \
  239. SQLITE_DISABLE_SKIPAHEAD_DISTINCT \
  240. SQLITE_ENABLE_API_ARMOR \
  241. SQLITE_ENABLE_ATOMIC_WRITE \
  242. SQLITE_ENABLE_BATCH_ATOMIC_WRITE \
  243. SQLITE_ENABLE_BYTECODE_VTAB \
  244. SQLITE_ENABLE_CEROD \
  245. SQLITE_ENABLE_COLUMN_METADATA \
  246. SQLITE_ENABLE_COLUMN_USED_MASK \
  247. SQLITE_ENABLE_COMMENTS \
  248. SQLITE_ENABLE_CORRUPT_PGNO \
  249. SQLITE_ENABLE_COSTMULT \
  250. SQLITE_ENABLE_CURSOR_HINTS \
  251. SQLITE_ENABLE_DBPAGE_VTAB \
  252. SQLITE_ENABLE_DBSTAT_VTAB \
  253. SQLITE_ENABLE_EXPENSIVE_ASSERT \
  254. SQLITE_ENABLE_EXPLAIN_COMMENTS \
  255. SQLITE_ENABLE_FTS \
  256. SQLITE_ENABLE_GEOPOLY \
  257. SQLITE_ENABLE_HIDDEN_COLUMNS \
  258. SQLITE_ENABLE_ICU \
  259. SQLITE_ENABLE_ICU_COLLATIONS \
  260. SQLITE_ENABLE_INTERNAL_FUNCTIONS \
  261. SQLITE_ENABLE_IOTRACE \
  262. SQLITE_ENABLE_LOAD_EXTENSION \
  263. SQLITE_ENABLE_LOCKING_STYLE \
  264. SQLITE_ENABLE_MATH_FUNCTIONS \
  265. SQLITE_ENABLE_MEMORY_MANAGEMENT \
  266. SQLITE_ENABLE_MEMSYS \
  267. SQLITE_ENABLE_MODULE_COMMENTS \
  268. SQLITE_ENABLE_MULTIPLEX \
  269. SQLITE_ENABLE_MULTITHREADED_CHECKS \
  270. SQLITE_ENABLE_NORMALIZE \
  271. SQLITE_ENABLE_NULL_TRIM \
  272. SQLITE_ENABLE_OFFSET_SQL_FUNC \
  273. SQLITE_ENABLE_OVERSIZE_CELL_CHECK \
  274. SQLITE_ENABLE_PREUPDATE_HOOK \
  275. SQLITE_ENABLE_QPSG \
  276. SQLITE_ENABLE_RBU \
  277. SQLITE_ENABLE_RTREE \
  278. SQLITE_ENABLE_SELECTTRACE \
  279. SQLITE_ENABLE_SESSION \
  280. SQLITE_ENABLE_SETLK_TIMEOUT \
  281. SQLITE_ENABLE_SNAPSHOT \
  282. SQLITE_ENABLE_SORTER_MMAP\
  283. SQLITE_ENABLE_SORTER_REFERENCE \
  284. SQLITE_ENABLE_SORTER_REFERENCES \
  285. SQLITE_ENABLE_SQLLOG\
  286. SQLITE_ENABLE_STAT \
  287. SQLITE_ENABLE_STMT_SCANSTATUS \
  288. SQLITE_ENABLE_STMTVTAB \
  289. SQLITE_ENABLE_TREETRACE \
  290. SQLITE_ENABLE_UNKNOWN_FUNCTION \
  291. SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION \
  292. SQLITE_ENABLE_UNLOCK_NOTIFY \
  293. SQLITE_ENABLE_UPDATE_DELETE_LIMIT \
  294. SQLITE_ENABLE_URI_00_ERROR \
  295. SQLITE_ENABLE_VFSTRACE \
  296. SQLITE_ENABLE_WHERETRACE \
  297. SQLITE_ENABLE_ZIPVFS \
  298. ]
  299. # Process any command line options.
  300. process_options $argv
  301. if {[info exists ::SYMBOL] } {
  302. set sym $::SYMBOL
  303. if {[lsearch $::OMIT_SYMBOLS $sym]<0 && [lsearch $::ENABLE_SYMBOLS $sym]<0} {
  304. puts stderr "No such symbol: $sym"
  305. exit -1
  306. }
  307. set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
  308. run_quick_test $dirname $sym
  309. } else {
  310. # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
  311. # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
  312. # and the latter is currently incompatible with the test suite (this should
  313. # be fixed, but it will be a lot of work).
  314. set allsyms [list]
  315. foreach s $::OMIT_SYMBOLS {
  316. if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
  317. lappend allsyms $s
  318. }
  319. }
  320. run_quick_test test_OMIT_EVERYTHING $allsyms
  321. # Now try one quick.test with each of the OMIT symbols defined. Included
  322. # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
  323. # know they will fail. It's good to be reminded of this from time to time.
  324. foreach sym $::OMIT_SYMBOLS {
  325. set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
  326. run_quick_test $dirname $sym
  327. }
  328. # Try the ENABLE/DISABLE symbols one at a time.
  329. # We don't do them all at once since some are conflicting.
  330. foreach sym $::ENABLE_SYMBOLS {
  331. set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
  332. run_quick_test $dirname $sym
  333. }
  334. }
  335. }
  336. main $argv