mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
begin rework for js tests and hook examples
This commit is contained in:
7
hook/tests/hookapi/wasm/api.h
Normal file
7
hook/tests/hookapi/wasm/api.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include "../../../examples/hookapi.h"
|
||||
#define ASSERT(x)\
|
||||
{\
|
||||
if (!(x))\
|
||||
rollback(SBUF(#x), __LINE__);\
|
||||
}
|
||||
19
hook/tests/hookapi/wasm/log.c
Normal file
19
hook/tests/hookapi/wasm/log.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "api.h"
|
||||
|
||||
int64_t hook(uint32_t reserved )
|
||||
{
|
||||
int64_t x = float_set(0, 1234567890);
|
||||
int64_t l = float_log(x);
|
||||
int64_t i = float_int(l, 15, 1);
|
||||
|
||||
ASSERT(i == 9091514977169268ULL);
|
||||
|
||||
ASSERT(float_log(float_one()) == 0);
|
||||
|
||||
// RH TODO: more tests
|
||||
|
||||
accept (0,0,0);
|
||||
_g(1,1); // every hook needs to import guard function and use it at least once
|
||||
// unreachable
|
||||
return 0;
|
||||
}
|
||||
7
hook/tests/hookapi/wasm/makefile
Normal file
7
hook/tests/hookapi/wasm/makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
all: log.wasm root.wasm
|
||||
log.wasm: log.c
|
||||
wasmcc log.c -o log.wasm -O0 -Wl,--allow-undefined -I../
|
||||
hook-cleaner log.wasm
|
||||
root.wasm: root.c
|
||||
wasmcc root.c -o root.wasm -O0 -Wl,--allow-undefined -I../
|
||||
hook-cleaner root.wasm
|
||||
21
hook/tests/hookapi/wasm/root.c
Normal file
21
hook/tests/hookapi/wasm/root.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "api.h"
|
||||
|
||||
int64_t hook(uint32_t reserved )
|
||||
{
|
||||
int64_t x = float_set(0, 1234567890);
|
||||
int64_t l = float_root(x, 2);
|
||||
TRACEXFL(l);
|
||||
int64_t i = float_int(l, 6, 1);
|
||||
|
||||
TRACEVAR(i);
|
||||
|
||||
ASSERT(i == 35136418286444ULL);
|
||||
|
||||
|
||||
// RH TODO: more tests
|
||||
|
||||
accept (0,0,0);
|
||||
_g(1,1); // every hook needs to import guard function and use it at least once
|
||||
// unreachable
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user