From: Frederic Suter Date: Mon, 17 Jul 2017 12:16:47 +0000 (+0200) Subject: plug leaks in low level tests X-Git-Tag: v3_17~380 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b5dd72a23cf8e0dcc7cb4c3a3b9e12c45aae766b plug leaks in low level tests adding a higher level init function ensures that all data structures are correctly deallocated. Would be better to not allocate them at all (dict of mailboxes for instance), but no user won't ever write XBT or SURF test, will they? --- diff --git a/teshsuite/surf/lmm_usage/lmm_usage.cpp b/teshsuite/surf/lmm_usage/lmm_usage.cpp index 01a2dfadb4..ce8eac5e71 100644 --- a/teshsuite/surf/lmm_usage/lmm_usage.cpp +++ b/teshsuite/surf/lmm_usage/lmm_usage.cpp @@ -6,12 +6,13 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "xbt/sysdep.h" +#include "simgrid/msg.h" +#include "src/surf/surf_interface.hpp" #include "surf/maxmin.h" #include "xbt/log.h" #include "xbt/module.h" +#include "xbt/sysdep.h" #include -#include "src/surf/surf_interface.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example"); @@ -298,8 +299,9 @@ static void test3(method_t method) xbt_free(A); } -int main() +int main(int argc, char** argv) { + MSG_init(&argc, argv); XBT_INFO("***** Test 1 (Max-Min)"); test1(MAXMIN); XBT_INFO("***** Test 1 (Lagrange - Vegas)"); diff --git a/teshsuite/surf/maxmin_bench/maxmin_bench.cpp b/teshsuite/surf/maxmin_bench/maxmin_bench.cpp index c4972b26da..aed2abb2a9 100644 --- a/teshsuite/surf/maxmin_bench/maxmin_bench.cpp +++ b/teshsuite/surf/maxmin_bench/maxmin_bench.cpp @@ -7,9 +7,10 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "surf/maxmin.h" +#include "simgrid/msg.h" #include "xbt/module.h" +#include "xbt/sysdep.h" /* time manipulation for benchmarking */ #include "xbt/xbt_os_time.h" -#include "xbt/sysdep.h" /* time manipulation for benchmarking */ #define MYRANDMAX 1000 @@ -117,6 +118,8 @@ unsigned int TestClasses [][4]= int main(int argc, char **argv) { + MSG_init(&argc, argv); + float rate_no_limit=0.2; float acc_date=0; float acc_date2=0; diff --git a/teshsuite/xbt/heap_bench/heap_bench.c b/teshsuite/xbt/heap_bench/heap_bench.c index 3d2c542600..47797d2a34 100644 --- a/teshsuite/xbt/heap_bench/heap_bench.c +++ b/teshsuite/xbt/heap_bench/heap_bench.c @@ -10,6 +10,7 @@ #include #include +#include "simgrid/msg.h" #include "xbt/heap.h" #include "xbt/sysdep.h" @@ -89,10 +90,11 @@ static void test_heap_mean_operation(int size) xbt_heap_free(heap); } -int main(int argc, char **argv) +int main(int argc, char** argv) { - int size; - for (size = 100; size < 10000; size *= 10) { + MSG_init(&argc, argv); + + for (int size = 100; size < 10000; size *= 10) { test_heap_validity(size); test_heap_mean_operation(size); } diff --git a/teshsuite/xbt/log_large/log_large.c b/teshsuite/xbt/log_large/log_large.c index 9eeec686d9..3abb24a6b4 100644 --- a/teshsuite/xbt/log_large/log_large.c +++ b/teshsuite/xbt/log_large/log_large.c @@ -7,11 +7,13 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt.h" +#include XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logs of this example"); int main(int argc, char *argv[]) { + MSG_init(&argc, argv); char *tmp = bprintf("\n%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s", 1, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", 2, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", @@ -24,8 +26,6 @@ int main(int argc, char *argv[]) 9, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", 0, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n"); - xbt_init(&argc, argv); - XBT_INFO("This is a very large message:\n0%s1%s2%s3%s4%s5%s6%s7%s8%s9%s", tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp); XBT_INFO("Done (strlen>%d)", (int) (10 * strlen(tmp)));