Skip to content

Commit 5ca5183

Browse files
committed
refactor: streamline CMake configurations and improve code coverage collection
1 parent 6253bd1 commit 5ca5183

21 files changed

Lines changed: 70 additions & 328 deletions

File tree

build-scripts/config_common.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ if (WAMR_BUILD_GC_HEAP_VERIFY EQUAL 1)
603603
message (" GC heap verification enabled")
604604
endif ()
605605
if ("$ENV{COLLECT_CODE_COVERAGE}" STREQUAL "1" OR COLLECT_CODE_COVERAGE EQUAL 1)
606-
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
607-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
606+
add_compile_options(--coverage -fprofile-update=atomic -O0 -g)
607+
link_libraries(gcov)
608608
add_definitions (-DCOLLECT_CODE_COVERAGE)
609609
message (" Collect code coverage enabled")
610610
endif ()

tests/unit/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
7676
add_subdirectory (compilation)
7777

7878
# Fast-JIT or mem64 is not supported on X86_32
79-
add_subdirectory (running-modes)
79+
# add_subdirectory (running-modes)
8080
add_subdirectory (memory64)
81-
add_subdirectory (shared-heap)
81+
# add_subdirectory (shared-heap)
8282

8383
# HW_BOUND_CHECK is not supported on X86_32
8484
add_subdirectory (runtime-common)

tests/unit/aot-stack-frame/CMakeLists.txt

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,10 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
3232
set (UNIT_SOURCE ${source_all})
3333

3434
set (unit_test_sources
35-
${UNIT_SOURCE}
36-
${WAMR_RUNTIME_LIB_SOURCE}
37-
${UNCOMMON_SHARED_SOURCE}
38-
${SRC_LIST}
39-
${PLATFORM_SHARED_SOURCE}
40-
${UTILS_SHARED_SOURCE}
41-
${MEM_ALLOC_SHARED_SOURCE}
42-
${LIB_HOST_AGENT_SOURCE}
43-
${NATIVE_INTERFACE_SOURCE}
44-
${LIBC_BUILTIN_SOURCE}
45-
${IWASM_COMMON_SOURCE}
46-
${IWASM_INTERP_SOURCE}
47-
${IWASM_AOT_SOURCE}
48-
${IWASM_COMPL_SOURCE}
49-
${WASM_APP_LIB_SOURCE_ALL}
50-
)
35+
${UNIT_SOURCE}
36+
${WAMR_RUNTIME_LIB_SOURCE}
37+
${IWASM_COMPL_SOURCE}
38+
)
5139

5240
# Automatically build wasm-apps for this test
5341
add_subdirectory(wasm-apps)
@@ -59,4 +47,4 @@ add_dependencies (aot_stack_frame_test aot-stack-frame-test-wasm)
5947

6048
target_link_libraries (aot_stack_frame_test ${LLVM_AVAILABLE_LIBS} gtest_main )
6149

62-
#gtest_discover_tests(aot_stack_frame_test)
50+
gtest_discover_tests(aot_stack_frame_test)

tests/unit/aot/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ set (WAMR_BUILD_APP_FRAMEWORK 1)
1818

1919
include (../unit_common.cmake)
2020

21-
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
22-
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
23-
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
24-
endif ()
25-
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
26-
find_package(LLVM REQUIRED CONFIG)
27-
include_directories(${LLVM_INCLUDE_DIRS})
28-
add_definitions(${LLVM_DEFINITIONS})
29-
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
30-
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
31-
3221
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
3322

3423
include_directories (${CMAKE_CURRENT_SOURCE_DIR})

tests/unit/compilation/CMakeLists.txt

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@ set (WAMR_BUILD_AOT 1)
2020

2121
include (../unit_common.cmake)
2222

23-
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
24-
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
25-
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
26-
endif ()
27-
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
28-
find_package(LLVM REQUIRED CONFIG)
29-
include_directories(${LLVM_INCLUDE_DIRS})
30-
add_definitions(${LLVM_DEFINITIONS})
31-
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
32-
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
33-
3423
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
3524

3625
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
@@ -40,22 +29,11 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
4029
set (UNIT_SOURCE ${source_all})
4130

4231
set (unit_test_sources
43-
${UNIT_SOURCE}
44-
${WAMR_RUNTIME_LIB_SOURCE}
45-
${UNCOMMON_SHARED_SOURCE}
46-
${SRC_LIST}
47-
${PLATFORM_SHARED_SOURCE}
48-
${UTILS_SHARED_SOURCE}
49-
${MEM_ALLOC_SHARED_SOURCE}
50-
${LIB_HOST_AGENT_SOURCE}
51-
${NATIVE_INTERFACE_SOURCE}
52-
${LIBC_BUILTIN_SOURCE}
53-
${IWASM_COMMON_SOURCE}
54-
${IWASM_INTERP_SOURCE}
55-
${IWASM_AOT_SOURCE}
56-
${IWASM_COMPL_SOURCE}
57-
${WASM_APP_LIB_SOURCE_ALL}
58-
)
32+
${UNIT_SOURCE}
33+
${WAMR_RUNTIME_LIB_SOURCE}
34+
${IWASM_COMPL_SOURCE}
35+
${UNCOMMON_SHARED_SOURCE}
36+
)
5937

6038
# Now simply link against gtest or gtest_main as needed. Eg
6139
add_executable (compilation_test ${unit_test_sources})

tests/unit/custom-section/CMakeLists.txt

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ set (WAMR_BUILD_LOAD_CUSTOM_SECTION 1)
2222

2323
include (../unit_common.cmake)
2424

