Skip to content

Commit 7c75167

Browse files
add tests
1 parent c226760 commit 7c75167

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

tests/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ endif ()
2525

2626
set(library_dir "${CMAKE_SOURCE_DIR}/../o1heap")
2727

28-
# Use -DNO_STATIC_ANALYSIS=1 to suppress static analysis.
29-
# If not suppressed, the tools used here shall be available, otherwise the build will fail.
30-
if (NOT NO_STATIC_ANALYSIS)
28+
# clang-tidy
29+
set(DISABLE_CLANG_TIDY OFF CACHE BOOL "Do not use Clang-Tidy")
30+
if (NOT DISABLE_CLANG_TIDY)
3131
# clang-tidy (separate config files per directory)
3232
find_program(clang_tidy NAMES clang-tidy)
3333
if (NOT clang_tidy)
@@ -99,3 +99,4 @@ gen_test_matrix(
9999
test_general.cpp
100100
""
101101
)
102+
gen_test("test_general_c11_x32_trc" "test_general.cpp" "O1HEAP_TRACE=1" c_std_11 "-m32" "-m32")

tests/test_general.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,3 +603,21 @@ TEST_CASE("General: invariant checker")
603603
dg.oom_count++;
604604
REQUIRE(heap->doInvariantsHold());
605605
}
606+
607+
extern "C" void o1heapTraceAllocate(O1HeapInstance* const handle, void* const allocated_memory, size_t size)
608+
{
609+
REQUIRE(handle != nullptr);
610+
const auto* const h = reinterpret_cast<internal::O1HeapInstance*>(handle);
611+
h->validate();
612+
(void) allocated_memory;
613+
(void) size;
614+
}
615+
616+
extern "C" void o1heapTraceFree(O1HeapInstance* const handle, void* const freed_memory, size_t size)
617+
{
618+
REQUIRE(handle != nullptr);
619+
const auto* const h = reinterpret_cast<internal::O1HeapInstance*>(handle);
620+
h->validate();
621+
(void) freed_memory;
622+
(void) size;
623+
}

0 commit comments

Comments
 (0)