CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
test
common
test_multigpu_secondary.cpp
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#include "
test.h
"
8
9
#ifdef __linux__
10
11
#include <
carla/multigpu/secondary.h
>
12
13
#include <boost/asio/ip/tcp.hpp>
14
15
#include <cstdint>
16
#include <filesystem>
17
#include <iterator>
18
#include <memory>
19
#include <thread>
20
21
using namespace
std::chrono_literals;
22
23
namespace
{
24
25
std::size_t CountThreads() {
26
return
static_cast<
std::size_t
>
(
27
std::distance(std::filesystem::directory_iterator(
"/proc/self/task"
), {}));
28
}
29
30
}
// namespace
31
32
TEST
(multigpu_secondary, retrying_a_refused_connection_does_not_add_threads) {
33
using namespace
carla::multigpu
;
34
35
constexpr
auto
first_attempt = 500ms;
36
constexpr
auto
retry_window = 3000ms;
37
38
std::uint16_t unused_port = 0u;
39
{
40
boost::asio::io_context io_context;
41
boost::asio::ip::tcp::acceptor acceptor(
42
io_context,
43
boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4::loopback(), 0));
44
unused_port = acceptor.local_endpoint().port();
45
}
46
47
auto
secondary = std::make_shared<Secondary>(
"127.0.0.1"
, unused_port, [](
carla::multigpu::MultiGPUCommand
,
carla::Buffer
) {});
48
secondary->Connect();
49
std::this_thread::sleep_for(first_attempt);
50
const
auto
threads_after_first_attempt = CountThreads();
51
std::this_thread::sleep_for(retry_window);
52
const
auto
threads_after_retries = CountThreads();
53
secondary->Stop();
54
55
ASSERT_EQ(threads_after_retries, threads_after_first_attempt);
56
}
57
58
#endif
// __linux__
carla::Buffer
A piece of raw data.
Definition
carla/Buffer.h:42
carla::multigpu
Definition
commands.h:17
carla::multigpu::MultiGPUCommand
MultiGPUCommand
Definition
commands.h:19
secondary.h
test.h
TEST
TEST(agents_types, road_option_values_match_python)
Definition
test_agents.cpp:40
Generated by
1.18.0