X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ecd5f7562caf1d443bf22788fa5f4fac408776ec..2b3790827a15510aa6b18146bc01597a568b332b:/src/surf/trace_mgr_test.cpp diff --git a/src/surf/trace_mgr_test.cpp b/src/surf/trace_mgr_test.cpp index 823baf8b03..064b2a1d0a 100644 --- a/src/surf/trace_mgr_test.cpp +++ b/src/surf/trace_mgr_test.cpp @@ -1,14 +1,15 @@ -/* Copyright (c) 2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2017-2019. 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 +bool init_unit_test(); // boost sometimes forget to give this prototype (NetBSD and other), which does not fit our paranoid flags #define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include +#include "simgrid/kernel/resource/Resource.hpp" #include "src/surf/surf_interface.hpp" #include "src/surf/trace_mgr.hpp" @@ -18,46 +19,45 @@ bool init_unit_test(); // boost forget to give this prototype on NetBSD, which d #include namespace utf = boost::unit_test; -namespace tmgr = simgrid::trace_mgr; XBT_LOG_NEW_DEFAULT_CATEGORY(unit, "Unit tests of the Trace Manager"); double thedate; -class MockedResource : public simgrid::surf::Resource { +class MockedResource : public simgrid::kernel::resource::Resource { public: - explicit MockedResource() : simgrid::surf::Resource(nullptr, "fake", nullptr) {} - void apply_event(tmgr_trace_event_t event, double value) + explicit MockedResource() : simgrid::kernel::resource::Resource(nullptr, "fake", nullptr) {} + void apply_event(simgrid::kernel::profile::Event* event, double value) override { XBT_VERB("t=%.1f: Change value to %lg (idx: %u)", thedate, value, event->idx); tmgr_trace_event_unref(&event); } - bool isUsed() { return true; } + bool is_used() override { return true; } }; -static void trace2vector(const char* str, std::vector* whereto) +static void trace2vector(const char* str, std::vector* whereto) { - simgrid::trace_mgr::trace* trace = tmgr_trace_new_from_string("TheName", str, 0); + simgrid::kernel::profile::Profile* trace = tmgr_trace_new_from_string("TheName", str, 0); XBT_VERB("---------------------------------------------------------"); XBT_VERB("data>>\n%s<event_list) XBT_VERB("event: d:%lg v:%lg", evt.date_, evt.value_); MockedResource daResource; - simgrid::trace_mgr::future_evt_set fes; - tmgr_trace_event_t insertedIt = fes.add_trace(trace, &daResource); + simgrid::kernel::profile::FutureEvtSet fes; + simgrid::kernel::profile::Event* insertedIt = fes.add_trace(trace, &daResource); while (fes.next_date() <= 20.0 && fes.next_date() >= 0) { thedate = fes.next_date(); double value; - simgrid::surf::Resource* res; - tmgr_trace_event_t it = fes.pop_leq(thedate, &value, &res); + simgrid::kernel::resource::Resource* res; + simgrid::kernel::profile::Event* it = fes.pop_leq(thedate, &value, &res); if (it == nullptr) continue; BOOST_CHECK_EQUAL(it, insertedIt); // Check that we find what we've put if (value >= 0) { res->apply_event(it, value); - whereto->push_back(tmgr::DatedValue(thedate, value)); + whereto->push_back(simgrid::kernel::profile::DatedValue(thedate, value)); } else { XBT_DEBUG("%.1f: ignore an event (idx: %u)\n", thedate, it->idx); } @@ -74,76 +74,76 @@ BOOST_AUTO_TEST_CASE(no_evt_noloop) { }*/ BOOST_AUTO_TEST_CASE(one_evt_noloop) { - std::vector got; + std::vector got; trace2vector("9.0 3.0\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(9, 3)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(9, 3)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } BOOST_AUTO_TEST_CASE(two_evt_noloop) { - std::vector got; + std::vector got; trace2vector("3.0 1.0\n" "9.0 3.0\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(3, 1)); - want.push_back(tmgr::DatedValue(9, 3)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(3, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(9, 3)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } BOOST_AUTO_TEST_CASE(three_evt_noloop) { - std::vector got; + std::vector got; trace2vector("3.0 1.0\n" "5.0 2.0\n" "9.0 3.0\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(3, 1)); - want.push_back(tmgr::DatedValue(5, 2)); - want.push_back(tmgr::DatedValue(9, 3)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(3, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(5, 2)); + want.push_back(simgrid::kernel::profile::DatedValue(9, 3)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } BOOST_AUTO_TEST_CASE(two_evt_loop) { - std::vector got; + std::vector got; trace2vector("1.0 1.0\n" "3.0 3.0\n" "LOOPAFTER 2\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(1, 1)); - want.push_back(tmgr::DatedValue(3, 3)); - want.push_back(tmgr::DatedValue(6, 1)); - want.push_back(tmgr::DatedValue(8, 3)); - want.push_back(tmgr::DatedValue(11, 1)); - want.push_back(tmgr::DatedValue(13, 3)); - want.push_back(tmgr::DatedValue(16, 1)); - want.push_back(tmgr::DatedValue(18, 3)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(1, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(3, 3)); + want.push_back(simgrid::kernel::profile::DatedValue(6, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(8, 3)); + want.push_back(simgrid::kernel::profile::DatedValue(11, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(13, 3)); + want.push_back(simgrid::kernel::profile::DatedValue(16, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(18, 3)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } BOOST_AUTO_TEST_CASE(two_evt_start0_loop) { - std::vector got; + std::vector got; trace2vector("0.0 1\n" "5.0 2\n" "LOOPAFTER 5\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(0, 1)); - want.push_back(tmgr::DatedValue(5, 2)); - want.push_back(tmgr::DatedValue(10, 1)); - want.push_back(tmgr::DatedValue(15, 2)); - want.push_back(tmgr::DatedValue(20, 1)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(0, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(5, 2)); + want.push_back(simgrid::kernel::profile::DatedValue(10, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(15, 2)); + want.push_back(simgrid::kernel::profile::DatedValue(20, 1)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } @@ -157,7 +157,6 @@ 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); }