releasetest.tcl 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. set rcsid {$Id: $}
  2. # Documentation for this script. This may be output to stderr
  3. # if the script is invoked incorrectly. See the [process_options]
  4. # proc below.
  5. #
  6. set ::USAGE_MESSAGE {
  7. This Tcl script is used to test the various configurations required
  8. before releasing a new version. Supported command line options (all
  9. optional) are:
  10. -makefile PATH-TO-MAKEFILE (default "releasetest.mk")
  11. -platform PLATFORM (see below)
  12. -quick BOOLEAN (default "0")
  13. The default value for -makefile is "./releasetest.mk".
  14. The script determines the default value for -platform using the
  15. $tcl_platform(os) and $tcl_platform(machine) variables. Supported
  16. platforms are "Linux-x86", "Linux-x86_64" and "Darwin-i386".
  17. If the -quick option is set to true, then the "veryquick.test" script
  18. is run for all compilation configurations. Otherwise, sometimes "all.test"
  19. is run, sometimes "veryquick.test".
  20. Almost any SQLite makefile (except those generated by configure - see below)
  21. should work. The following properties are required:
  22. * The makefile should support the "fulltest" target.
  23. * The makefile should support the variable "OPTS" as a way to pass
  24. options from the make command line to lemon and the C compiler.
  25. More precisely, the following invocation must be supported:
  26. make -f $::MAKEFILE fulltest OPTS="-DSQLITE_SECURE_DELETE=1 -DSQLITE_DEBUG=1"
  27. Makefiles generated by the sqlite configure program cannot be used as
  28. they do not respect the OPTS variable.
  29. Example Makefile contents:
  30. ########################################################
  31. TOP=/home/dan/work/sqlite/sqlite
  32. TCL_FLAGS=-I/home/dan/tcl/include
  33. LIBTCL=-L/home/dan/tcl/lib -ltcl
  34. BCC = gcc
  35. TCC = gcc -ansi -g $(CFLAGS)
  36. NAWK = awk
  37. AR = ar cr
  38. RANLIB = ranlib
  39. THREADLIB = -lpthread -ldl
  40. include $(TOP)/main.mk
  41. ########################################################
  42. }
  43. array set ::Configs {
  44. "Default" {
  45. -O2
  46. }
  47. "Ftrapv" {
  48. -O2 -ftrapv
  49. -DSQLITE_MAX_ATTACHED=55
  50. -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
  51. }
  52. "Unlock-Notify" {
  53. -O2
  54. -DSQLITE_ENABLE_UNLOCK_NOTIFY
  55. -DSQLITE_THREADSAFE
  56. -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
  57. }
  58. "Secure-Delete" {
  59. -O2
  60. -DSQLITE_SECURE_DELETE=1
  61. -DSQLITE_SOUNDEX=1
  62. }
  63. "Update-Delete-Limit" {
  64. -O2
  65. -DSQLITE_DEFAULT_FILE_FORMAT=4
  66. -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
  67. }
  68. "Check-Symbols" {
  69. -DSQLITE_MEMDEBUG=1
  70. -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
  71. -DSQLITE_ENABLE_FTS3=1
  72. -DSQLITE_ENABLE_RTREE=1
  73. -DSQLITE_ENABLE_MEMSYS5=1
  74. -DSQLITE_ENABLE_MEMSYS3=1
  75. -DSQLITE_ENABLE_COLUMN_METADATA=1
  76. -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
  77. -DSQLITE_SECURE_DELETE=1
  78. -DSQLITE_SOUNDEX=1
  79. -DSQLITE_ENABLE_ATOMIC_WRITE=1
  80. -DSQLITE_ENABLE_IOTRACE=1
  81. -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
  82. -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
  83. }
  84. "Debug-One" {
  85. -O2
  86. -DSQLITE_DEBUG=1
  87. -DSQLITE_MEMDEBUG=1
  88. -DSQLITE_MUTEX_NOOP=1
  89. -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
  90. -DSQLITE_ENABLE_FTS3=1
  91. -DSQLITE_ENABLE_RTREE=1
  92. -DSQLITE_ENABLE_MEMSYS5=1
  93. -DSQLITE_ENABLE_MEMSYS3=1
  94. -DSQLITE_ENABLE_COLUMN_METADATA=1
  95. }
  96. "Device-One" {
  97. -O2
  98. -DSQLITE_DEBUG=1
  99. -DSQLITE_DEFAULT_AUTOVACUUM=1
  100. -DSQLITE_DEFAULT_CACHE_SIZE=64
  101. -DSQLITE_DEFAULT_PAGE_SIZE=1024
  102. -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32
  103. -DSQLITE_DISABLE_LFS=1
  104. -DSQLITE_ENABLE_ATOMIC_WRITE=1
  105. -DSQLITE_ENABLE_IOTRACE=1
  106. -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
  107. -DSQLITE_MAX_PAGE_SIZE=4096
  108. -DSQLITE_OMIT_LOAD_EXTENSION=1
  109. -DSQLITE_OMIT_PROGRESS_CALLBACK=1
  110. -DSQLITE_OMIT_VIRTUALTABLE=1
  111. -DSQLITE_TEMP_STORE=3
  112. }
  113. "Device-Two" {
  114. -DSQLITE_4_BYTE_ALIGNED_MALLOC=1
  115. -DSQLITE_DEFAULT_AUTOVACUUM=1
  116. -DSQLITE_DEFAULT_CACHE_SIZE=1000
  117. -DSQLITE_DEFAULT_LOCKING_MODE=0
  118. -DSQLITE_DEFAULT_PAGE_SIZE=1024
  119. -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000
  120. -DSQLITE_DISABLE_LFS=1
  121. -DSQLITE_ENABLE_FTS3=1
  122. -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
  123. -DSQLITE_ENABLE_RTREE=1
  124. -DSQLITE_MAX_COMPOUND_SELECT=50
  125. -DSQLITE_MAX_PAGE_SIZE=32768
  126. -DSQLITE_OMIT_TRACE=1
  127. -DSQLITE_TEMP_STORE=3
  128. -DSQLITE_THREADSAFE=2
  129. }
  130. "Locking-Style" {
  131. -O2
  132. -DSQLITE_ENABLE_LOCKING_STYLE=1
  133. }
  134. "OS-X" {
  135. -DSQLITE_OMIT_LOAD_EXTENSION=1
  136. -DSQLITE_DEFAULT_MEMSTATUS=0
  137. -DSQLITE_THREADSAFE=2
  138. -DSQLITE_OS_UNIX=1
  139. -DSQLITE_ENABLE_LOCKING_STYLE=1
  140. -DUSE_PREAD=1
  141. -DSQLITE_ENABLE_RTREE=1
  142. -DSQLITE_ENABLE_FTS3=1
  143. -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
  144. -DSQLITE_DEFAULT_CACHE_SIZE=1000
  145. -DSQLITE_MAX_LENGTH=2147483645
  146. -DSQLITE_MAX_VARIABLE_NUMBER=500000
  147. -DSQLITE_DEBUG=1
  148. -DSQLITE_PREFER_PROXY_LOCKING=1
  149. }
  150. "Extra-Robustness" {
  151. -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
  152. -DSQLITE_MAX_ATTACHED=62
  153. }
  154. "Devkit" {
  155. -DSQLITE_DEFAULT_FILE_FORMAT=4
  156. -DSQLITE_MAX_ATTACHED=30
  157. -DSQLITE_ENABLE_COLUMN_METADATA
  158. -DSQLITE_ENABLE_FTS4
  159. -DSQLITE_ENABLE_FTS4_PARENTHESIS
  160. -DSQLITE_DISABLE_FTS4_DEFERRED
  161. -DSQLITE_ENABLE_RTREE
  162. }
  163. }
  164. array set ::Platforms {
  165. Linux-x86_64 {
  166. "Check-Symbols" checksymbols
  167. "Debug-One" test
  168. "Secure-Delete" test
  169. "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
  170. "Update-Delete-Limit" test
  171. "Extra-Robustness" test
  172. "Device-Two" test
  173. "Ftrapv" test
  174. "Default" "threadtest test"
  175. "Device-One" fulltest
  176. }
  177. Linux-i686 {
  178. "Devkit" test
  179. "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
  180. "Device-One" test
  181. "Device-Two" test
  182. "Default" "threadtest fulltest"
  183. }
  184. Darwin-i386 {
  185. "Locking-Style" test
  186. "OS-X" "threadtest fulltest"
  187. }
  188. }
  189. # End of configuration section.
  190. #########################################################################
  191. #########################################################################
  192. foreach {key value} [array get ::Platforms] {
  193. foreach {v t} $value {
  194. if {0==[info exists ::Configs($v)]} {
  195. puts stderr "No such configuration: \"$v\""
  196. exit -1
  197. }
  198. }
  199. }
  200. proc run_test_suite {name testtarget config} {
  201. # Tcl variable $opts is used to build up the value used to set the
  202. # OPTS Makefile variable. Variable $cflags holds the value for
  203. # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
  204. # CFLAGS is only passed to gcc.
  205. #
  206. set cflags ""
  207. set opts ""
  208. foreach arg $config {
  209. if {[string match -D* $arg]} {
  210. lappend opts $arg
  211. } else {
  212. lappend cflags $arg
  213. }
  214. }
  215. set cflags [join $cflags " "]
  216. set opts [join $opts " "]
  217. append opts " -DSQLITE_NO_SYNC=1 -DHAVE_USLEEP"
  218. # Set the sub-directory to use.
  219. #
  220. set dir [string tolower [string map {- _ " " _} $name]]
  221. if {$::tcl_platform(platform)=="windows"} {
  222. append opts " -DSQLITE_OS_WIN=1"
  223. } else {
  224. append opts " -DSQLITE_OS_UNIX=1"
  225. }
  226. # Run the test.
  227. #
  228. set makefile [file normalize $::MAKEFILE]
  229. file mkdir $dir
  230. puts -nonewline "Testing configuration \"$name\" (logfile=$dir/test.log)..."
  231. flush stdout
  232. set makecmd [concat \
  233. [list exec make -C $dir -f $makefile clean] \
  234. $testtarget \
  235. [list CFLAGS=$cflags OPTS=$opts >& $dir/test.log] \
  236. ]
  237. set tm1 [clock seconds]
  238. set rc [catch $makecmd]
  239. set tm2 [clock seconds]
  240. set minutes [expr {($tm2-$tm1)/60}]
  241. set seconds [expr {($tm2-$tm1)%60}]
  242. puts -nonewline [format " (%d:%.2d) " $minutes $seconds]
  243. if {$rc} {
  244. puts "FAILED."
  245. } else {
  246. puts "Ok."
  247. }
  248. }
  249. # This proc processes the command line options passed to this script.
  250. # Currently the only option supported is "-makefile", default
  251. # "releasetest.mk". Set the ::MAKEFILE variable to the value of this
  252. # option.
  253. #
  254. proc process_options {argv} {
  255. set ::MAKEFILE releasetest.mk ;# Default value
  256. set ::QUICK 0 ;# Default value
  257. set platform $::tcl_platform(os)-$::tcl_platform(machine)
  258. for {set i 0} {$i < [llength $argv]} {incr i} {
  259. switch -- [lindex $argv $i] {
  260. -makefile {
  261. incr i
  262. set ::MAKEFILE [lindex $argv $i]
  263. }
  264. -platform {
  265. incr i
  266. set platform [lindex $argv $i]
  267. }
  268. -quick {
  269. incr i
  270. set ::QUICK [lindex $argv $i]
  271. }
  272. default {
  273. puts stderr ""
  274. puts stderr [string trim $::USAGE_MESSAGE]
  275. exit -1
  276. }
  277. }
  278. }
  279. set ::MAKEFILE [file normalize $::MAKEFILE]
  280. if {0==[info exists ::Platforms($platform)]} {
  281. puts "Unknown platform: $platform"
  282. puts -nonewline "Set the -platform option to "
  283. set print [list]
  284. foreach p [array names ::Platforms] {
  285. lappend print "\"$p\""
  286. }
  287. lset print end "or [lindex $print end]"
  288. puts "[join $print {, }]."
  289. exit
  290. }
  291. set ::CONFIGLIST $::Platforms($platform)
  292. puts "Running the following configurations for $platform:"
  293. puts " [string trim $::CONFIGLIST]"
  294. }
  295. # Main routine.
  296. #
  297. proc main {argv} {
  298. # Process any command line options.
  299. process_options $argv
  300. foreach {zConfig target} $::CONFIGLIST {
  301. if {$::QUICK} {set target test}
  302. set config_options $::Configs($zConfig)
  303. run_test_suite $zConfig $target $config_options
  304. # If the configuration included the SQLITE_DEBUG option, then remove
  305. # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
  306. # add it and run veryquick.test.
  307. if {$target!="checksymbols"} {
  308. set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
  309. if {$debug_idx < 0} {
  310. run_test_suite "${zConfig}_debug" test [
  311. concat $config_options -DSQLITE_DEBUG=1
  312. ]
  313. } else {
  314. run_test_suite "${zConfig}_ndebug" test [
  315. lreplace $config_options $debug_idx $debug_idx
  316. ]
  317. }
  318. }
  319. }
  320. }
  321. main $argv