瀏覽代碼

Enable Unit test on Mac(m1) (#4841)

- detecting host arch. and platform instead of hard-coding
- fix few compilation errors because of stricter rules involve by appleclang
- refactor: modernize wasm-apps CMakeLists.txt to target-specific options and install commands
- refactor: modernize memory64 CMakeLists.txt to target-specific options and install commands
- Update running-modes CMakeLists.txt: enable AOT and INTERP; JIT/FAST_JIT gating for x86_64. Fix typo in JIT section.
- fix: replace deprecated get_binary_path function with get_test_binary_dir for improved portability
- fix: adjust size_level test cases for aarch64 architecture compatibility
liang.he 1 天之前
父節點
當前提交
46472ee6c8
共有 30 個文件被更改,包括 276 次插入470 次删除
  1. 4 1
      .gitignore
  2. 39 4
      tests/unit/CMakeLists.txt
  3. 14 0
      tests/unit/common/test_helper.h
  4. 8 20
      tests/unit/compilation/aot_compiler_test.cc
  5. 1 18
      tests/unit/compilation/aot_emit_aot_file_test.cc
  6. 1 18
      tests/unit/compilation/aot_emit_control_test.cc
  7. 1 18
      tests/unit/compilation/aot_emit_function_test.cc
  8. 1 18
      tests/unit/compilation/aot_emit_memory_test.cc
  9. 1 18
      tests/unit/compilation/aot_emit_numberic_test.cc
  10. 1 18
      tests/unit/compilation/aot_emit_parametric_test.cc
  11. 1 18
      tests/unit/compilation/aot_emit_table_test.cc
  12. 1 18
      tests/unit/compilation/aot_llvm_test.cc
  13. 2 18
      tests/unit/gc/gc_test.cc
  14. 33 6
      tests/unit/linear-memory-aot/build_aot.sh
  15. 1 18
      tests/unit/linear-memory-aot/linear_memory_aot_test.cc
  16. 1 18
      tests/unit/linear-memory-wasm/linear_memory_wasm_test.cc
  17. 0 5
      tests/unit/linux-perf/CMakeLists.txt
  18. 3 9
      tests/unit/linux-perf/test_sort_func_ptrs.cc
  19. 6 2
      tests/unit/running-modes/CMakeLists.txt
  20. 1 17
      tests/unit/running-modes/wasm_running_modes_test.cc
  21. 1 18
      tests/unit/runtime-common/wasm_runtime_common_test.cc
  22. 1 18
      tests/unit/runtime-common/wasm_runtime_init_test.cc
  23. 25 5
      tests/unit/shared-heap/CMakeLists.txt
  24. 1 0
      tests/unit/shared-heap/shared_heap_test.cc
  25. 50 88
      tests/unit/shared-heap/wasm-apps/CMakeLists.txt
  26. 40 0
      tests/unit/shared-heap/wasm-apps/bulk-memory/CMakeLists.txt
  27. 38 57
      tests/unit/shared-heap/wasm-apps/memory64/CMakeLists.txt
  28. 0 4
      tests/unit/tid-allocator/CMakeLists.txt
  29. 0 16
      tests/unit/unit_common.cmake
  30. 0 2
      tests/unit/wasm-c-api/CMakeLists.txt

+ 4 - 1
.gitignore

@@ -40,4 +40,7 @@ tests/benchmarks/coremark/coremark*
 samples/workload/include/**
 !samples/workload/include/.gitkeep
 
-# core/iwasm/libraries/wasi-threads
+# core/iwasm/libraries/wasi-threads
+
+tests/unit/runtime-common/wasm-apps/main.aot
+tests/unit/aot-stack-frame/wasm-apps/test_aot.h

+ 39 - 4
tests/unit/CMakeLists.txt

@@ -14,7 +14,30 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
 
 SET(CMAKE_BUILD_TYPE Debug)
 
-# add_definitions (-m32)
+set(CMAKE_CXX_STANDARD 17)
+
+#TODO: modularization me
+# Detect Hosting target info
+string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
+# Set WAMR_BUILD_TARGET, currently values supported:
+# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
+# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
+if (NOT DEFINED WAMR_BUILD_TARGET)
+  if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
+    set (WAMR_BUILD_TARGET "AARCH64")
+  elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
+    set (WAMR_BUILD_TARGET "RISCV64")
+  elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
+    # Build as X86_64 by default in 64-bit platform
+    set (WAMR_BUILD_TARGET "X86_64")
+  elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
+    # Build as X86_32 by default in 32-bit platform
+    set (WAMR_BUILD_TARGET "X86_32")
+  else ()
+    message(SEND_ERROR "Unsupported build target platform!")
+  endif ()
+endif ()
+
 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
 
@@ -66,8 +89,9 @@ add_subdirectory(tid-allocator)
 add_subdirectory(unsupported-features)
 add_subdirectory(smart-tests)
 add_subdirectory(exception-handling)
+add_subdirectory(running-modes)
 
-if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
+if(WAMR_BUILD_TARGET STREQUAL "X86_64")
   add_subdirectory(aot-stack-frame)
 
   # should enable 32-bit llvm when X86_32
@@ -75,11 +99,22 @@ if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
   add_subdirectory (custom-section)
   add_subdirectory (compilation)
 
-  # Fast-JIT or mem64 is not supported on X86_32
-  add_subdirectory (running-modes)
   add_subdirectory (memory64)
   add_subdirectory (shared-heap)
 
   # HW_BOUND_CHECK is not supported on X86_32
+  add_subdirectory (runtime-common)
+endif()
+
+if(WAMR_BUILD_TARGET STREQUAL "AARCH64")
+  add_subdirectory(aot-stack-frame)
+
+  add_subdirectory (aot)
+  add_subdirectory (custom-section)
+  add_subdirectory (compilation)
+
+  add_subdirectory (memory64)
+  add_subdirectory (shared-heap)
+
   add_subdirectory (runtime-common)
 endif ()

+ 14 - 0
tests/unit/common/test_helper.h

@@ -11,6 +11,20 @@
 #include <iostream>
 #include <memory>
 #include <fstream>
+#include <limits.h>
+#include <string>
+#include <unistd.h>
+
+static inline std::string
+get_test_binary_dir()
+{
+    char cwd[PATH_MAX] = { 0 };
+    if (!getcwd(cwd, sizeof(cwd))) {
+        return std::string();
+    }
+
+    return std::string(cwd);
+}
 
 template<int Size = 512 * 1024>
 class WAMRRuntimeRAII

+ 8 - 20
tests/unit/compilation/aot_compiler_test.cc

@@ -14,23 +14,6 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 extern "C" {
 char *
 aot_generate_tempfile_name(const char *prefix, const char *extension,
@@ -50,7 +33,7 @@ class aot_compiler_test_suit : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
     }
 
@@ -117,8 +100,13 @@ TEST_F(aot_compiler_test_suit, aot_emit_object_file)
 
     // Test size_level in range from 0 to 3.
     option.opt_level = 3;
-    for (i = 0; i <= 3; i++) {
-        option.size_level = i;
+#if defined(__aarch64__) || defined(_M_ARM64)
+    std::vector<int> size_levels = { 0, 3 };
+#else
+    std::vector<int> size_levels = { 0, 1, 2, 3 };
+#endif
+    for (auto size_level : size_levels) {
+        option.size_level = size_level;
         test_aot_emit_object_file_with_option(&option);
     }
 

+ 1 - 18
tests/unit/compilation/aot_emit_aot_file_test.cc

@@ -14,23 +14,6 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 extern "C" {
 uint8 *
 aot_emit_aot_file_buf(AOTCompContext *comp_ctx, AOTCompData *comp_data,
@@ -50,7 +33,7 @@ class aot_emit_aot_file_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
     }
 

+ 1 - 18
tests/unit/compilation/aot_emit_control_test.cc

@@ -15,23 +15,6 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class aot_emit_control_test_suite : public testing::Test
 {
   protected:
@@ -45,7 +28,7 @@ class aot_emit_control_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
     }
 

+ 1 - 18
tests/unit/compilation/aot_emit_function_test.cc

@@ -14,23 +14,6 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class aot_emit_function_test_suite : public testing::Test
 {
   protected:
@@ -44,7 +27,7 @@ class aot_emit_function_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
     }
 

+ 1 - 18
tests/unit/compilation/aot_emit_memory_test.cc

@@ -16,29 +16,12 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class compilation_aot_emit_memory_test : public testing::Test
 {
   protected:
     void SetUp() override
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
         AOTCompOption option = { 0 };
 

+ 1 - 18
tests/unit/compilation/aot_emit_numberic_test.cc

@@ -15,23 +15,6 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class aot_emit_numberic_test_suite : public testing::Test
 {
   protected:
@@ -45,7 +28,7 @@ class aot_emit_numberic_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
     }
 

+ 1 - 18
tests/unit/compilation/aot_emit_parametric_test.cc

@@ -14,23 +14,6 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class aot_emit_parametric_test_suite : public testing::Test
 {
   protected:
@@ -44,7 +27,7 @@ class aot_emit_parametric_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
     }
 

+ 1 - 18
tests/unit/compilation/aot_emit_table_test.cc

@@ -14,23 +14,6 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class aot_emit_table_test_suite : public testing::Test
 {
   protected:
@@ -44,7 +27,7 @@ class aot_emit_table_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
     }
 

+ 1 - 18
tests/unit/compilation/aot_llvm_test.cc

@@ -14,23 +14,6 @@ static std::string CWD;
 static std::string MAIN_WASM = "/main.wasm";
 static char *WASM_FILE;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class aot_llvm_test_suite : public testing::Test
 {
   protected:
@@ -44,7 +27,7 @@ class aot_llvm_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE = strdup((CWD + MAIN_WASM).c_str());
     }
 

+ 2 - 18
tests/unit/gc/gc_test.cc

@@ -3,6 +3,7 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
+#include "test_helper.h"
 #include "gtest/gtest.h"
 #include "bh_platform.h"
 #include "bh_read_file.h"
@@ -10,27 +11,10 @@
 
 class WasmGCTest : public testing::Test
 {
-  private:
-    std::string get_binary_path()
-    {
-        char cwd[1024] = { 0 };
-
-        if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-            return NULL;
-        }
-
-        char *path_end = strrchr(cwd, '/');
-        if (path_end != NULL) {
-            *path_end = '\0';
-        }
-
-        return std::string(cwd);
-    }
-
   protected:
     void SetUp()
     {
-        CWD = get_binary_path();
+                CWD = get_test_binary_dir();
 
         memset(&init_args, 0, sizeof(RuntimeInitArgs));
 

+ 33 - 6
tests/unit/linear-memory-aot/build_aot.sh

@@ -31,15 +31,42 @@ if [ ! -s "$WAST2WASM" ]; then
     echo "please install wabt first" && exit -1
 fi
 
+# Detect host architecture
+HOST_ARCH=$(uname -m)
+echo "Detected host architecture: $HOST_ARCH"
+
 # Iterate over the files array
-rm -r build 
+rm -r build 2>/dev/null
 mkdir build
 for file_name in "${file_names[@]}"; do
     # wast to wasm
     $WAST2WASM "${file_name}.wast" -o "build/${file_name}.wasm"
-    # compile the aot files, x86-64, x86-32, no_hw_bounds, no_hw_bounds_x32
-    $WAMRC -o "build/${file_name}.aot" "build/${file_name}.wasm"
-    $WAMRC --target=i386 -o "build/${file_name}_32.aot" "build/${file_name}.wasm"
-    $WAMRC --bounds-checks=1 -o "build/${file_name}_no_hw_bounds.aot" "build/${file_name}.wasm"
-    $WAMRC --bounds-checks=1 --target=i386 -o "build/${file_name}_no_hw_bounds_32.aot" "build/${file_name}.wasm"
+    
+    # Determine compilation configurations based on host architecture
+    case "$HOST_ARCH" in
+        x86_64)
+            # x86-64 host: compile both x86-64 and x86-32
+            $WAMRC -o "build/${file_name}.aot" "build/${file_name}.wasm"
+            $WAMRC --target=i386 -o "build/${file_name}_32.aot" "build/${file_name}.wasm"
+            $WAMRC --bounds-checks=1 -o "build/${file_name}_no_hw_bounds.aot" "build/${file_name}.wasm"
+            $WAMRC --bounds-checks=1 --target=i386 -o "build/${file_name}_no_hw_bounds_32.aot" "build/${file_name}.wasm"
+            ;;
+        i386|i686)
+            # x86-32 host: compile only x86-32
+            $WAMRC -o "build/${file_name}.aot" "build/${file_name}.wasm"
+            $WAMRC --bounds-checks=1 -o "build/${file_name}_no_hw_bounds.aot" "build/${file_name}.wasm"
+            ;;
+        aarch64|arm64)
+            # ARM64 host: compile only aarch64
+            $WAMRC  -o "build/${file_name}.aot" "build/${file_name}.wasm"
+            $WAMRC  --bounds-checks=1 -o "build/${file_name}_no_hw_bounds.aot" "build/${file_name}.wasm"
+            ;;
+        *)
+            echo "Warning: Unsupported architecture '$HOST_ARCH'. Using default target."
+            $WAMRC -o "build/${file_name}.aot" "build/${file_name}.wasm"
+            $WAMRC --bounds-checks=1 -o "build/${file_name}_no_hw_bounds.aot" "build/${file_name}.wasm"
+            ;;
+    esac
 done
+
+echo "AOT compilation completed for architecture: $HOST_ARCH"

+ 1 - 18
tests/unit/linear-memory-aot/linear_memory_aot_test.cc

@@ -11,23 +11,6 @@
 
 static std::string CWD;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 #if WASM_DISABLE_HW_BOUND_CHECK != 0
 #define TEST_SUITE_NAME linear_memory_test_suite_aot_no_hw_bound
 #else
@@ -45,7 +28,7 @@ class TEST_SUITE_NAME : public testing::Test
     // Otherwise, this can be skipped.
     virtual void SetUp() {}
 
-    static void SetUpTestCase() { CWD = get_binary_path(); }
+    static void SetUpTestCase() { CWD = get_test_binary_dir(); }
 
     // virtual void TearDown() will be called after each test is run.
     // You should define it if there is cleanup work to do.  Otherwise,

+ 1 - 18
tests/unit/linear-memory-wasm/linear_memory_wasm_test.cc

@@ -11,23 +11,6 @@
 
 static std::string CWD;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 #if WASM_DISABLE_HW_BOUND_CHECK != 0
 #define TEST_SUITE_NAME linear_memory_test_suite_wasm_no_hw_bound
 #else
@@ -45,7 +28,7 @@ class TEST_SUITE_NAME : public testing::Test
     // Otherwise, this can be skipped.
     virtual void SetUp() {}
 
-    static void SetUpTestCase() { CWD = get_binary_path(); }
+    static void SetUpTestCase() { CWD = get_test_binary_dir(); }
 
     // virtual void TearDown() will be called after each test is run.
     // You should define it if there is cleanup work to do.  Otherwise,

+ 0 - 5
tests/unit/linux-perf/CMakeLists.txt

@@ -32,9 +32,4 @@ include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
 add_executable (linux_perf_test test_sort_func_ptrs.cc)
 target_compile_options(linux_perf_test PUBLIC -fpermissive)
 target_link_libraries(linux_perf_test ${LLVM_AVAILABLE_LIBS} gtest_main )
-target_link_options(linux_perf_test
-  PUBLIC
-    LINKER:--unresolved-symbols=ignore-all
-)
-
 gtest_discover_tests(linux_perf_test)

+ 3 - 9
tests/unit/linux-perf/test_sort_func_ptrs.cc

@@ -33,7 +33,7 @@ sort_func_ptrs(const AOTModule *module, char *error_buf, uint32 error_buf_size)
     unsigned i;
 
     content_len = (uint64)sizeof(struct func_info) * module->func_count;
-    sorted_func_ptrs = wasm_runtime_malloc(content_len);
+    sorted_func_ptrs = (struct func_info *)wasm_runtime_malloc(content_len);
     if (!sorted_func_ptrs) {
         snprintf(error_buf, error_buf_size,
                  "allocate memory failed when creating perf map");
@@ -63,23 +63,17 @@ wasm_runtime_free(void* ptr)
     return free(ptr);
 }
 
-int
-b_memcpy_s(void *s1, unsigned int s1max, const void *s2, unsigned int n)
-{
-    return memcpy(s1, s2, n);
-}
 }
 
 TEST(TestSortFuncPtrs, qsort)
 {
-    void *p = sort_func_ptrs;
-    ASSERT_NE(p, nullptr);
+    ASSERT_NE(sort_func_ptrs, nullptr);
 
     void *funcs[5] = {
         (void *)0x1024, (void *)0x10, (void *)0x24, (void *)0x102, (void *)0x4,
     };
 
-    AOTModule module = { 0 };
+    AOTModule module = {};
     module.func_count = 5;
     module.func_ptrs = &funcs[0];
 

+ 6 - 2
tests/unit/running-modes/CMakeLists.txt

@@ -26,8 +26,12 @@ set(WAMR_BUILD_LIBC_BUILTIN 1)
 set(WAMR_BUILD_MULTI_MODULE 0)
 set(WAMR_BUILD_LIBC_WASI 1)
 set(WAMR_BUILD_APP_FRAMEWORK 0)
-set(WAMR_BUILD_JIT 1)
-set(WAMR_BUILD_FAST_JIT 1)
+set(WAMR_BUILD_AOT 1)
+set(WAMR_BUILD_INTERP 1)
+if(WAMR_BUILD_TARGET STREQUAL "x86_64")
+  set(WAMR_BUILD_JIT 1)
+  sset(WAMR_BUILD_FAST_JIT 1)
+endif()
 set(WAMR_BUILD_REF_TYPES 1)
 
 # if only load this CMake other than load it as subdirectory

+ 1 - 17
tests/unit/running-modes/wasm_running_modes_test.cc

@@ -39,22 +39,6 @@ std::vector<RunningMode> running_mode_supported = { Mode_Interp,
 class wasm_running_modes_test_suite : public testing::TestWithParam<RunningMode>
 {
   private:
-    std::string get_binary_path()
-    {
-        char cwd[1024];
-        memset(cwd, 0, 1024);
-
-        if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-        }
-
-        char *path_end = strrchr(cwd, '/');
-        if (path_end != NULL) {
-            *path_end = '\0';
-        }
-
-        return std::string(cwd);
-    }
-
     bool load_wasm_file(const char *wasm_file)
     {
         const char *file;
@@ -199,7 +183,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam<RunningMode>
     // Otherwise, this can be skipped.
     virtual void SetUp()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE_1 = strdup((CWD + TEST_WASM1).c_str());
         WASM_FILE_2 = strdup((CWD + TEST_WASM2).c_str());
 

+ 1 - 18
tests/unit/runtime-common/wasm_runtime_common_test.cc

@@ -36,23 +36,6 @@ static std::string MAIN_AOT = "/main.aot";
 static char *WASM_FILE_1;
 static char *AOT_FILE_1;
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class wasm_runtime_common_test_suite : public testing::Test
 {
   protected:
@@ -66,7 +49,7 @@ class wasm_runtime_common_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE_1 = strdup((CWD + MAIN_WASM).c_str());
         AOT_FILE_1 = strdup((CWD + MAIN_AOT).c_str());
     }

+ 1 - 18
tests/unit/runtime-common/wasm_runtime_init_test.cc

@@ -48,23 +48,6 @@ static NativeSymbol native_symbols[] = { {
     "(ii)i"             // the function prototype signature
 } };
 
-static std::string
-get_binary_path()
-{
-    char cwd[1024];
-    memset(cwd, 0, 1024);
-
-    if (readlink("/proc/self/exe", cwd, 1024) <= 0) {
-    }
-
-    char *path_end = strrchr(cwd, '/');
-    if (path_end != NULL) {
-        *path_end = '\0';
-    }
-
-    return std::string(cwd);
-}
-
 class wasm_runtime_init_test_suite : public testing::Test
 {
   protected:
@@ -78,7 +61,7 @@ class wasm_runtime_init_test_suite : public testing::Test
 
     static void SetUpTestCase()
     {
-        CWD = get_binary_path();
+        CWD = get_test_binary_dir();
         WASM_FILE_1 = strdup((CWD + MAIN_WASM).c_str());
         AOT_FILE_1 = strdup((CWD + MAIN_AOT).c_str());
     }

+ 25 - 5
tests/unit/shared-heap/CMakeLists.txt

@@ -16,14 +16,34 @@ set(WAMR_BUILD_MEMORY64 0)
 set(WAMR_BUILD_SHARED_HEAP 1)
 
 # Compile wasm modules
-add_subdirectory(wasm-apps)
+set(WASI_SDK_DIR "/opt/wasi-sdk")
+set(WASISDK_TOOLCHAIN "${WASI_SDK_DIR}/share/cmake/wasi-sdk.cmake")
 
-if (WAMR_BUILD_MEMORY64 EQUAL 1)
-   add_subdirectory(wasm-apps/memory64)
-endif ()
+include(ExternalProject)
+ExternalProject_Add(
+  shared_heap_wasm_apps
+  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps
+  BUILD_ALWAYS YES
+  CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps -B build
+                      -DWASI_SDK_PREFIX=${WASI_SDK_DIR}
+                      -DCMAKE_TOOLCHAIN_FILE=${WASISDK_TOOLCHAIN}
+  BUILD_COMMAND     ${CMAKE_COMMAND} --build build
+  INSTALL_COMMAND   ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+ExternalProject_Add(
+  shared_heap_wasm_apps_bulk_memory
+  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps/bulk-memory
+  BUILD_ALWAYS YES
+  CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps/bulk-memory -B build
+                      -DWASI_SDK_PREFIX=${WASI_SDK_DIR}
+                      -DCMAKE_TOOLCHAIN_FILE=${WASISDK_TOOLCHAIN}
+  BUILD_COMMAND     ${CMAKE_COMMAND} --build build
+  INSTALL_COMMAND   ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR}
+)
 
 # if only load this CMake other than load it as subdirectory
-include(../unit_common.cmake)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../unit_common.cmake)
 
 include(${IWASM_DIR}/compilation/iwasm_compl.cmake)
 

+ 1 - 0
tests/unit/shared-heap/shared_heap_test.cc

@@ -3,6 +3,7 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
+#include "platform_internal.h"
 #include "test_helper.h"
 #include "gtest/gtest.h"
 

+ 50 - 88
tests/unit/shared-heap/wasm-apps/CMakeLists.txt

@@ -5,105 +5,67 @@ cmake_minimum_required(VERSION 3.14)
 project(wasm-apps)
 
 set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
-set(WAMRC_ROOT_DIR ${WAMR_ROOT_DIR}/wamr-compiler/build)
 
-set(CMAKE_SYSTEM_PROCESSOR wasm32)
-set(CMAKE_SYSROOT ${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot)
-
-if (NOT DEFINED WASI_SDK_DIR)
-    set(WASI_SDK_DIR "/opt/wasi-sdk")
-endif ()
-
-set(CMAKE_C_FLAGS "-nostdlib -pthread -Qunused-arguments")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -z stack-size=8192 -nostdlib -O0")
-set(CMAKE_C_COMPILER_TARGET "wasm32")
-set(CMAKE_C_COMPILER "${WASI_SDK_DIR}/bin/clang")
-
-set(DEFINED_SYMBOLS
-        "${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt")
-
-set(CMAKE_EXE_LINKER_FLAGS
-        "-Wl,--no-entry           \
-      -Wl,--initial-memory=65536  \
-      -Wl,--export-all            \
-      -Wl,--allow-undefined"
-        )
+# Find WAMRC
+set(WAMRC_ROOT_DIR ${WAMR_ROOT_DIR}/wamr-compiler)
+find_program(WAMRC_BIN wamrc HINTS ${WAMRC_ROOT_DIR}/build REQUIRED)
 
+# Set architecture-specific WAMRC flags
 if (WAMR_BUILD_TARGET STREQUAL "X86_32")
-  set (WAMR_COMPILER_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap --target=i386)
-  set (WAMR_COMPILER_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain --target=i386)
+  set(WAMRC_SHARED_HEAP_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap --target=i386)
+  set(WAMRC_SHARED_HEAP_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain --target=i386)
 else ()
-  set (WAMR_COMPILER_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap)
-  set (WAMR_COMPILER_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain)
+  set(WAMRC_SHARED_HEAP_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap)
+  set(WAMRC_SHARED_HEAP_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain)
 endif ()
 
-function(copy_wasm TARGET_NAME)
-    add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
-        COMMAND ${CMAKE_COMMAND} -E copy
-                ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
-                ${CMAKE_CURRENT_BINARY_DIR}/../
-        COMMENT "Copy ${TARGET_NAME} to the same directory of google test"
-    )
-endfunction()
-
-function(compile_and_copy_aot_from TARGET_NAME)
-    string(REPLACE ".wasm" ".aot" AOT_TARGET ${TARGET_NAME})
-    string(REPLACE ".wasm" "_chain.aot" AOT_CHAIN_TARGET ${TARGET_NAME})
-
-    add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
-        COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_FLAGS}
-                -o ${AOT_TARGET}
-                ${TARGET_NAME}
-        COMMAND ${CMAKE_COMMAND} -E copy
-                ${CMAKE_CURRENT_BINARY_DIR}/${AOT_TARGET}
-                ${CMAKE_CURRENT_BINARY_DIR}/../
-        COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_CHAIN_FLAGS}
-                -o ${AOT_CHAIN_TARGET}
-                ${TARGET_NAME}
-        COMMAND ${CMAKE_COMMAND} -E copy
-                ${CMAKE_CURRENT_BINARY_DIR}/${AOT_CHAIN_TARGET}
-                ${CMAKE_CURRENT_BINARY_DIR}/../
-        COMMENT "Compile and copy ${AOT_TARGET} to the same directory of google test"
-    )
-endfunction()
-
+#
+# C -> Wasm
+#
 add_executable(test.wasm test.c)
-target_link_libraries(test.wasm)
-copy_wasm(test.wasm)
-compile_and_copy_aot_from(test.wasm)
+target_compile_options(test.wasm PUBLIC -nostdlib -O0 -pthread)
+target_link_options(test.wasm PRIVATE
+  -nostdlib
+  LINKER:--no-entry
+  LINKER:--initial-memory=65536
+  LINKER:--allow-undefined
+  LINKER:--export-all
+  -z stack-size=1024
+)
 
 add_executable(test_addr_conv.wasm test_addr_conv.c)
-target_link_libraries(test_addr_conv.wasm)
-copy_wasm(test_addr_conv.wasm)
-compile_and_copy_aot_from(test_addr_conv.wasm)
-
-# copy and compile aot for bulk memory test
-set(SOURCE_WASM ${CMAKE_CURRENT_SOURCE_DIR}/bulk-memory/test_bulk_memory.wasm)
-set(BUILD_WASM ${CMAKE_CURRENT_BINARY_DIR}/../test_bulk_memory.wasm)
-set(OUTPUT_AOT ${CMAKE_CURRENT_BINARY_DIR}/../test_bulk_memory.aot)
-set(OUTPUT_CHAIN_AOT ${CMAKE_CURRENT_BINARY_DIR}/../test_bulk_memory_chain.aot)
-
-add_custom_command(
-    OUTPUT ${BUILD_WASM}
-    COMMAND ${CMAKE_COMMAND} -E copy 
-            ${SOURCE_WASM}
-            ${BUILD_WASM}   
-    DEPENDS ${SOURCE_WASM}
-    COMMENT "Copying bulk memory WASM to build directory"
+target_compile_options(test_addr_conv.wasm PUBLIC -nostdlib -O0 -pthread)
+target_link_options(test_addr_conv.wasm PRIVATE
+  -nostdlib
+  LINKER:--no-entry
+  LINKER:--initial-memory=65536
+  LINKER:--allow-undefined
+  LINKER:--export-all
+  -z stack-size=1024
 )
 
-add_custom_command(
-    OUTPUT ${OUTPUT_AOT}
-    COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_FLAGS}
-            -o ${OUTPUT_AOT} 
-            ${BUILD_WASM}
-    COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_CHAIN_FLAGS}
-            -o ${OUTPUT_CHAIN_AOT} 
-            ${BUILD_WASM}
-    DEPENDS ${BUILD_WASM}
-    COMMENT "Compiling bulk memory AOT from copied WASM"
+# Compile AOT files (combined target)
+add_custom_target(compile_aot ALL
+  COMMAND ${WAMRC_BIN} ${WAMRC_SHARED_HEAP_FLAGS} -o test.aot test.wasm
+  COMMAND ${WAMRC_BIN} ${WAMRC_SHARED_HEAP_CHAIN_FLAGS} -o test_chain.aot test.wasm
+  COMMAND ${WAMRC_BIN} ${WAMRC_SHARED_HEAP_FLAGS} -o test_addr_conv.aot test_addr_conv.wasm
+  COMMAND ${WAMRC_BIN} ${WAMRC_SHARED_HEAP_CHAIN_FLAGS} -o test_addr_conv_chain.aot test_addr_conv.wasm
+  DEPENDS test.wasm test_addr_conv.wasm
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 )
 
-add_custom_target(compile_bulk_memory_aot ALL
-    DEPENDS ${OUTPUT_AOT}
+# Install WASM files
+set(WASM_FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/test.wasm
+  ${CMAKE_CURRENT_BINARY_DIR}/test_addr_conv.wasm
+)
+install(FILES ${WASM_FILES} DESTINATION .)
+
+# Install AOT files
+set(AOT_FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/test.aot
+  ${CMAKE_CURRENT_BINARY_DIR}/test_chain.aot
+  ${CMAKE_CURRENT_BINARY_DIR}/test_addr_conv.aot
+  ${CMAKE_CURRENT_BINARY_DIR}/test_addr_conv_chain.aot
 )
+install(FILES ${AOT_FILES} DESTINATION .)

+ 40 - 0
tests/unit/shared-heap/wasm-apps/bulk-memory/CMakeLists.txt

@@ -0,0 +1,40 @@
+# Copyright (C) 2024 Xiaomi Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+cmake_minimum_required(VERSION 3.14)
+project(wasm-apps-bulk-memory)
+
+# Find WAMRC
+set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)
+set(WAMRC_ROOT_DIR ${WAMR_ROOT_DIR}/wamr-compiler)
+find_program(WAMRC_BIN wamrc HINTS ${WAMRC_ROOT_DIR}/build REQUIRED)
+
+# Set architecture-specific WAMRC flags
+if (WAMR_BUILD_TARGET STREQUAL "X86_32")
+  set(WAMRC_SHARED_HEAP_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap --target=i386)
+  set(WAMRC_SHARED_HEAP_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain --target=i386)
+else ()
+  set(WAMRC_SHARED_HEAP_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap)
+  set(WAMRC_SHARED_HEAP_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain)
+endif ()
+
+# Compile AOT files (combined target)
+add_custom_target(compile_aot ALL
+  COMMAND ${WAMRC_BIN} ${WAMRC_SHARED_HEAP_FLAGS} -o test_bulk_memory.aot ${CMAKE_CURRENT_SOURCE_DIR}/test_bulk_memory.wasm
+  COMMAND ${WAMRC_BIN} ${WAMRC_SHARED_HEAP_CHAIN_FLAGS} -o test_bulk_memory_chain.aot ${CMAKE_CURRENT_SOURCE_DIR}/test_bulk_memory.wasm
+  DEPENDS test_bulk_memory.wasm
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+# Install WASM file
+set(WASM_FILES
+  ${CMAKE_CURRENT_SOURCE_DIR}/test_bulk_memory.wasm
+)
+install(FILES ${WASM_FILES} DESTINATION .)
+
+# Install AOT files
+set(AOT_FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/test_bulk_memory.aot
+  ${CMAKE_CURRENT_BINARY_DIR}/test_bulk_memory_chain.aot
+)
+install(FILES ${AOT_FILES} DESTINATION .)

+ 38 - 57
tests/unit/shared-heap/wasm-apps/memory64/CMakeLists.txt

@@ -5,64 +5,45 @@ cmake_minimum_required(VERSION 3.14)
 project(wasm-apps-wasm64)
 
 set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)
-set(WAMRC_ROOT_DIR ${WAMR_ROOT_DIR}/wamr-compiler/build)
 
-set(CMAKE_SYSTEM_PROCESSOR wasm64)
-set(CMAKE_SYSROOT ${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot)
+# Find WAMRC
+set(WAMRC_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
+find_program(WAMRC_BIN wamrc HINTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../../wamr-compiler/build REQUIRED)
 
-if (NOT DEFINED WASI_SDK_DIR)
-    set(WASI_SDK_DIR "/opt/wasi-sdk")
-endif ()
-
-set(CMAKE_C_FLAGS "-nostdlib -pthread -Qunused-arguments")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -z stack-size=8192 -nostdlib -O0 --target=wasm64")
-set(CMAKE_C_COMPILER_TARGET "wasm64")
-set(CMAKE_C_COMPILER "${WASI_SDK_DIR}/bin/clang")
-
-set(DEFINED_SYMBOLS
-        "${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt")
-
-set(CMAKE_EXE_LINKER_FLAGS
-        "-Wl,--no-entry           \
-      -Wl,--initial-memory=65536  \
-      -Wl,--export-all            \
-      -Wl,--allow-undefined"
-        )
-
-set (WAMR_COMPILER_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap)
-set (WAMR_COMPILER_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain)
-
-function(copy_wasm TARGET_NAME)
-    add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
-        COMMAND ${CMAKE_COMMAND} -E copy
-                ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
-                ${CMAKE_CURRENT_BINARY_DIR}/../../
-        COMMENT "Copy ${TARGET_NAME} to the same directory of google test"
-    )
-endfunction()
-
-function(compile_and_copy_aot_from TARGET_NAME)
-    string(REPLACE ".wasm" ".aot" AOT_TARGET ${TARGET_NAME})
-    string(REPLACE ".wasm" "_chain.aot" AOT_CHAIN_TARGET ${TARGET_NAME})
-
-    add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
-        COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_FLAGS}
-                -o ${AOT_TARGET}
-                ${TARGET_NAME}
-        COMMAND ${CMAKE_COMMAND} -E copy
-                ${CMAKE_CURRENT_BINARY_DIR}/${AOT_TARGET}
-                ${CMAKE_CURRENT_BINARY_DIR}/../../
-        COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_CHAIN_FLAGS}
-                -o ${AOT_CHAIN_TARGET}
-                ${TARGET_NAME}
-        COMMAND ${CMAKE_COMMAND} -E copy
-                ${CMAKE_CURRENT_BINARY_DIR}/${AOT_CHAIN_TARGET}
-                ${CMAKE_CURRENT_BINARY_DIR}/../../
-        COMMENT "Compile and copy ${AOT_TARGET} ${AOT_CHAIN_TARGET} to the same directory of google test"
-    )
-endfunction()
+# Set WAMRC flags for memory64
+set(WAMRC_SHARED_HEAP_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap)
+set(WAMRC_SHARED_HEAP_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain)
 
+#
+# C -> Wasm
+#
 add_executable(test64.wasm ../test.c)
-target_link_libraries(test64.wasm)
-copy_wasm(test64.wasm)
-compile_and_copy_aot_from(test64.wasm)
+target_compile_options(test64.wasm PUBLIC -nostdlib -O0 -pthread --target=wasm64)
+target_link_options(test64.wasm PRIVATE
+  -nostdlib
+  LINKER:--no-entry
+  LINKER:--initial-memory=65536
+  LINKER:--export-all
+  LINKER:--allow-undefined
+)
+
+# Compile AOT files (combined target)
+add_custom_target(compile_aot ALL
+  COMMAND ${WAMRC_BIN} ${WAMRC_SHARED_HEAP_FLAGS} -o test64.aot test64.wasm
+  COMMAND ${WAMRC_BIN} ${WAMRC_SHARED_HEAP_CHAIN_FLAGS} -o test64_chain.aot test64.wasm
+  DEPENDS test64.wasm
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+# Install WASM file
+set(WASM_FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/test64.wasm
+)
+install(FILES ${WASM_FILES} DESTINATION .)
+
+# Install AOT files
+set(AOT_FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/test64.aot
+  ${CMAKE_CURRENT_BINARY_DIR}/test64_chain.aot
+)
+install(FILES ${AOT_FILES} DESTINATION .)

+ 0 - 4
tests/unit/tid-allocator/CMakeLists.txt

@@ -13,10 +13,6 @@ if (NOT DEFINED WAMR_BUILD_INTERP)
   set (WAMR_BUILD_INTERP 1)
 endif ()
 
-if (NOT DEFINED WAMR_BUILD_PLATFORM)
-  string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
-endif ()
-
 include (../unit_common.cmake)
 
 add_library (tid_allocator_vmlib ${WAMR_RUNTIME_LIB_SOURCE})

+ 0 - 16
tests/unit/unit_common.cmake

@@ -1,27 +1,11 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-if (NOT DEFINED WAMR_BUILD_PLATFORM)
-  set (WAMR_BUILD_PLATFORM "linux")
-endif ()
-
 enable_language (ASM)
 
 # Usually, test cases should identify their unique
 # complation flags to implement their test plan
 
-# Set WAMR_BUILD_TARGET, currently values supported:
-# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32"
-if (NOT DEFINED WAMR_BUILD_TARGET)
-  if (CMAKE_SIZEOF_VOID_P EQUAL 8)
-    # Build as X86_64 by default in 64-bit platform
-    set (WAMR_BUILD_TARGET "X86_64")
-  else ()
-    # Build as X86_32 by default in 32-bit platform
-    set (WAMR_BUILD_TARGET "X86_32")
-  endif ()
-endif ()
-
 set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
 
 # include the build config template file

+ 0 - 2
tests/unit/wasm-c-api/CMakeLists.txt

@@ -4,8 +4,6 @@
 cmake_minimum_required (VERSION 3.14)
 project (wasm_c_api_test)
 
-set(WAMR_BUILD_PLATFORM "linux")
-
 # WAMR features switch
 if (NOT DEFINED WAMR_BUILD_TARGET)
   set(WAMR_BUILD_TARGET "X86_64")