diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2025-04-15 22:20:14 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2025-04-15 22:20:14 +0200 |
| commit | 1dcb601fb5332e41058de2bf753b0981d5d0228f (patch) | |
| tree | 6ef2e2c4e10246e55b30c65ba308d84b0b6cf304 | |
| parent | 3145a4af99ff8610ee368ffd56a4c25f30221654 (diff) | |
Started Implementing Test Binary
There are a bunch of symbols that the linker can't find that we need to
start stubbing. I _hope_ the PS Vita has enough support for all of them!
| -rw-r--r-- | lib/wamr/Makefile | 11 | ||||
| -rw-r--r-- | lib/wamr/test/fibonacci.c | 26 | ||||
| -rw-r--r-- | lib/wamr/test/main.c | 14 |
3 files changed, 50 insertions, 1 deletions
diff --git a/lib/wamr/Makefile b/lib/wamr/Makefile index de1462b..5946e8d 100644 --- a/lib/wamr/Makefile +++ b/lib/wamr/Makefile @@ -32,7 +32,6 @@ CFLAGS = -DBH_FREE=wasm_runtime_free \ -DWASM_ENABLE_BULK_MEMORY=1 \ -DWASM_ENABLE_FAST_INTERP=1 \ -DWASM_ENABLE_INTERP=1 \ - -DWASM_ENABLE_LIBC_EMCC=1 \ -Icore/iwasm/common \ -Icore/iwasm/include \ -Icore/iwasm/interpreter \ @@ -56,3 +55,13 @@ $(LIB): $(OBJ) .PHONY: clean clean: rm -f $(LIB) $(OBJ) + +.PHONY: check +check: test/test.exe test/fibonacci.wasm + (cd $(dir $<); ./$(notdir $<)) + +test/test.exe: test/main.c $(LIB) + $(CC) -o $@ $< -Icore/iwasm/include -L. -lwamr + +test/fibonacci.wasm: test/fibonacci.c + clang -target wasm32 -nostdlib -Wl,--no-entry -Wl,--export=fibonacci -Wl,--allow-undefined -o $@ $< diff --git a/lib/wamr/test/fibonacci.c b/lib/wamr/test/fibonacci.c new file mode 100644 index 0000000..ce67a7e --- /dev/null +++ b/lib/wamr/test/fibonacci.c @@ -0,0 +1,26 @@ +#include <stdint.h> + +extern void lognumber(int32_t n); + +extern int32_t fibonacci(int32_t i) { + if (i < 0) { + return -1; + } + + uint32_t last = 0; + uint32_t result = 1; + for (; i > 0; i--) { + uint32_t current = result; + lognumber((int32_t)current); + + result += last; + last = current; + + if (result > INT32_MAX) { + // overflow + return -1; + } + } + + return (int32_t)result; +} diff --git a/lib/wamr/test/main.c b/lib/wamr/test/main.c new file mode 100644 index 0000000..2ae4912 --- /dev/null +++ b/lib/wamr/test/main.c @@ -0,0 +1,14 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +#include "wasm_export.h" + +int main(int argc, char *argv[argc + 1]) { + FILE *f = fopen("fibonacci.wasm", "w"); + assert(f); + + wasm_runtime_init(); + + return EXIT_SUCCESS; +} |
