Skip to content

Commit

Permalink
Run Tests in different configuration combinations.
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller committed Nov 26, 2024
1 parent 9ad7ff6 commit 29d6e47
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,33 @@ enum {
CMN_MONITORING_TIMEOUT_MS = (5000 + 100),
CMN_REGISTRATION_REFRESH_MS = (1000)
};
TEST(core_cpp_registration_public, ClientExpiration)

// struct to hold the test parameters
struct ClientsTestParams
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "core_cpp_registration_public");
eCAL::Configuration configuration;
};

// enable loop back communication in the same process
eCAL::Util::EnableLoopback(true);
// test class that accepts TestParams as a parameter
class ClientsTestFixture : public ::testing::TestWithParam<ClientsTestParams>
{
protected:
void SetUp() override
{
// set configuration from the test parameters
auto params = GetParam();
eCAL::Initialize(params.configuration, "core_cpp_registration_public", eCAL::Init::All);
eCAL::Util::EnableLoopback(true);
}

void TearDown() override
{
// clean up
eCAL::Finalize();
}
};
TEST_P(ClientsTestFixture, ClientExpiration)
{
std::map<eCAL::Registration::SServiceMethod, eCAL::SServiceMethodInformation> client_info_map;

// create simple client and let it expire
Expand Down Expand Up @@ -83,19 +102,10 @@ TEST(core_cpp_registration_public, ClientExpiration)

// check size
EXPECT_EQ(client_info_map.size(), 0);

// finalize eCAL API
eCAL::Finalize();
}

TEST(core_cpp_registration_public, ClientEqualQualities)
TEST_P(ClientsTestFixture, ClientEqualQualities)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "core_cpp_registration_public");

// enable loop back communication in the same process
eCAL::Util::EnableLoopback(true);

std::map<eCAL::Registration::SServiceMethod, eCAL::SServiceMethodInformation> client_info_map;

// create 2 clients with the same quality of data type information
Expand Down Expand Up @@ -181,19 +191,10 @@ TEST(core_cpp_registration_public, ClientEqualQualities)

// check size
EXPECT_EQ(client_info_map.size(), 0);

// finalize eCAL API
eCAL::Finalize();
}

TEST(core_cpp_registration_public, ClientDifferentQualities)
TEST_P(ClientsTestFixture, ClientDifferentQualities)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "core_cpp_registration_public");

// enable loop back communication in the same process
eCAL::Util::EnableLoopback(true);

std::map<eCAL::Registration::SServiceMethod, eCAL::SServiceMethodInformation> client_info_map;

// create 2 clients with different qualities of data type information
Expand Down Expand Up @@ -258,19 +259,10 @@ TEST(core_cpp_registration_public, ClientDifferentQualities)

// check size
EXPECT_EQ(client_info_map.size(), 0);

// finalize eCAL API
eCAL::Finalize();
}

TEST(core_cpp_registration_public, GetClientIDs)
TEST_P(ClientsTestFixture, GetClientIDs)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "core_cpp_registration_public");

// enable loop back communication in the same process
eCAL::Util::EnableLoopback(true);

// create simple client
{
// create client
Expand All @@ -296,7 +288,33 @@ TEST(core_cpp_registration_public, GetClientIDs)
EXPECT_EQ(service_method_info, info.info);
}
}

// finalize eCAL API
eCAL::Finalize();
}

INSTANTIATE_TEST_SUITE_P(
core_cpp_registration_public_clients,
ClientsTestFixture,
::testing::Values(
ClientsTestParams{ []() {
// shm
eCAL::Configuration config;
config.registration.layer.shm.enable = true;
config.registration.layer.udp.enable = false;
return config;
}() },
ClientsTestParams{ []() {
// shm + host group name
eCAL::Configuration config;
config.registration.layer.shm.enable = true;
config.registration.layer.udp.enable = false;
config.registration.host_group_name = "abc";
return config;
}() },
ClientsTestParams{ []() {
// udp
eCAL::Configuration config;
config.registration.layer.shm.enable = false;
config.registration.layer.udp.enable = true;
return config;
}() }
)
);
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ INSTANTIATE_TEST_SUITE_P(
config.registration.layer.udp.enable = false;
return config;
}() },
TestParams{ 10, []() {
// shm + host group name
eCAL::Configuration config;
config.registration.layer.shm.enable = true;
config.registration.layer.udp.enable = false;
config.registration.host_group_name = "abc";
return config;
}() },
TestParams{ 10, []() {
// udp
eCAL::Configuration config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,33 @@ enum {
CMN_REGISTRATION_REFRESH_MS = (1000)
};

TEST(core_cpp_registration_public, ServiceExpiration)
// struct to hold the test parameters
struct ServicesTestParams
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "core_cpp_registration_public");
eCAL::Configuration configuration;
};

