]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Revise test cases in malloc5.test to accommodate varying allocation
authordrh <drh@noemail.net>
Tue, 10 Mar 2015 13:50:18 +0000 (13:50 +0000)
committerdrh <drh@noemail.net>
Tue, 10 Mar 2015 13:50:18 +0000 (13:50 +0000)
sizes returned by some system malloc() implementations.

FossilOrigin-Name: fbae6bafd74d8da9c72be5f562a62f80b01cc846

manifest
manifest.uuid
test/malloc5.test

index a8566de9633c174cb8f84f5f19a8864ae33f056f..3769cadfe28d58211542c8e1bf245edf4b31fd1d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\sLIKE\soptimization\sso\sthat\sit\sworks\seven\sif\sthere\sare\sadditional\nrange\scontraints\son\sthe\scolumn\sthat\sis\ssubject\sto\sthe\sLIKE\sor\sGLOB.
-D 2015-03-09T13:01:02.136
+C Revise\stest\scases\sin\smalloc5.test\sto\saccommodate\svarying\sallocation\nsizes\sreturned\sby\ssome\ssystem\smalloc()\simplementations.
+D 2015-03-10T13:50:18.414
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 2f643d6968dfc0b82d2e546a0525a39079f9e928
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -709,7 +709,7 @@ F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
 F test/malloc.test 96939d2d1a6f39667bbebe5bc27c6525f2ab614e
 F test/malloc3.test e3b32c724b5a124b57cb0ed177f675249ad0c66a
 F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
-F test/malloc5.test fafce0aa9157060445cd1a56ad50fc79d82f28c3
+F test/malloc5.test 79182b8bffd6d62f77b1a5a8ba8e6bf0e5053b8e
 F test/malloc6.test 2f039d9821927eacae43e1831f815e157659a151
 F test/malloc7.test 7c68a32942858bc715284856c5507446bba88c3a
 F test/malloc8.test 9b7a3f8cb9cf0b12fff566e80a980b1767bd961d
@@ -1241,8 +1241,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P e5da5e7d5dc5a3438ced23f1ee83e695abc29c45 0e02dc94fd1bb891d0edd1e34b57e923b17712a7
-R c1700660b0fab033a6359aa8c00c1b69
-T +closed 0e02dc94fd1bb891d0edd1e34b57e923b17712a7
+P 984c3fd5261619fb542a5a95dab37707b5d79dbf
+R 755476faee751a04385de321ff0c4db7
 U drh
-Z 0d4bf9b628bd332a63a01f9a77a070c3
+Z d102bfa9bbfc74e74ac15b539033106b
index 5e807e391c07c6657a2380c61649f13bf1dc65e4..960352f2cd11dc2c0931febf8d9ac87794879475 100644 (file)
@@ -1 +1 @@
-984c3fd5261619fb542a5a95dab37707b5d79dbf
\ No newline at end of file
+fbae6bafd74d8da9c72be5f562a62f80b01cc846
\ No newline at end of file
index 6abedf79e1c438c1302955074884b144c83c3c8b..c046499261cf77dd33d4e8e15c7761c1a43222c7 100644 (file)
@@ -71,6 +71,23 @@ do_test malloc5-1.3 {
   expr $::pgalloc > 0
 } {1}
 
+# The sizes of memory allocations from system malloc() might vary,
+# depending on the memory allocator algorithms used.  The following
+# routine is designed to support answers that fall within a range
+# of values while also supplying easy-to-understand "expected" values
+# when errors occur.
+#
+proc value_in_range {target x args} {
+  set v [lindex $args 0]
+  if {$v!=""} {
+    if {$v<$target*$x} {return $v}
+    if {$v>$target/$x} {return $v}
+  }
+  return "number between [expr {int($target*$x)}] and [expr {int($target/$x)}]"
+}
+set mrange 0.98   ;#  plus or minus 2%
+
+
 do_test malloc5-1.4 {
   # Commit the transaction and open a new one. Read 1 page into the cache.
   # Because the page is not dirty, it is eligible for collection even
@@ -81,16 +98,16 @@ do_test malloc5-1.4 {
     BEGIN;
     SELECT * FROM abc;
   }
-  sqlite3_release_memory
-} $::pgalloc
+  value_in_range $::pgalloc $::mrange [sqlite3_release_memory]
+} [value_in_range $::pgalloc $::mrange]
 
 do_test malloc5-1.5 {
   # Conclude the transaction opened in the previous [do_test] block. This
   # causes another page (page 1) to become eligible for recycling.
   #
   execsql { COMMIT }
-  sqlite3_release_memory
-} $::pgalloc
+  value_in_range $::pgalloc $::mrange [sqlite3_release_memory]
+} [value_in_range $::pgalloc $::mrange]
 
 do_test malloc5-1.6 {
   # Manipulate the cache so that it contains two unused pages. One requires 
@@ -101,8 +118,8 @@ do_test malloc5-1.6 {
     SELECT * FROM abc;
     CREATE TABLE def(d, e, f);
   }
-  sqlite3_release_memory 500
-} $::pgalloc
+  value_in_range $::pgalloc $::mrange [sqlite3_release_memory 500]
+} [value_in_range $::pgalloc $::mrange]
 
 do_test malloc5-1.7 {
   # Database should not be locked this time.