Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Parameter 'fd' is always -1 for xbt_mheap_new. Kill dead code.
[simgrid.git] / teshsuite / xbt / mmalloc / mmalloc_test.cpp
index b610e1f..76196b8 100644 (file)
@@ -27,8 +27,7 @@ constexpr int TESTSIZE = 100;
 static void check_block(const unsigned char* p, unsigned char b, int n)
 {
   for (int i = 0; i < n; i++)
-    if (p[i] != b)
-      xbt_die("value mismatch: %p[%d] = %#hhx, expected %#hhx", p, i, p[i], b);
+    xbt_assert(p[i] == b, "value mismatch: %p[%d] = %#hhx, expected %#hhx", p, i, p[i], b);
 }
 
 int main(int argc, char**argv)
@@ -40,7 +39,7 @@ int main(int argc, char**argv)
   XBT_INFO("Allocating a new heap");
   unsigned long mask = ~((unsigned long)xbt_pagesize - 1);
   auto* addr         = reinterpret_cast<void*>(((unsigned long)sbrk(0) + BUFFSIZE) & mask);
-  heapA = xbt_mheap_new(-1, addr);
+  heapA              = xbt_mheap_new(addr, 0);
   if (heapA == nullptr) {
     perror("attach 1 failed");
     fprintf(stderr, "bye\n");
@@ -80,8 +79,7 @@ int main(int argc, char**argv)
     } catch (const simgrid::Exception&) {
       gotit = true;
     }
-    if (not gotit)
-      xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i));
+    xbt_assert(gotit, "FAIL: A double-free went undetected (for size:%d)", size_of_block(i));
   }
 
   XBT_INFO("free again all blocks (to really check that double free are correctly caught)");
@@ -92,8 +90,7 @@ int main(int argc, char**argv)
     } catch (const simgrid::Exception&) {
       gotit = true;
     }
-    if (not gotit)
-      xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i));
+    xbt_assert(gotit, "FAIL: A double-free went undetected (for size:%d)", size_of_block(i));
   }
 
   XBT_INFO("Let's try different codepaths for mrealloc");