// enable loop back communication in the same process
eCAL::Util::EnableLoopback(true);
// test class that accepts TestParams as a parameter
class ServicesTestFixture : public ::testing::TestWithParam<ServicesTestParams>
{
protected:
void SetUp() override
{
// set configuration from the test parameters
auto params = GetParam();
eCAL::Initialize(params.configuration, "core_cpp_registration_public", eCAL::Init::All);
eCAL::Util::EnableLoopback(true);
}

void TearDown() override
{
// clean up
eCAL::Finalize();
}
};

TEST_P(ServicesTestFixture, ServiceExpiration)
{
std::map<eCAL::Registration::SServiceMethod, eCAL::SServiceMethodInformation> service_info_map;

// create simple service and let it expire
Expand Down Expand Up @@ -80,19 +99,10 @@ TEST(core_cpp_registration_public, ServiceExpiration)

// check size
EXPECT_EQ(service_info_map.size(), 0);

// finalize eCAL API
eCAL::Finalize();
}

TEST(core_cpp_registration_public, ServiceEqualQualities)
TEST_P(ServicesTestFixture, ServiceEqualQualities)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "core_cpp_registration_public");

// enable loop back communication in the same process
eCAL::Util::EnableLoopback(true);

std::map<eCAL::Registration::SServiceMethod, eCAL::SServiceMethodInformation> service_info_map;

// create 2 services with the same quality of data type information
Expand Down Expand Up @@ -170,19 +180,10 @@ TEST(core_cpp_registration_public, ServiceEqualQualities)

// check size
EXPECT_EQ(service_info_map.size(), 0);

// finalize eCAL API
eCAL::Finalize();
}

TEST(core_cpp_registration_public, ServiceDifferentQualities)
TEST_P(ServicesTestFixture, ServiceDifferentQualities)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "core_cpp_registration_public");

// enable loop back communication in the same process
eCAL::Util::EnableLoopback(true);

std::map<eCAL::Registration::SServiceMethod, eCAL::SServiceMethodInformation> service_info_map;

// create 2 services with different qualities of data type information
Expand Down Expand Up @@ -239,19 +240,10 @@ TEST(core_cpp_registration_public, ServiceDifferentQualities)

// check size
EXPECT_EQ(service_info_map.size(), 0);

// finalize eCAL API
eCAL::Finalize();
}

TEST(core_cpp_registration_public, GetServiceIDs)
TEST_P(ServicesTestFixture, GetServiceIDs)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "core_cpp_registration_public");

// enable loop back communication in the same process
eCAL::Util::EnableLoopback(true);

// create simple server
{
// create server
Expand Down Expand Up @@ -285,7 +277,34 @@ TEST(core_cpp_registration_public, GetServiceIDs)
EXPECT_EQ(service_method_info, info.info);
}
}

// finalize eCAL API
eCAL::Finalize();
}


INSTANTIATE_TEST_SUITE_P(
core_cpp_registration_public_services,
ServicesTestFixture,
::testing::Values(
ServicesTestParams{[]() {
// shm
eCAL::Configuration config;
config.registration.layer.shm.enable = true;
config.registration.layer.udp.enable = false;
return config;
}() },
ServicesTestParams{ []() {
// shm + host group name
eCAL::Configuration config;
config.registration.layer.shm.enable = true;
config.registration.layer.udp.enable = false;
config.registration.host_group_name = "abc";
return config;
}() },
ServicesTestParams{[]() {
// udp
eCAL::Configuration config;
config.registration.layer.shm.enable = false;
config.registration.layer.udp.enable = true;
return config;
}() }
)
);
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ INSTANTIATE_TEST_SUITE_P(
config.registration.layer.udp.enable = false;
return config;
}() },
TestParams{10, []() {
// shm + host group name
eCAL::Configuration config;
config.registration.layer.shm.enable = true;
config.registration.layer.udp.enable = false;
config.registration.host_group_name = "abc";
return config;
}() },
TestParams{ 10, []() {
// udp
eCAL::Configuration config;
Expand Down

0 comments on commit 29d6e47

Please sign in to comment.