Skip to content

Commit bdb5407

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 bdb5407

File tree

9 files changed

+62
-59
lines changed

9 files changed

+62
-59
lines changed

.clang-tidy

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Checks: >-
2+
boost-*,
3+
bugprone-*,
4+
cert-*,
5+
clang-analyzer-*,
6+
cppcoreguidelines-*,
7+
google-*,
8+
hicpp-*,
9+
llvm-*,
10+
misc-*,
11+
modernize-*,
12+
performance-*,
13+
portability-*,
14+
readability-*,
15+
-boost-use-ranges,
16+
-clang-analyzer-core.uninitialized.Assign,
17+
-cppcoreguidelines-avoid-const-or-ref-data-members,
18+
-cppcoreguidelines-use-default-member-init,
19+
-google-readability-avoid-underscore-in-googletest-name,
20+
-google-readability-todo,
21+
-llvm-header-guard,
22+
-modernize-concat-nested-namespaces,
23+
-modernize-type-traits,
24+
-modernize-use-constraints,
25+
-modernize-use-default-member-init,
26+
-modernize-use-designated-initializers,
27+
-modernize-use-nodiscard,
28+
-modernize-use-ranges,
29+
-readability-avoid-const-params-in-decls,
30+
-readability-identifier-length,
31+
-*-use-trailing-return-type,
32+
-*-named-parameter,
33+
CheckOptions:
34+
- key: readability-function-cognitive-complexity.Threshold
35+
value: '90'
36+
- key: readability-magic-numbers.IgnoredIntegerValues
37+
value: '1;2;3;4;5;8;10;16;20;32;60;64;100;128;256;500;512;1000'
38+
WarningsAsErrors: '*'
39+
HeaderFilterRegex: 'include/cetl/.*\.hpp'
40+
FormatStyle: file

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: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,23 @@ 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 = 4096;
2626

27-
public:
28-
cetl::pmr::O1HeapAlignedStorage<TestBufferSize> large_buffer{};
27+
void SetUp() override
28+
{
29+
// Fill the buffer with a known pattern to help identify uninitialized memory usage
30+
memset(&large_buffer, 0xAA, sizeof(large_buffer)); // NOLINT
31+
}
32+
33+
protected:
34+
static cetl::pmr::O1HeapAlignedStorage<TestBufferSize> large_buffer;
2935
};
3036

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-
}
37+
cetl::pmr::O1HeapAlignedStorage<O1HeapMemoryResourceTest::TestBufferSize> O1HeapMemoryResourceTest::large_buffer;
3838

3939
TEST_F(O1HeapMemoryResourceTest, O1HeapAlignedStorageTest)
4040
{
41-
cetl::pmr::O1HeapAlignedStorage<4096> aligned_storage{};
42-
cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate test_subject{aligned_storage};
41+
cetl::pmr::UnsynchronizedO1HeapMemoryResourceDelegate test_subject{large_buffer};
4342
void* mem = test_subject.allocate(16);
4443
ASSERT_NE(nullptr, mem);
4544
test_subject.deallocate(mem, 16);
@@ -89,12 +88,7 @@ TEST_F(O1HeapMemoryResourceTest, TestAllocationFailureThrowsBadAlloc)
8988
void* final_alloc = test_subject.allocate(64);
9089
EXPECT_EQ(nullptr, final_alloc) << "Allocation should return nullptr when heap is exhausted";
9190
#endif
92-
93-
// Clean up allocations
94-
for (void* mem : allocations)
95-
{
96-
test_subject.deallocate(mem, 64);
97-
}
91+
// Don't worry about deallocating memory since the allocator and small_buffer both go out of scope with the test.
9892
}
9993

10094
} // 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)