Add standalone cases (#3536)
This commit is contained in:
50
tests/standalone/dump-call-stack/run.sh
Executable file
50
tests/standalone/dump-call-stack/run.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
readonly WAMR_DIR="$PWD/../../.."
|
||||
readonly IWASM_CMD="$PWD/build/iwasm"
|
||||
readonly WAMRC_CMD="$PWD/../../../wamr-compiler/build/wamrc"
|
||||
|
||||
PLATFORM=$(uname -s | tr A-Z a-z)
|
||||
|
||||
if [[ $1 == "--classic-interp" ]]; then
|
||||
CMAKE_FLAGS="-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0"
|
||||
elif [[ $1 == "--fast-interp" ]]; then
|
||||
CMAKE_FLAGS="-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1"
|
||||
elif [[ $1 == "--fast-jit" ]]; then
|
||||
CMAKE_FLAGS="-DWAMR_BUILD_FAST_JIT=1"
|
||||
elif [[ $1 == "--jit" ]]; then
|
||||
CMAKE_FLAGS="-DWAMR_BUILD_JIT=1"
|
||||
elif [[ $1 == "--multi-tier-jit" ]]; then
|
||||
CMAKE_FLAGS="-DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1"
|
||||
fi
|
||||
|
||||
TARGET="X86_64"
|
||||
if [[ $3 = "X86_32" ]]; then
|
||||
TARGET="X86_32"
|
||||
fi
|
||||
|
||||
echo "============> test dump-call-stack"
|
||||
|
||||
rm -fr build && mkdir build && cd build
|
||||
cmake ${WAMR_DIR}/product-mini/platforms/${PLATFORM} ${CMAKE_FLAGS} \
|
||||
-DWAMR_BUILD_DUMP_CALL_STACK=1 -DWAMR_BUILD_TARGET=${TARGET}
|
||||
make -j ${nproc} > /dev/null 2>&1
|
||||
cd ..
|
||||
|
||||
echo "============> compile test-malloc to wasm"
|
||||
/opt/wasi-sdk/bin/clang -O3 -o test-malloc.wasm wasm-app/main.c \
|
||||
-Wl,--export-all -Wl,--export=__heap_base,--export=__data_end
|
||||
|
||||
if [[ $1 != "--aot" ]]; then
|
||||
echo "============> run test-malloc.wasm"
|
||||
${IWASM_CMD} test-malloc.wasm
|
||||
else
|
||||
echo "============> compile test-malloc.wasm to aot"
|
||||
${WAMRC_CMD} --enable-dump-call-stack --emit-custom-sections=name -o test-malloc.aot test-malloc.wasm
|
||||
echo "============> run test-malloc.aot"
|
||||
${IWASM_CMD} test-malloc.aot
|
||||
fi
|
||||
50
tests/standalone/dump-call-stack/wasm-app/main.c
Normal file
50
tests/standalone/dump-call-stack/wasm-app/main.c
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
printf("Hello World!\n");
|
||||
|
||||
char *buf = "1234", *buf1 = "12345";
|
||||
|
||||
printf("result is %f \n", 22.00);
|
||||
|
||||
printf("Hello World!\n");
|
||||
|
||||
buf = malloc(1024);
|
||||
|
||||
printf("malloc func ptr: %p\n", malloc);
|
||||
|
||||
printf("##buf: %p\n", buf);
|
||||
|
||||
if (!buf) {
|
||||
printf("malloc buf failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("buf ptr: %p\n", buf);
|
||||
|
||||
sprintf(buf, "%s", "1234\n");
|
||||
printf("buf: %s", buf);
|
||||
|
||||
buf1 = strdup(buf);
|
||||
printf("buf1: %s\n", buf1);
|
||||
|
||||
free(buf1);
|
||||
free(buf);
|
||||
|
||||
printf("buf[65536]: %c\n", buf[65536 * 10]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user