mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-11-27 18:11:21 +00:00
refactor: update CMakeLists.txt for testing support and modify demo output
This commit is contained in:
parent
be4dc9fcf9
commit
29d5070e7f
|
|
@ -5,9 +5,8 @@ cmake_minimum_required (VERSION 3.14)
|
||||||
|
|
||||||
project(checked_api_sample)
|
project(checked_api_sample)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
# assertion required
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 23)
|
set(CMAKE_C_STANDARD 23)
|
||||||
|
|
||||||
|
|
@ -54,3 +53,9 @@ ExternalProject_Add(wasm
|
||||||
BUILD_COMMAND ${CMAKE_COMMAND} --build build
|
BUILD_COMMAND ${CMAKE_COMMAND} --build build
|
||||||
INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR}
|
INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
add_test(NAME checked_api_sample_test
|
||||||
|
COMMAND ${PROJECT_NAME}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,18 @@ main(int argc, char *argv_main[])
|
||||||
arguments);
|
arguments);
|
||||||
VERIFY_API_RESULT(wasm_runtime_call_wasm_a_checked, api_result,
|
VERIFY_API_RESULT(wasm_runtime_call_wasm_a_checked, api_result,
|
||||||
release_runtime);
|
release_runtime);
|
||||||
printf("Native finished calling wasm function: fib, returned: %d\n",
|
printf("Native finished calling wasm function: fib(%d), returned: %d\n",
|
||||||
result[0].of.i32);
|
arguments[0].of.i32, result[0].of.i32);
|
||||||
|
bh_assert(result[0].of.i32 == 8);
|
||||||
|
|
||||||
|
arguments[0].of.i32 = 2;
|
||||||
|
api_result = wasm_runtime_call_wasm_a_checked(exec_env, func, 1, result, 1,
|
||||||
|
arguments);
|
||||||
|
VERIFY_API_RESULT(wasm_runtime_call_wasm_a_checked, api_result,
|
||||||
|
release_runtime);
|
||||||
|
printf("Native finished calling wasm function: fib(%d), returned: %d\n",
|
||||||
|
arguments[0].of.i32, result[0].of.i32);
|
||||||
|
bh_assert(result[0].of.i32 == 1);
|
||||||
|
|
||||||
ret = EXIT_SUCCESS;
|
ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ __attribute__((export_name("fib"))) int
|
||||||
fib(int n)
|
fib(int n)
|
||||||
{
|
{
|
||||||
int result = fibonacci(n);
|
int result = fibonacci(n);
|
||||||
printf("fibonacci(%d)=%d\n", n, result);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user