Skip to content

Commit 52ff880

Browse files
committed
test(mem-alloc): add test infrastructure
Add CMocka support and mem-alloc test subdirectory.
1 parent b1c99bc commit 52ff880

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

tests/unit/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ endif()
7373
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
7474
FetchContent_MakeAvailable(googletest)
7575

76+
# Fetch CMocka for C unit tests
77+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
78+
FetchContent_Declare(
79+
cmocka
80+
URL https://git.cryptomilk.org/projects/cmocka.git/snapshot/cmocka-2.0.1.tar.gz
81+
DOWNLOAD_EXTRACT_TIMESTAMP ON
82+
)
83+
else()
84+
FetchContent_Declare(
85+
cmocka
86+
URL https://git.cryptomilk.org/projects/cmocka.git/snapshot/cmocka-2.0.1.tar.gz
87+
)
88+
endif()
89+
FetchContent_MakeAvailable(cmocka)
90+
7691
include(GoogleTest)
7792
enable_testing()
7893

@@ -90,6 +105,7 @@ add_subdirectory(unsupported-features)
90105
add_subdirectory(smart-tests)
91106
add_subdirectory(exception-handling)
92107
add_subdirectory(running-modes)
108+
add_subdirectory(mem-alloc)
93109

94110
if(WAMR_BUILD_TARGET STREQUAL "X86_64")
95111
add_subdirectory(aot-stack-frame)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
cmake_minimum_required(VERSION 3.14)
5+
6+
project(test-mem-alloc)
7+
8+
# Enable test build flag
9+
add_definitions(-DWAMR_BUILD_TEST=1)
10+
11+
# Test-specific feature configuration
12+
set(WAMR_BUILD_AOT 0)
13+
set(WAMR_BUILD_FAST_INTERP 0)
14+
set(WAMR_BUILD_INTERP 0)
15+
set(WAMR_BUILD_JIT 0)
16+
set(WAMR_BUILD_LIBC_WASI 0)
17+
set(WAMR_BUILD_APP_FRAMEWORK 0)
18+
19+
include(../unit_common.cmake)
20+
21+
# Test source files
22+
set(TEST_SOURCES
23+
test_runner.c
24+
${WAMR_RUNTIME_LIB_SOURCE}
25+
)
26+
27+
# Create test executable
28+
add_executable(mem-alloc-test ${TEST_SOURCES})
29+
30+
# Link dependencies
31+
target_link_libraries(mem-alloc-test cmocka::cmocka m)
32+
33+
# Add to ctest
34+
add_test(NAME mem-alloc-test COMMAND mem-alloc-test)
35+
set_tests_properties(mem-alloc-test PROPERTIES TIMEOUT 60)

0 commit comments

Comments
 (0)