]> Savannah Git Hosting - gnulib.git/commitdiff
ssfmalloc tests: Small tweaks.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Oct 2020 17:18:06 +0000 (18:18 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Oct 2020 17:18:06 +0000 (18:18 +0100)
* tests/test-ssfmalloc.c: Add comments.
(alloc_pages): Don't require PROT_EXEC bits.
(block_sizes): Add more small sizes, for better coverage of
ssfmalloc-bitmap.h.

ChangeLog
tests/test-ssfmalloc.c

index 26ba40cde2d64bfad2500093159e7e8710038439..bb838bc8836b6208f6e0a895f551b14716a88e10 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-10-25  Bruno Haible  <bruno@clisp.org>
 
+       ssfmalloc tests: Small tweaks.
+       * tests/test-ssfmalloc.c: Add comments.
+       (alloc_pages): Don't require PROT_EXEC bits.
+       (block_sizes): Add more small sizes, for better coverage of
+       ssfmalloc-bitmap.h.
+
        ssfmalloc tests: Portability to Minix.
        * modules/ssfmalloc-tests (Files): Add m4/mmap-anon.m4.
        (configure.ac): Invoke gl_FUNC_MMAP_ANON.
index 09427c77013f0cb24e565b5d5ab4d02542309e10..9699e6b5ed5cb15c6957b4a1513f6d431bb37810 100644 (file)
@@ -92,7 +92,7 @@ alloc_pages (size_t size)
   return (uintptr_t) mem;
 #else
   /* Use mmap with the MAP_ANONYMOUS or MAP_ANON flag.  */
-  void *mem = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
+  void *mem = mmap (NULL, size, PROT_READ | PROT_WRITE,
                     MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0);
   if (mem == (void *)(-1))
     return 0;
@@ -143,6 +143,7 @@ free_pages (uintptr_t pages, size_t size)
 
 #include "macros.h"
 
+/* Fills a block of a given size with some contents.  */
 static void
 fill_block (uintptr_t block, size_t size)
 {
@@ -150,6 +151,8 @@ fill_block (uintptr_t block, size_t size)
   memset ((char *) block, code, size);
 }
 
+/* Verifies that the contents of a block is still present
+   (i.e. has not accidentally been overwritten by other operations).  */
 static void
 verify_block (uintptr_t block, size_t size)
 {
@@ -187,12 +190,29 @@ static size_t block_sizes[] =
     64,
     65,
     71,
+    77,
     83,
+    96,
     99,
     110,
+    119,
     127,
     128,
+    130,
+    144,
+    150,
+    157,
+    161,
     169,
+    180,
+    192,
+    199,
+    204,
+    210,
+    224,
+    225,
+    236,
+    241,
     249,
     255,
     256,
@@ -266,6 +286,9 @@ main (int argc, char *argv[])
 
   init_pagesize ();
 
+  /* Randomly allocate and deallocate blocks.
+     Also verify that there are no unexpected modifications to the contents of
+     these blocks.  */
   {
     unsigned int repeat;
     char *blocks[SIZEOF (block_sizes)];