Initial LinuxCNC WebAssembly workspace snapshot
This commit is contained in:
26
wasm-core/tests/sim_api_test.c
Normal file
26
wasm-core/tests/sim_api_test.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "sim_api.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(void) {
|
||||
uint8_t snapshot[sizeof(uint64_t)] = {0};
|
||||
uint8_t state[32] = {0};
|
||||
assert(sim_step(1) == SIM_ERR_NOT_CREATED);
|
||||
assert(sim_create(NULL, 0) == SIM_OK);
|
||||
assert(sim_load_workspace("/workspace") == SIM_OK);
|
||||
assert(sim_step(7) == SIM_OK);
|
||||
assert(sim_read_snapshot(snapshot, sizeof(snapshot)) == sizeof(snapshot));
|
||||
uint64_t tick = 0;
|
||||
memcpy(&tick, snapshot, sizeof(tick));
|
||||
assert(tick == 7);
|
||||
assert(sim_export_state(state, sizeof(state)) > 0);
|
||||
assert(sim_step(3) == SIM_OK);
|
||||
assert(sim_import_state(state, sizeof(state)) == SIM_OK);
|
||||
assert(sim_read_snapshot(snapshot, sizeof(snapshot)) == sizeof(snapshot));
|
||||
memcpy(&tick, snapshot, sizeof(tick));
|
||||
assert(tick == 7);
|
||||
sim_destroy();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user