25-
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
26-
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
27-
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
28-
endif ()
29-
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
30-
find_package(LLVM REQUIRED CONFIG)
31-
include_directories(${LLVM_INCLUDE_DIRS})
32-
add_definitions(${LLVM_DEFINITIONS})
33-
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
34-
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
35-
3625
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
3726

3827
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
@@ -42,17 +31,10 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
4231
set (UNIT_SOURCE ${source_all})
4332

4433
set (unit_test_sources
45-
${UNIT_SOURCE}
46-
${PLATFORM_SHARED_SOURCE}
47-
${UTILS_SHARED_SOURCE}
48-
${MEM_ALLOC_SHARED_SOURCE}
49-
${NATIVE_INTERFACE_SOURCE}
50-
${IWASM_COMMON_SOURCE}
51-
${IWASM_INTERP_SOURCE}
52-
${IWASM_AOT_SOURCE}
53-
${IWASM_COMPL_SOURCE}
54-
${WASM_APP_LIB_SOURCE_ALL}
55-
)
34+
${UNIT_SOURCE}
35+
${WAMR_RUNTIME_LIB_SOURCE}
36+
${IWASM_COMPL_SOURCE}
37+
)
5638

5739
# Automatically build wasm-apps for this test
5840
add_subdirectory(wasm-apps)

tests/unit/gc/CMakeLists.txt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,9 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
2121
set (UNIT_SOURCE ${source_all})
2222

2323
set (unit_test_sources
24-
${UNIT_SOURCE}
25-
${WAMR_RUNTIME_LIB_SOURCE}
26-
${UNCOMMON_SHARED_SOURCE}
27-
${SRC_LIST}
28-
${PLATFORM_SHARED_SOURCE}
29-
${UTILS_SHARED_SOURCE}
30-
${MEM_ALLOC_SHARED_SOURCE}
31-
${LIB_HOST_AGENT_SOURCE}
32-
${NATIVE_INTERFACE_SOURCE}
33-
${LIBC_BUILTIN_SOURCE}
34-
${IWASM_COMMON_SOURCE}
35-
${IWASM_INTERP_SOURCE}
36-
${IWASM_AOT_SOURCE}
37-
${IWASM_COMPL_SOURCE}
38-
${WASM_APP_LIB_SOURCE_ALL}
24+
${UNIT_SOURCE}
25+
${WAMR_RUNTIME_LIB_SOURCE}
26+
${UNCOMMON_SHARED_SOURCE}
3927
)
4028

4129
add_executable (gc_test ${unit_test_sources})
@@ -48,4 +36,4 @@ add_custom_command(TARGET gc_test POST_BUILD
4836
COMMENT "Copy wasm files to directory ${CMAKE_CURRENT_BINARY_DIR}"
4937
)
5038

51-
#gtest_discover_tests(gc_test)
39+
gtest_discover_tests(gc_test)

tests/unit/interpreter/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
2424
set (UNIT_SOURCE ${source_all})
2525

2626
set (unit_test_sources
27-
${UNIT_SOURCE}
28-
${PLATFORM_SHARED_SOURCE}
29-
${UTILS_SHARED_SOURCE}
30-
${MEM_ALLOC_SHARED_SOURCE}
31-
${NATIVE_INTERFACE_SOURCE}
32-
${LIBC_BUILTIN_SOURCE}
33-
${IWASM_COMMON_SOURCE}
34-
${IWASM_INTERP_SOURCE}
35-
)
27+
${UNIT_SOURCE}
28+
${WAMR_RUNTIME_LIB_SOURCE}
29+
)
3630

3731
# Now simply link against gtest or gtest_main as needed. Eg
3832
add_executable (interpreter_test ${unit_test_sources})

tests/unit/libc-builtin/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ project (test-libc-builtin)
77

88
add_definitions (-DRUN_ON_LINUX)
99

10-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
11-
1210
set (WAMR_BUILD_LIBC_WASI 0)
1311
set (WAMR_BUILD_APP_FRAMEWORK 0)
1412

@@ -21,9 +19,9 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
2119
set (UNIT_SOURCE ${source_all})
2220

2321
set (unit_test_sources
24-
${UNIT_SOURCE}
25-
${WAMR_RUNTIME_LIB_SOURCE}
26-
)
22+
${UNIT_SOURCE}
23+
${WAMR_RUNTIME_LIB_SOURCE}
24+
)
2725

2826
add_executable (libc_builtin_test ${unit_test_sources})
2927

tests/unit/linear-memory-aot/CMakeLists.txt

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,11 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
2222
set (UNIT_SOURCE ${source_all})
2323

2424
set (unit_test_sources
25-
${UNIT_SOURCE}
26-
${WAMR_RUNTIME_LIB_SOURCE}
27-
${UNCOMMON_SHARED_SOURCE}
28-
${SRC_LIST}
29-
${PLATFORM_SHARED_SOURCE}
30-
${UTILS_SHARED_SOURCE}
31-
${MEM_ALLOC_SHARED_SOURCE}
32-
${LIB_HOST_AGENT_SOURCE}
33-
${NATIVE_INTERFACE_SOURCE}
34-
${LIBC_BUILTIN_SOURCE}
35-
${IWASM_COMMON_SOURCE}
36-
${IWASM_INTERP_SOURCE}
37-
${IWASM_AOT_SOURCE}
38-
${IWASM_COMPL_SOURCE}
39-
${WASM_APP_LIB_SOURCE_ALL}
25+
${UNIT_SOURCE}
26+
${WAMR_RUNTIME_LIB_SOURCE}
27+
${UNCOMMON_SHARED_SOURCE}
28+
${IWASM_COMPL_SOURCE}
29+
${WASM_APP_LIB_SOURCE_ALL}
4030
)
4131

4232
# Test case: .aot file with hardware bound check.

0 commit comments

Comments
 (0)