-
Notifications
You must be signed in to change notification settings - Fork 787
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test RTPSParticipant creation fails if SHM MaxMessageSize is lower th…
…an minimum Signed-off-by: Eugenio Collado <[email protected]>
- Loading branch information
1 parent
549428a
commit 01bf69f
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2018 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set(PARTICIPANTTESTS_SOURCE ParticipantTests.cpp) | ||
|
||
add_executable(RTPSParticipantTests ${PARTICIPANTTESTS_SOURCE}) | ||
target_compile_definitions(RTPSParticipantTests PRIVATE | ||
BOOST_ASIO_STANDALONE | ||
ASIO_STANDALONE | ||
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG> | ||
$<$<BOOL:${INTERNAL_DEBUG}>:__INTERNALDEBUG> # Internal debug activated. | ||
) | ||
target_include_directories(RTPSParticipantTests PRIVATE | ||
${Asio_INCLUDE_DIR}) | ||
target_link_libraries(RTPSParticipantTests fastcdr fastdds foonathan_memory | ||
GTest::gmock | ||
${CMAKE_DL_LIBS}) | ||
gtest_discover_tests(RTPSParticipantTests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2020 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include <fastdds/rtps/RTPSDomain.hpp> | ||
#include <fastdds/rtps/participant/RTPSParticipant.hpp> | ||
#include <fastdds/rtps/writer/RTPSWriter.hpp> | ||
#include <fastdds/rtps/history/IPayloadPool.hpp> | ||
#include <fastdds/rtps/history/WriterHistory.hpp> | ||
|
||
#include <rtps/writer/BaseWriter.hpp> | ||
|
||
|
||
namespace eprosima { | ||
namespace fastdds { | ||
namespace rtps { | ||
|
||
using namespace testing; | ||
|
||
RTPSParticipant* transport_size_participant_init( | ||
uint32_t max_message_size) | ||
{ | ||
uint32_t domain_id = 0; | ||
std::string max_message_size_str = std::to_string(max_message_size); | ||
|
||
RTPSParticipantAttributes p_attr; | ||
BuiltinTransportsOptions options; | ||
options.maxMessageSize = max_message_size; | ||
p_attr.setup_transports(BuiltinTransports::SHM, options); | ||
RTPSParticipant* participant = RTPSDomain::createParticipant( | ||
domain_id, true, p_attr); | ||
|
||
return participant; | ||
} | ||
|
||
/** | ||
* This test checks that the participant is not created when the max message size is smaller than the PDP package size | ||
* but it is properly created when the max message size is bigger than the PDP package size. | ||
*/ | ||
TEST(RTPSParticipantTests, participant_creation_message_size) | ||
{ | ||
ASSERT_EQ(transport_size_participant_init(100), nullptr); | ||
ASSERT_NE(transport_size_participant_init(1000), nullptr); | ||
} | ||
|
||
} // namespace rtps | ||
} // namespace fastdds | ||
} // namespace eprosima | ||
|
||
int main( | ||
int argc, | ||
char** argv) | ||
{ | ||
testing::InitGoogleMock(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |