File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ add_definitions(-DWAMR_BUILD_TEST=1)
1111# Test-specific feature configuration
1212set (WAMR_BUILD_AOT 0)
1313set (WAMR_BUILD_FAST_INTERP 0)
14- set (WAMR_BUILD_INTERP 0 )
14+ set (WAMR_BUILD_INTERP 1 )
1515set (WAMR_BUILD_JIT 0)
1616set (WAMR_BUILD_LIBC_WASI 0)
1717set (WAMR_BUILD_APP_FRAMEWORK 0)
@@ -27,6 +27,12 @@ set(TEST_SOURCES
2727# Create test executable
2828add_executable (mem-alloc-test ${TEST_SOURCES} )
2929
30+ # Add include directories for mem-alloc internals
31+ target_include_directories (mem-alloc-test PRIVATE
32+ ${WAMR_ROOT_DIR} /core/shared/mem-alloc
33+ ${WAMR_ROOT_DIR} /core/shared/mem-alloc/ems
34+ )
35+
3036# Link dependencies
3137target_link_libraries (mem-alloc-test cmocka::cmocka m )
3238
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
3+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+ */
5+
6+ #include <stdarg.h>
7+ #include <stddef.h>
8+ #include <setjmp.h>
9+ #include <stdint.h>
10+ #include <string.h>
11+ #include <cmocka.h>
12+
13+ #if WAMR_BUILD_TEST != 1
14+ #error "WAMR_BUILD_TEST must be defined as 1"
15+ #endif
16+
17+ #include "mem_alloc.h"
18+ #include "ems_gc_internal.h"
19+
20+ /* Test helper: Check if pointer is aligned */
21+ static inline bool
22+ is_aligned (void * ptr , size_t alignment )
23+ {
24+ return ((uintptr_t )ptr % alignment ) == 0 ;
25+ }
26+
27+ /* Test helper: Check if allocation is aligned (has magic value) */
28+ static inline bool
29+ is_aligned_allocation (gc_object_t obj )
30+ {
31+ uint32_t * magic_ptr = (uint32_t * )((char * )obj - 4 );
32+ return ((* magic_ptr & ALIGNED_ALLOC_MAGIC_MASK ) == ALIGNED_ALLOC_MAGIC_VALUE );
33+ }
34+
35+ /* Tests will be added incrementally */
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
3+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+ */
5+
6+ #include <stdarg.h>
7+ #include <stddef.h>
8+ #include <setjmp.h>
9+ #include <stdint.h>
10+ #include <cmocka.h>
11+
12+ /* Include test implementations */
13+ #include "mem_alloc_test.c"
14+
15+ int
16+ main (void )
17+ {
18+ const struct CMUnitTest tests [] = {
19+ /* Tests will be added incrementally */
20+ };
21+
22+ return cmocka_run_group_tests (tests , NULL , NULL );
23+ }
You can’t perform that action at this time.
0 commit comments