Skip to content

Commit

Permalink
iox-#2301 Fix tests for 32 bit builds
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Aug 22, 2024
1 parent 72fbf3f commit 1a15b22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions iceoryx_hoofs/test/moduletests/test_time_unit_duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ TEST(Duration_test, ConvertTimespecWithNoneReferenceFromDurationMoreThanOneSecon
TEST(Duration_test, ConvertTimespecWithNoneReferenceFromDurationResultsNotYetInSaturation)
{
::testing::Test::RecordProperty("TEST_ID", "70f11b99-78ec-442a-aefe-4dd9152b7903");
constexpr int64_t SECONDS{std::numeric_limits<int64_t>::max()};
constexpr int64_t SECONDS{std::numeric_limits<decltype(timespec::tv_sec)>::max()};
constexpr int64_t NANOSECONDS{NANOSECS_PER_SECOND - 1U};

auto duration = createDuration(SECONDS, NANOSECONDS);
Expand All @@ -1064,7 +1064,7 @@ TEST(Duration_test, ConvertTimespecWithNoneReferenceFromDurationResultsNotYetInS
TEST(Duration_test, ConvertTimespecWithNoneReferenceFromMaxDurationResultsInSaturation)
{
::testing::Test::RecordProperty("TEST_ID", "3bf4bb34-46f3-4889-84f5-9220b32fff73");
constexpr int64_t SECONDS{std::numeric_limits<int64_t>::max()};
constexpr int64_t SECONDS{std::numeric_limits<decltype(timespec::tv_sec)>::max()};
constexpr int64_t NANOSECONDS{NANOSECS_PER_SECOND - 1U};

const timespec sut = DurationAccessor::max().timespec(iox::units::TimeSpecReference::None);
Expand Down Expand Up @@ -1101,7 +1101,7 @@ TEST(Duration_test, ConvertTimespecWithMonotonicReference)
TEST(Duration_test, ConvertTimespecWithMonotonicReferenceFromMaxDurationResultsInSaturation)
{
::testing::Test::RecordProperty("TEST_ID", "ff5a1fe2-65c8-490a-b31d-4d8ea615c91a");
constexpr int64_t SECONDS{std::numeric_limits<int64_t>::max()};
constexpr int64_t SECONDS{std::numeric_limits<decltype(timespec::tv_sec)>::max()};
constexpr int64_t NANOSECONDS{NANOSECS_PER_SECOND - 1U};

const timespec sut = DurationAccessor::max().timespec(iox::units::TimeSpecReference::Monotonic);
Expand Down Expand Up @@ -1129,7 +1129,7 @@ TEST(Duration_test, ConvertTimespecWithEpochReference)
TEST(Duration_test, ConvertTimespecWithEpochReferenceFromMaxDurationResultsInSaturation)
{
::testing::Test::RecordProperty("TEST_ID", "97ff4204-a7f7-43ef-b81e-0e359d1dce93");
constexpr int64_t SECONDS{std::numeric_limits<int64_t>::max()};
constexpr int64_t SECONDS{std::numeric_limits<decltype(timespec::tv_sec)>::max()};
constexpr int64_t NANOSECONDS{NANOSECS_PER_SECOND - 1U};

const timespec sut = DurationAccessor::max().timespec(iox::units::TimeSpecReference::Epoch);
Expand Down
12 changes: 10 additions & 2 deletions iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "iceoryx_posh/internal/posh_error_reporting.hpp"
#include "iox/bump_allocator.hpp"
#include "iox/detail/hoofs_error_reporting.hpp"
#include "iox/detail/system_configuration.hpp"

#include "iceoryx_hoofs/testing/fatal_failure.hpp"
#include "test.hpp"
Expand All @@ -46,8 +47,8 @@ class MemPool_test : public Test
{
}

void SetUp(){};
void TearDown(){};
void SetUp() {};
void TearDown() {};

alignas(MemPool::CHUNK_MEMORY_ALIGNMENT) uint8_t
m_rawMemory[NUMBER_OF_CHUNKS * CHUNK_SIZE + LOFFLI_MEMORY_REQUIREMENT];
Expand Down Expand Up @@ -138,6 +139,13 @@ TEST_F(MemPool_test, MempoolPointeToIndexConversionForMemoryOffsetsLargerThan4GB
constexpr uint64_t GB{1ULL << 30};
constexpr uint64_t CHUNK_SIZE{128 * MB};
constexpr uint64_t RAW_MEMORY_BASE{0x7f60d90c5000ULL};

if (iox::detail::isCompiledOn32BitSystem())
{
GTEST_SKIP() << "This test does not work on 32 bit builds since it requires pointer larger than the 32 bit "
"address space";
}

uint8_t* const RAW_MEMORY_PTR{reinterpret_cast<uint8_t*>(RAW_MEMORY_BASE)};
constexpr uint32_t EXPECTED_INDEX{42};
uint8_t* const CHUNK_PTR{RAW_MEMORY_PTR + static_cast<uint64_t>(EXPECTED_INDEX) * CHUNK_SIZE};
Expand Down

0 comments on commit 1a15b22

Please sign in to comment.