1 /* Copyright (c) 2017-2022. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "NetZone_test.hpp" // CreateHost callback
9 #include "simgrid/kernel/routing/TorusZone.hpp"
10 #include "simgrid/s4u/Engine.hpp"
12 TEST_CASE("kernel::routing::TorusZone: Creating Zone", "")
14 simgrid::s4u::Engine e("test");
15 simgrid::s4u::ClusterCallbacks callbacks(CreateHost{});
16 REQUIRE(create_torus_zone("test", e.get_netzone_root(), {3, 3, 3}, callbacks, 1e9, 10,
17 simgrid::s4u::Link::SharingPolicy::SHARED));
20 TEST_CASE("kernel::routing::TorusZone: Invalid params", "")
22 simgrid::s4u::Engine e("test");
23 simgrid::s4u::ClusterCallbacks callbacks(CreateHost{});
25 SECTION("Empty dimensions")
27 REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {}, callbacks, 1e9, 10,
28 simgrid::s4u::Link::SharingPolicy::SHARED),
29 std::invalid_argument);
31 SECTION("One 0 dimension")
33 REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 0, 2}, callbacks, 1e9, 10,
34 simgrid::s4u::Link::SharingPolicy::SHARED),
35 std::invalid_argument);
37 SECTION("Invalid bandwidth")
39 REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 2, 2}, callbacks, 0, 10,
40 simgrid::s4u::Link::SharingPolicy::SHARED),
41 std::invalid_argument);
43 SECTION("Invalid latency")
45 REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 2, 2}, callbacks, 1e9, -10,
46 simgrid::s4u::Link::SharingPolicy::SHARED),
47 std::invalid_argument);