Skip to content

Commit 380cd7b

Browse files
authored
Add unit test suites (#3490)
1 parent 0a80cc4 commit 380cd7b

File tree

194 files changed

+14106
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+14106
-36
lines changed

tests/unit/CMakeLists.txt

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
1-
# Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
cmake_minimum_required (VERSION 3.14)
4+
cmake_minimum_required(VERSION 2.9)
55

6-
project (wamr_unit_tests)
6+
project(unit-test)
77

8-
include (CTest)
8+
SET(CMAKE_BUILD_TYPE Debug)
99

10-
if (NOT DEFINED WAMR_BUILD_INTERP)
11-
# Enable Interpreter by default
12-
set (WAMR_BUILD_INTERP 1)
13-
endif ()
10+
# add_definitions (-m32)
11+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
12+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
1413

15-
if (NOT DEFINED WAMR_BUILD_PLATFORM)
16-
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
17-
endif ()
14+
if(WAMR_BUILD_TARGET STREQUAL "X86_32")
15+
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
16+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
17+
endif()
1818

19-
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
20-
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
21-
add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE})
19+
# Prevent overriding the parent project's compiler/linker
20+
# settings on Windows
21+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
2222

23+
# Fetch Google test
2324
include (FetchContent)
2425
FetchContent_Declare (
2526
googletest
2627
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
2728
)
28-
# For Windows: Prevent overriding the parent project's compiler/linker settings
29-
set (gtest_force_shared_crt ON CACHE BOOL "" FORCE)
3029
FetchContent_MakeAvailable (googletest)
3130

32-
include (GoogleTest)
33-
34-
add_library (wamr_gtest_main main.cpp)
35-
target_link_libraries (wamr_gtest_main PUBLIC gtest vmlib)
36-
37-
function (create_wamr_unit_test test_name)
38-
set (sources ${ARGN})
39-
add_executable (${test_name} ${sources})
40-
target_link_libraries (
41-
${test_name}
42-
wamr_gtest_main
43-
vmlib
44-
${LLVM_AVAILABLE_LIBS}
45-
)
46-
gtest_discover_tests (${test_name})
47-
endfunction ()
48-
49-
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
50-
include (${IWASM_DIR}/libraries/lib-wasi-threads/unit-test/lib_wasi_threads_unit_tests.cmake)
51-
endif ()
31+
SET(GOOGLETEST_INCLUDED 1)
32+
33+
include(GoogleTest)
34+
enable_testing()
35+
36+
add_subdirectory(wasm-vm)
37+
add_subdirectory(interpreter)
38+
add_subdirectory(aot)
39+
add_subdirectory(wasm-c-api)
40+
add_subdirectory(libc-builtin)
41+
add_subdirectory(shared-utils)
42+
add_subdirectory(running-modes)
43+
add_subdirectory(runtime-common)
44+
add_subdirectory(custom-section)
45+
add_subdirectory(compilation)
46+
add_subdirectory(linear-memory-wasm)
47+
add_subdirectory(linear-memory-aot)
48+
add_subdirectory(aot-stack-frame)
49+
add_subdirectory(linux-perf)
50+
add_subdirectory(gc)
51+
add_subdirectory(memory64)
52+
add_subdirectory(tid-allocator)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 2.9)
5+
6+
project (test-aot-stack-frame)
7+
8+
add_definitions (-DRUN_ON_LINUX)
9+
10+
set (WAMR_BUILD_AOT 1)
11+
set (WAMR_BUILD_INTERP 0)
12+
set (WAMR_BUILD_JIT 0)
13+
set (WAMR_BUILD_SIMD 1)
14+
set (WAMR_BUILD_REF_TYPES 1)
15+
set (WAMR_BUILD_LIBC_WASI 0)
16+
set (WAMR_BUILD_LIBC_BUILTIN 0)
17+
set (WAMR_BUILD_MULTI_MODULE 0)
18+
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
19+
set (WAMR_DISABLE_WRITE_GS_BASE 1)
20+
21+
include (../unit_common.cmake)
22+
23+
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
24+
25+
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
26+
add_definitions (-DAOT_STACK_FRAME_DEBUG)
27+
#add_definitions (-DWASM_ENABLE_DUMP_CALL_STACK=1)
28+
29+
file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
30+
31+
set (UNIT_SOURCE ${source_all})
32+
33+
set (unit_test_sources
34+
${UNIT_SOURCE}
35+
${PLATFORM_SHARED_SOURCE}
36+
${UTILS_SHARED_SOURCE}
37+
${MEM_ALLOC_SHARED_SOURCE}
38+
${NATIVE_INTERFACE_SOURCE}
39+
${IWASM_COMMON_SOURCE}
40+
${IWASM_INTERP_SOURCE}
41+
${IWASM_AOT_SOURCE}
42+
${WASM_APP_LIB_SOURCE_ALL}
43+
)
44+
45+
# Automatically build wasm-apps for this test
46+
add_subdirectory(wasm-apps)
47+
48+
# Now simply link against gtest or gtest_main as needed. Eg
49+
add_executable (aot_stack_frame_test ${unit_test_sources})
50+
51+
add_dependencies (aot_stack_frame_test aot-stack-frame-test-wasm)
52+
53+
target_link_libraries (aot_stack_frame_test ${LLVM_AVAILABLE_LIBS} gtest_main )
54+
55+
#gtest_discover_tests(aot_stack_frame_test)

0 commit comments

Comments
 (0)