Skip to content

Commit 14d09bf

Browse files
authored
Fixed unit tests on X86_32 (#4279)
* fix unit tests on x86_32 * enbale wasm-c-api unit test on X86_32 * enable aot-stack-frame unit test on X86_32 * add ci: unit tests on X86_32
1 parent e48367c commit 14d09bf

File tree

4 files changed

+59
-24
lines changed

4 files changed

+59
-24
lines changed

.github/workflows/compilation_on_android_ubuntu.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ jobs:
315315
fail-fast: false
316316
matrix:
317317
os: [ubuntu-22.04]
318+
build_target: [
319+
"X86_64",
320+
"X86_32",
321+
]
318322
include:
319323
- os: ubuntu-22.04
320324
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
@@ -351,10 +355,16 @@ jobs:
351355
cmake --build . --config Release --parallel 4
352356
working-directory: wamr-compiler
353357

358+
- name: Install dependencies for X86_32
359+
if: matrix.build_target == 'X86_32'
360+
run: |
361+
sudo apt-get update
362+
sudo apt-get install -y g++-multilib
363+
354364
- name: Build and run unit tests
355365
run: |
356366
mkdir build && cd build
357-
cmake ..
367+
cmake .. -DWAMR_BUILD_TARGET=${{ matrix.build_target }}
358368
cmake --build . --config Release --parallel 4
359369
ctest
360370
working-directory: tests/unit

tests/unit/CMakeLists.txt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ include (FetchContent)
3232
FetchContent_Declare (
3333
googletest
3434
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
35+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
3536
)
3637
FetchContent_MakeAvailable (googletest)
3738

@@ -42,19 +43,27 @@ enable_testing()
4243

4344
add_subdirectory(wasm-vm)
4445
add_subdirectory(interpreter)
45-
add_subdirectory(aot)
4646
add_subdirectory(wasm-c-api)
4747
add_subdirectory(libc-builtin)
4848
add_subdirectory(shared-utils)
49-
add_subdirectory(running-modes)
50-
add_subdirectory(runtime-common)
51-
add_subdirectory(custom-section)
52-
add_subdirectory(compilation)
5349
add_subdirectory(linear-memory-wasm)
5450
add_subdirectory(linear-memory-aot)
5551
add_subdirectory(aot-stack-frame)
5652
add_subdirectory(linux-perf)
5753
add_subdirectory(gc)
58-
add_subdirectory(memory64)
5954
add_subdirectory(tid-allocator)
60-
add_subdirectory(shared-heap)
55+
56+
if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
57+
# should enable 32-bit llvm when X86_32
58+
add_subdirectory (aot)
59+
add_subdirectory (custom-section)
60+
add_subdirectory (compilation)
61+
62+
# Fast-JIT or mem64 is not supported on X86_32
63+
add_subdirectory (running-modes)
64+
add_subdirectory (memory64)
65+
add_subdirectory (shared-heap)
66+
67+
# HW_BOUND_CHECK is not supported on X86_32
68+
add_subdirectory (runtime-common)
69+
endif ()

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

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,37 @@ cmake_minimum_required(VERSION 3.14)
55

66
project(wasm-apps-aot-stack-frame)
77

8-
add_custom_target(aot-stack-frame-test-wasm ALL
9-
COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc
8+
set (WAMRC_OPTION --enable-dump-call-stack --bounds-checks=1 --enable-gc)
9+
10+
if (WAMR_BUILD_TARGET STREQUAL "X86_32")
11+
set (WAMRC_OPTION ${WAMRC_OPTION} --target=i386)
12+
endif ()
13+
14+
add_custom_target(
15+
aot-stack-frame-test-wasm ALL
16+
17+
# Step 1: Build wamrc
18+
COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc
1019
-S ${WAMR_ROOT_DIR}/wamr-compiler
11-
&& cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc
12-
&& /opt/wabt/bin/wat2wasm
13-
-o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm
14-
${CMAKE_CURRENT_LIST_DIR}/test.wast
15-
&& ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc
16-
--enable-dump-call-stack --bounds-checks=1 --enable-gc
17-
-o ${CMAKE_CURRENT_BINARY_DIR}/test.aot
18-
${CMAKE_CURRENT_BINARY_DIR}/test.wasm
19-
&& cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump
20+
COMMAND cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc
21+
22+
# Step 2: Compile .wast to .wasm
23+
COMMAND /opt/wabt/bin/wat2wasm
24+
-o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm ${CMAKE_CURRENT_LIST_DIR}/test.wast
25+
26+
# Step 3: Compile .wasm to .aot using wamrc
27+
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc ${WAMRC_OPTION}
28+
-o ${CMAKE_CURRENT_BINARY_DIR}/test.aot ${CMAKE_CURRENT_BINARY_DIR}/test.wasm
29+
30+
# Step 4: Build binarydump tool
31+
COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump
2032
-S ${WAMR_ROOT_DIR}/test-tools/binarydump-tool
21-
&& cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump
22-
&& ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump/binarydump
23-
-o ${CMAKE_CURRENT_LIST_DIR}/test_aot.h -n test_aot
24-
${CMAKE_CURRENT_BINARY_DIR}/test.aot
33+
COMMAND cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump
2534

35+
# Step 5: Generate .h file from .aot
36+
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump/binarydump
37+
-o ${CMAKE_CURRENT_LIST_DIR}/test_aot.h
38+
-n test_aot
39+
${CMAKE_CURRENT_BINARY_DIR}/test.aot
2640
)
2741

tests/unit/wasm-c-api/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
1313
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
1414

1515
# WAMR features switch
16-
set(WAMR_BUILD_TARGET "X86_64")
16+
if (NOT DEFINED WAMR_BUILD_TARGET)
17+
set(WAMR_BUILD_TARGET "X86_64")
18+
endif()
1719
set(WAMR_BUILD_INTERP 1)
1820
set(WAMR_BUILD_AOT 0)
1921
set(WAMR_BUILD_JIT 0)

0 commit comments

Comments
 (0)