Initial LinuxCNC WebAssembly workspace snapshot

This commit is contained in:
2026-08-20 18:21:15 +08:00
commit 5dd614c335
92 changed files with 200203 additions and 0 deletions

View 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;
}