diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index 94c5a44f903..a67dc8db0da 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -122,7 +122,7 @@ RTPSParticipant* RTPSDomain::createParticipant( // Create filewatch RTPSDomainImpl::file_watch_handle_ = SystemInfo::watch_file(filename, RTPSDomainImpl::file_watch_callback); } - else + else if (!filename.empty()) { logWarning(RTPS_PARTICIPANT, filename + " does not exist. File watching not initialized."); } diff --git a/test/blackbox/common/BlackboxTestsPubSubBasic.cpp b/test/blackbox/common/BlackboxTestsPubSubBasic.cpp index d5810e4afd8..0abf0b60781 100644 --- a/test/blackbox/common/BlackboxTestsPubSubBasic.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubBasic.cpp @@ -14,16 +14,22 @@ #include "BlackboxTests.hpp" +#include "mock/BlackboxMockConsumer.h" #include "PubSubParticipant.hpp" #include "PubSubReader.hpp" #include "PubSubWriter.hpp" -#include "ReqRepAsReliableHelloWorldRequester.hpp" #include "ReqRepAsReliableHelloWorldReplier.hpp" +#include "ReqRepAsReliableHelloWorldRequester.hpp" + +#include #include #include +#include +#include #include +#include using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -81,6 +87,52 @@ class PubSubBasic : public testing::TestWithParam(helper_consumer)); // Registering a consumer transfer ownership + // Filter specific message + Log::SetVerbosity(Log::Kind::Warning); + Log::SetCategoryFilter(std::regex("RTPS_PARTICIPANT")); + Log::SetErrorStringFilter(std::regex(".*does not exist. File watching not initialized.")); + + /* Create and enable DomainParticipant */ + PubSubReader reader(TEST_TOPIC_NAME); + reader.init(); + EXPECT_TRUE(reader.isInitialized()); + + /* Check logs */ + Log::Flush(); + EXPECT_EQ(helper_consumer->ConsumedEntries().size(), expected_logs); + + /* Clean-up */ + Log::Reset(); // This calls to ClearConsumers, which deletes the registered consumer +} + TEST_P(PubSubBasic, PubSubAsNonReliableHelloworld) { // Best effort incompatible with best effort @@ -756,6 +808,22 @@ TEST_P(PubSubBasic, ReliableTransientLocalTwoWritersConsecutives) } } +/* + * Check that setting FASTDDS_ENVIRONMENT_FILE to an unexisting file issues 1 logWarning + */ +TEST(PubSubBasic, EnvFileWarningWrongFile) +{ + env_file_warning("unexisting_file", 1); +} + +/* + * Check that setting FASTDDS_ENVIRONMENT_FILE to an empty string issues 0 logWarning + */ +TEST(PubSubBasic, EnvFileWarningEmpty) +{ + env_file_warning("", 0); +} + #ifdef INSTANTIATE_TEST_SUITE_P #define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_SUITE_P(x, y, z, w) #else diff --git a/test/blackbox/common/mock/BlackboxMockConsumer.h b/test/blackbox/common/mock/BlackboxMockConsumer.h index 9415b39e86c..8b2d10f0164 100644 --- a/test/blackbox/common/mock/BlackboxMockConsumer.h +++ b/test/blackbox/common/mock/BlackboxMockConsumer.h @@ -16,8 +16,10 @@ #define MOCK_BLACKBOX_LOG_CONSUMER_H #include -#include + +#include #include +#include #include namespace eprosima { @@ -33,7 +35,7 @@ class BlackboxMockConsumer : public LogConsumer { std::unique_lock guard(mMutex); mEntriesConsumed.push_back(entry); - cv_.notify_one(); + cv_.notify_all(); } const std::vector ConsumedEntries() const @@ -42,6 +44,13 @@ class BlackboxMockConsumer : public LogConsumer return mEntriesConsumed; } + void clear_entries() + { + std::unique_lock guard(mMutex); + mEntriesConsumed.clear(); + cv_.notify_all(); + } + std::condition_variable& cv() { return cv_;