Skip to content

Commit e41233b

Browse files
Scott DixonScott Dixon
authored andcommitted
Bumbling around trying to fix assert in CI
Not able to reproduce so far.
1 parent e2961a7 commit e41233b

8 files changed

Lines changed: 13 additions & 58 deletions

File tree

cetlvast/CMakePresets.json

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -502,20 +502,6 @@
502502
"gcovr_sonarqube_report_for_examples"
503503
]
504504
},
505-
{
506-
"name": "manual-Coverage-no-scan-gcc-native-cpp-14-offline",
507-
"configurePreset": "configure-gcc-native-cpp-14-offline",
508-
"configuration": "Coverage",
509-
"targets": [
510-
"build",
511-
"run_unittests",
512-
"gcovr_html_report_for_unittest",
513-
"gcovr_sonarqube_report_for_unittest",
514-
"run_examples",
515-
"gcovr_html_report_for_examples",
516-
"gcovr_sonarqube_report_for_examples"
517-
]
518-
},
519505
{
520506
"name": "build-Release-gcc-native-cpp-14-online",
521507
"configurePreset": "configure-gcc-native-cpp-14-online",
@@ -2112,21 +2098,6 @@
21122098
}
21132099
]
21142100
},
2115-
{
2116-
"name": "manual-sonar-scan-gcc-native-cpp-14-offline",
2117-
"displayName": "gcc native cpp 14 offline (Coverage only).",
2118-
"description": "Hand-managed workflow for generating coverage data for sonarqube scans.",
2119-
"steps": [
2120-
{
2121-
"type": "configure",
2122-
"name": "configure-gcc-native-cpp-14-offline"
2123-
},
2124-
{
2125-
"type": "build",
2126-
"name": "manual-Coverage-gcc-native-cpp-14-offline"
2127-
}
2128-
]
2129-
},
21302101
{
21312102
"name": "manual-coverage-gcc-native-cpp-14-offline",
21322103
"displayName": "gcc native cpp 14 offline (Coverage only).",
@@ -2138,7 +2109,7 @@
21382109
},
21392110
{
21402111
"type": "build",
2141-
"name": "manual-Coverage-no-scan-gcc-native-cpp-14-offline"
2112+
"name": "manual-Coverage-gcc-native-cpp-14-offline"
21422113
}
21432114
]
21442115
},

cetlvast/suites/docs/examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set(NATIVE_EXAMPLES
3131
example_08_variable_length_array_vs_vector.cpp
3232
example_09_variant.cpp
3333
example_10_unbounded_variant.cpp
34-
example_11_memory_resource_01heap.cpp
34+
example_11_memory_resource_o1heap.cpp
3535
)
3636

3737
set(ALL_EXAMPLES "")

