Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
overall optimization of map usage
[simgrid.git] / src / surf / trace_mgr_test.cpp
index 30c53c6..bc2d47c 100644 (file)
@@ -4,22 +4,22 @@
  * 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>
 
+namespace utf  = boost::unit_test;
+namespace tmgr = simgrid::trace_mgr;
+
 XBT_LOG_NEW_DEFAULT_CATEGORY(unit, "Unit tests of the Trace Manager");
 
 double thedate;
@@ -29,6 +29,7 @@ public:
   void apply_event(tmgr_trace_event_t event, double value)
   {
     XBT_VERB("t=%.1f: Change value to %lg (idx: %d)", thedate, value, event->idx);
+    tmgr_trace_event_unref(&event);
   }
   bool isUsed() { return true; }
 };
@@ -61,6 +62,7 @@ static void trace2vector(const char* str, std::vector<tmgr::DatedValue>* whereto
       XBT_DEBUG("%.1f: ignore an event (idx: %d)\n", thedate, it->idx);
     }
   }
+  tmgr_finalize();
 }
 
 /* Fails in a way that is difficult to test: xbt_assert should become throw
@@ -113,7 +115,7 @@ BOOST_AUTO_TEST_CASE(two_evt_loop)
   std::vector<tmgr::DatedValue> got;
   trace2vector("1.0 1.0\n"
                "3.0 3.0\n"
-               "WAITFOR 2\n",
+               "LOOPAFTER 2\n",
                &got);
 
   std::vector<tmgr::DatedValue> want;
@@ -133,7 +135,7 @@ BOOST_AUTO_TEST_CASE(two_evt_start0_loop)
   std::vector<tmgr::DatedValue> got;
   trace2vector("0.0 1\n"
                "5.0 2\n"
-               "WAITFOR 5\n",
+               "LOOPAFTER 5\n",
                &got);
 
   std::vector<tmgr::DatedValue> want;
@@ -155,6 +157,7 @@ static bool init_function()
 
 int main(int argc, char** argv)
 {
+  XBT_LOG_CONNECT(unit);
   xbt_log_init(&argc, argv);
   return ::boost::unit_test::unit_test_main(&init_function, argc, argv);
 }