Skip to content

Commit 6858160

Browse files
committed
iox-#1613 Use IOX_EXPECT_FATAL_FAILURE in some iceoryx_posh tests
1 parent 5469b86 commit 6858160

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

iceoryx_posh/test/moduletests/test_capro_service.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "iceoryx_dust/cxx/convert.hpp"
2121
#include "iceoryx_dust/cxx/serialization.hpp"
22+
#include "iceoryx_hoofs/error_handling/error_handling.hpp"
23+
#include "iceoryx_hoofs/testing/fatal_failure.hpp"
2224
#include "iceoryx_hoofs/testing/mocks/logger_mock.hpp"
2325
#include "iceoryx_posh/capro/service_description.hpp"
2426
#include "iox/string.hpp"
@@ -30,6 +32,7 @@
3032
namespace
3133
{
3234
using namespace ::testing;
35+
using namespace iox::testing;
3336

3437
using namespace iox::capro;
3538

@@ -129,7 +132,8 @@ TEST_F(ServiceDescription_test, ClassHashSubsriptOperatorOutOfBoundsFails)
129132
testHash[2] = 3U;
130133
testHash[3] = 4U;
131134

132-
EXPECT_DEATH({ testHash[4] = 5U; }, ".*");
135+
136+
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { testHash[4] = 5U; }, iox::HoofsError::EXPECTS_ENSURES_FAILED);
133137
}
134138

135139
/// END CLASSHASH TESTS

iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "iceoryx_dust/cxx/convert.hpp"
1919
#include "iceoryx_hoofs/cxx/type_traits.hpp"
20+
#include "iceoryx_hoofs/error_handling/error_handling.hpp"
21+
#include "iceoryx_hoofs/testing/fatal_failure.hpp"
2022
#include "iceoryx_posh/internal/mepoo/mem_pool.hpp"
2123
#include "iceoryx_posh/internal/mepoo/memory_manager.hpp"
2224
#include "iceoryx_posh/mepoo/chunk_header.hpp"
@@ -30,6 +32,7 @@ namespace
3032
{
3133
using namespace ::testing;
3234
using namespace iox::mepoo;
35+
using namespace iox::testing;
3336

3437
using UserPayloadOffset_t = ChunkHeader::UserPayloadOffset_t;
3538

@@ -367,7 +370,12 @@ TEST(ChunkHeader_test, ConstructorTerminatesWhenUserPayloadSizeExceedsChunkSize)
367370
ASSERT_FALSE(chunkSettingsResult.has_error());
368371
auto& chunkSettings = chunkSettingsResult.value();
369372

370-
EXPECT_DEATH({ ChunkHeader sut(CHUNK_SIZE, chunkSettings); }, ".*");
373+
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>(
374+
[&] {
375+
ChunkHeader sut(CHUNK_SIZE, chunkSettings);
376+
;
377+
},
378+
iox::HoofsError::EXPECTS_ENSURES_FAILED);
371379
}
372380

373381
// BEGIN PARAMETERIZED TESTS FOR CHUNK HEADER

iceoryx_posh/test/moduletests/test_mepoo_config.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
//
1515
// SPDX-License-Identifier: Apache-2.0
1616

17+
#include "iceoryx_hoofs/testing/fatal_failure.hpp"
18+
#include "iceoryx_posh/error_handling/error_handling.hpp"
1719
#include "iceoryx_posh/iceoryx_posh_types.hpp"
1820
#include "iceoryx_posh/mepoo/mepoo_config.hpp"
1921
#include "test.hpp"
2022

2123
using namespace ::testing;
24+
using namespace iox::testing;
2225

2326
using namespace iox::mepoo;
2427

@@ -58,7 +61,11 @@ TEST_F(MePooConfig_Test, AddingMempoolWhenTheMemPoolConfigContainerIsFullReturns
5861
{
5962
sut.addMemPool({SIZE, CHUNK_COUNT});
6063
}
61-
EXPECT_DEATH({ sut.addMemPool({SIZE, CHUNK_COUNT}); }, ".*");
64+
IOX_EXPECT_FATAL_FAILURE<iox::PoshError>(
65+
[&] {
66+
sut.addMemPool({SIZE, CHUNK_COUNT});
67+
},
68+
iox::PoshError::MEPOO__MAXIMUM_NUMBER_OF_MEMPOOLS_REACHED);
6269
}
6370

6471
TEST_F(MePooConfig_Test, SetDefaultMethodAddsTheDefaultMemPoolConfigurationToTheMemPoolConfigContainer)

iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
// SPDX-License-Identifier: Apache-2.0
1717

1818
#include "iceoryx_hoofs/cxx/variant_queue.hpp"
19+
#include "iceoryx_hoofs/error_handling/error_handling.hpp"
1920
#include "iceoryx_hoofs/testing/barrier.hpp"
21+
#include "iceoryx_hoofs/testing/fatal_failure.hpp"
2022
#include "iceoryx_hoofs/testing/watch_dog.hpp"
2123
#include "iceoryx_posh/internal/mepoo/shared_chunk.hpp"
2224
#include "iceoryx_posh/internal/popo/building_blocks/chunk_distributor.hpp"
@@ -33,6 +35,7 @@
3335
namespace
3436
{
3537
using namespace ::testing;
38+
using namespace iox::testing;
3639
using namespace iox::popo;
3740
using namespace iox::cxx;
3841
using namespace iox::mepoo;
@@ -126,17 +129,16 @@ constexpr std::chrono::milliseconds ChunkDistributor_test<PolicyType>::BLOCKING_
126129
template <typename PolicyType>
127130
constexpr iox::units::Duration ChunkDistributor_test<PolicyType>::DEADLOCK_TIMEOUT;
128131

129-
/// @todo iox-#898: this is broken on macOS and triggers the watchdog, even with 5 seconds timeout
130-
#if !defined(__APPLE__)
131132
TYPED_TEST(ChunkDistributor_test, AddingNullptrQueueDoesNotWork)
132133
{
133134
::testing::Test::RecordProperty("TEST_ID", "aa7eaa9e-c337-45dc-945a-d097b8916eaa");
134135
auto sutData = this->getChunkDistributorData();
135136
typename TestFixture::ChunkDistributor_t sut(sutData.get());
136137

137-
EXPECT_DEATH(IOX_DISCARD_RESULT(sut.tryAddQueue(nullptr)), ".*");
138+
139+
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { sut.tryAddQueue(nullptr); },
140+
iox::HoofsError::EXPECTS_ENSURES_FAILED);
138141
}
139-
#endif
140142

141143
TYPED_TEST(ChunkDistributor_test, NewChunkDistributorHasNoQueues)
142144
{

0 commit comments

Comments
 (0)