cetlvast/suites/docs/examples/example_11_memory_resource_01heap.cpp renamed to cetlvast/suites/docs/examples/example_11_memory_resource_o1heap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace cetl
1616
namespace pf17
1717
{
1818

19-
TEST(example_11_memory_resource_01heap, main)
19+
TEST(example_11_memory_resource_o1heap, main)
2020
{
2121
//! [main]
2222
// We'll use the aligned-storage helper class to defined properly aligned storage for the 01-heap areana. As this

cetlvast/suites/unittest/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,3 @@ add_executable(cetlvast_sonar
208208
target_link_libraries(cetlvast_sonar
209209
PRIVATE cetl
210210
)
211-
212-
find_package(SonarScanner)

cetlvast/suites/unittest/test_o1heap_memory_resource.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,15 @@ namespace test
2222

2323
class O1HeapMemoryResourceTest : public ::testing::Test
2424
{
25-
static constexpr std::size_t TestBufferSize = 0x100000;
25+
static constexpr std::size_t TestBufferSize = 0x4096;
2626

2727
public:
2828
cetl::pmr::O1HeapAlignedStorage<TestBufferSize> large_buffer{};
2929
};
3030

31-
TEST_F(O1HeapMemoryResourceTest, TestDefault)
32-
{
33-
cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate test_subject{large_buffer};
34-
void* mem = test_subject.allocate(8);
35-
ASSERT_NE(nullptr, mem);
36-
test_subject.deallocate(mem, 8);
37-
}
38-
3931
TEST_F(O1HeapMemoryResourceTest, O1HeapAlignedStorageTest)
4032
{
41-
cetl::pmr::O1HeapAlignedStorage<4096> aligned_storage{};
42-
cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate test_subject{aligned_storage};
33+
cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate test_subject{large_buffer};
4334
void* mem = test_subject.allocate(16);
4435
ASSERT_NE(nullptr, mem);
4536
test_subject.deallocate(mem, 16);
@@ -89,12 +80,7 @@ TEST_F(O1HeapMemoryResourceTest, TestAllocationFailureThrowsBadAlloc)
8980
void* final_alloc = test_subject.allocate(64);
9081
EXPECT_EQ(nullptr, final_alloc) << "Allocation should return nullptr when heap is exhausted";
9182
#endif
92-
93-
// Clean up allocations
94-
for (void* mem : allocations)
95-
{
96-
test_subject.deallocate(mem, 64);
97-
}
83+
// Don't worry about deallocating memory since the allocator and small_buffer both go out of scope with the test.
9884
}
9985

10086
} // namespace test

include/cetl/cetl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/// - @subpage example_08_variable_length_array_vs_vector
3232
/// - @subpage example_09_variant
3333
/// - @subpage example_10_unbounded_variant
34-
/// - @subpage example_11_memory_resource_01heap
34+
/// - @subpage example_11_memory_resource_o1heap
3535
///
3636
/// @page example_01_polyfill_20 Example 1: CETL C++20 Polyfill Header
3737
/// Full example for @ref cetl/pf20/cetlpf.hpp
@@ -74,9 +74,9 @@
7474
/// Full example for cetl::unbounded_variant
7575
/// @include example_10_unbounded_variant.cpp
7676
///
77-
/// @page example_11_memory_resource_01heap Example 11: Using the 01Heap memory_resource
77+
/// @page example_11_memory_resource_o1heap Example 11: Using the 01heap memory_resource
7878
/// Full example for cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate
79-
/// @include example_11_memory_resource_01heap.cpp
79+
/// @include example_11_memory_resource_o1heap.cpp
8080
///
8181

8282
#ifndef CETL_H_INCLUDED

include/cetl/pmr/o1heap_memory_resource_delegate.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// include cetl/pf17/cetlpf.hpp or provide the memory_resource definition you want this class to use.
55
/// You'll also need to provide an include path to o1heap.h and compile in o1heap.c when using this type.
66
///
7-
/// @snippet{trimleft} example_11_memory_resource_01heap.cpp main
7+
/// @snippet{trimleft} example_11_memory_resource_o1heap.cpp main
88
///
99
/// @copyright
1010
/// Copyright (C) OpenCyphal Development Team <opencyphal.org>
@@ -38,10 +38,10 @@ struct O1HeapAlignedStorage
3838

3939
static_assert(O1HEAP_ALIGNMENT >= alignof(std::max_align_t), "O1HEAP_ALIGNMENT is too small for this platform.");
4040

41-
struct alignas(alignment) type
41+
struct alignas(alignment) type // NOSONAR cpp:5945
4242
{
4343
std::array<unsigned char, arena_size> data;
44-
} storage[1];
44+
} storage[1]; // NOSONAR cpp:3646
4545
};
4646

4747
class UnsynchronizedO1HeapMemoryResourceDelegate

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ sonar.cpd.exclusions=cetlvast/**/*,**/sonar.cpp
2424

2525
# Rule exclusions
2626
sonar.issue.ignore.multicriteria=e1
27-
sonar.issue.ignore.multicriteria.e1.ruleKey=cpp:S994
27+
sonar.issue.ignore.multicriteria.e1.ruleKey=cpp:S994,cpp:S799
2828
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*

0 commit comments

Comments
 (0)