forked from eclipse-iceoryx/iceoryx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iox-eclipse-iceoryx#1030 Add builder for minimal 'RouDiConfig_t'
- Loading branch information
1 parent
0471df8
commit 7299cd1
Showing
5 changed files
with
87 additions
and
3 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
43 changes: 43 additions & 0 deletions
43
iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp
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,43 @@ | ||
// Copyright (c) 2023 by Mathias Kraus <elboberido@m-hias.de>. All rights reserved. | ||
// | ||
// 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. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef IOX_POSH_ROUDI_ENVIRONMENT_MINIMAL_ROUDI_CONFIG_HPP | ||
#define IOX_POSH_ROUDI_ENVIRONMENT_MINIMAL_ROUDI_CONFIG_HPP | ||
|
||
#include "iceoryx_posh/iceoryx_posh_config.hpp" | ||
#include "iox/builder.hpp" | ||
|
||
namespace iox | ||
{ | ||
namespace testing | ||
{ | ||
/// @brief Builder for a minimal RouDiConfig_t with only one MemPool. This significantly speeds up tests which create a | ||
/// shared memory. | ||
class MinimalRouDiConfigBuilder | ||
{ | ||
/// @brief Set the chunk size. Default = 128 | ||
IOX_BUILDER_PARAMETER(uint32_t, chunk_size, 128) | ||
/// @brief Set the chunk count. Default = 10 | ||
IOX_BUILDER_PARAMETER(uint32_t, chunk_count, 10) | ||
|
||
public: | ||
/// @brief creates the previously configured RouDiConfig_t | ||
RouDiConfig_t create() const noexcept; | ||
}; | ||
} // namespace testing | ||
} // namespace iox | ||
|
||
#endif // IOX_POSH_ROUDI_ENVIRONMENT_MINIMAL_ROUDI_CONFIG_HPP |
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
33 changes: 33 additions & 0 deletions
33
iceoryx_posh/testing/roudi_environment/minimal_roudi_config.cpp
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,33 @@ | ||
// Copyright (c) 2023 by Mathias Kraus <elboberido@m-hias.de>. All rights reserved. | ||
// | ||
// 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. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" | ||
|
||
namespace iox | ||
{ | ||
namespace testing | ||
{ | ||
RouDiConfig_t MinimalRouDiConfigBuilder::create() const noexcept | ||
{ | ||
RouDiConfig_t roudiConfig; | ||
mepoo::MePooConfig mepooConfig; | ||
mepooConfig.addMemPool({m_chunk_size, m_chunk_count}); | ||
auto currentGroup = iox::posix::PosixGroup::getGroupOfCurrentProcess(); | ||
roudiConfig.m_sharedMemorySegments.push_back({currentGroup.getName(), currentGroup.getName(), mepooConfig}); | ||
return roudiConfig; | ||
} | ||
} // namespace testing | ||
} // namespace iox |