mirror of
https://github.com/fluencelabs/wasmer
synced 2025-07-31 23:32:04 +00:00
Add validate function and test
This commit is contained in:
22
lib/runtime-c-api/tests/test-validate.c
Normal file
22
lib/runtime-c-api/tests/test-validate.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include "../wasmer.h"
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Read the wasm file bytes
|
||||
FILE *file = fopen("sum.wasm", "r");
|
||||
fseek(file, 0, SEEK_END);
|
||||
long len = ftell(file);
|
||||
uint8_t *bytes = malloc(len);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
fread(bytes, 1, len, file);
|
||||
fclose(file);
|
||||
|
||||
bool result = wasmer_validate(bytes, len);
|
||||
printf("Result: %d", result);
|
||||
assert(result);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user