X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/697e7bf5e65bce115783c6debcded0cf6f14744d..HEAD:/src/kernel/resource/profile/Profile_test.cpp diff --git a/src/kernel/resource/profile/Profile_test.cpp b/src/kernel/resource/profile/Profile_test.cpp index 283de0f333..97ff0ab71d 100644 --- a/src/kernel/resource/profile/Profile_test.cpp +++ b/src/kernel/resource/profile/Profile_test.cpp @@ -1,16 +1,14 @@ -/* Copyright (c) 2017-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2017-2023. 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. */ -#include "catch.hpp" +#include "src/3rd-party/catch.hpp" -#include "simgrid/kernel/resource/Resource.hpp" -#include "src/kernel/resource/profile/DatedValue.hpp" +#include "simgrid/kernel/ProfileBuilder.hpp" +#include "src/kernel/resource/Resource.hpp" #include "src/kernel/resource/profile/Event.hpp" -#include "src/kernel/resource/profile/Profile.hpp" #include "src/kernel/resource/profile/StochasticDatedValue.hpp" -#include "src/surf/surf_interface.hpp" #include "xbt/log.h" #include "xbt/misc.h" @@ -24,7 +22,7 @@ class MockedResource : public simgrid::kernel::resource::Resource { public: static double the_date; - explicit MockedResource() { this->set_name("fake"); } + explicit MockedResource() : Resource("fake"){} void apply_event(simgrid::kernel::profile::Event* event, double value) override { XBT_VERB("t=%.1f: Change value to %lg (idx: %u)", the_date, value, event->idx); @@ -38,15 +36,15 @@ double MockedResource::the_date; static std::vector trace2vector(const char* str) { std::vector res; - simgrid::kernel::profile::Profile* trace = simgrid::kernel::profile::Profile::from_string("TheName", str, 0); + simgrid::kernel::profile::Profile* trace = simgrid::kernel::profile::ProfileBuilder::from_string("TheName", str, 0); XBT_VERB("---------------------------------------------------------"); XBT_VERB("data>>\n%s<event_list) + for (auto const& evt : trace->get_event_list()) XBT_VERB("event: d:%lg v:%lg", evt.date_, evt.value_); MockedResource daResource; simgrid::kernel::profile::FutureEvtSet fes; - simgrid::kernel::profile::Event* insertedIt = trace->schedule(&fes, &daResource); + const simgrid::kernel::profile::Event* insertedIt = trace->schedule(&fes, &daResource); while (fes.next_date() <= 20.0 && fes.next_date() >= 0) { MockedResource::the_date = fes.next_date(); @@ -68,14 +66,6 @@ static std::vector trace2vector(const char return res; } -static std::vector trace2selist(const char* str) -{ - const simgrid::kernel::profile::Profile* trace = simgrid::kernel::profile::Profile::from_string("TheName", str, 0); - std::vector stocevlist = trace->stochastic_event_list; - tmgr_finalize(); - return stocevlist; -} - TEST_CASE("kernel::profile: Resource profiles, defining the external load", "kernel::profile") { SECTION("No event, no loop") @@ -162,7 +152,6 @@ TEST_CASE("kernel::profile: Resource profiles, defining the external load", "ker "DET 0 UNIF 10 20"); std::vector want; - want.emplace_back(0, -1); // The initial fake event want.emplace_back(Distribution::DET, std::vector{0}, Distribution::UNIF, std::vector{10, 20}); REQUIRE(want == got); @@ -178,7 +167,6 @@ TEST_CASE("kernel::profile: Resource profiles, defining the external load", "ker "DET 5 UNIF 5 25"); std::vector want; - want.emplace_back(0, -1); want.emplace_back(Distribution::DET, std::vector{0}, Distribution::DET, std::vector{4}); want.emplace_back(Distribution::NORM, std::vector{25, 10}, Distribution::DET, std::vector{3}); want.emplace_back(Distribution::UNIF, std::vector{10, 20}, Distribution::NORM, std::vector{25, 10});