Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[DVFS] Rephrase debug statements
[simgrid.git] / src / surf / trace_mgr_test.cpp
index 4b81b68..4bdb1d7 100644 (file)
@@ -1,24 +1,24 @@
-/* Copyright (c) 2017. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2017-2018. The SimGrid Team. All rights reserved.               */
 
 /* 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. */
 
 #define BOOST_TEST_MODULE Trace Manager tests
-
 bool init_unit_test(); // boost forget to give this prototype on NetBSD, which does not fit our paranoid flags
 #define BOOST_TEST_DYN_LINK
 #define BOOST_TEST_NO_MAIN
 #include <boost/test/unit_test.hpp>
-namespace utf = boost::unit_test;
 
 #include "src/surf/surf_interface.hpp"
 #include "src/surf/trace_mgr.hpp"
-namespace tmgr = simgrid::trace_mgr;
 
 #include "xbt/log.h"
 #include "xbt/misc.h"
 
-#include <math.h>
+#include <cmath>
+
+namespace utf  = boost::unit_test;
+namespace tmgr = simgrid::trace_mgr;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(unit, "Unit tests of the Trace Manager");
 
@@ -28,7 +28,8 @@ public:
   explicit MockedResource() : simgrid::surf::Resource(nullptr, "fake", nullptr) {}
   void apply_event(tmgr_trace_event_t event, double value)
   {
-    XBT_VERB("t=%.1f: Change value to %lg (idx: %d)", thedate, value, event->idx);
+    XBT_VERB("t=%.1f: Change value to %lg (idx: %u)", thedate, value, event->idx);
+    tmgr_trace_event_unref(&event);
   }
   bool isUsed() { return true; }
 };
@@ -38,7 +39,7 @@ static void trace2vector(const char* str, std::vector<tmgr::DatedValue>* whereto
   simgrid::trace_mgr::trace* trace = tmgr_trace_new_from_string("TheName", str, 0);
   XBT_VERB("---------------------------------------------------------");
   XBT_VERB("data>>\n%s<<data\n", str);
-  for (auto evt : trace->event_list)
+  for (auto const& evt : trace->event_list)
     XBT_VERB("event: d:%lg v:%lg", evt.date_, evt.value_);
 
   MockedResource daResource;
@@ -58,9 +59,10 @@ static void trace2vector(const char* str, std::vector<tmgr::DatedValue>* whereto
       res->apply_event(it, value);
       whereto->push_back(tmgr::DatedValue(thedate, value));
     } else {
-      XBT_DEBUG("%.1f: ignore an event (idx: %d)\n", thedate, it->idx);
+      XBT_DEBUG("%.1f: ignore an event (idx: %u)\n", thedate, it->idx);
     }
   }
+  tmgr_finalize();
 }
 
 /* Fails in a way that is difficult to test: xbt_assert should become throw