27 lines
858 B
C
27 lines
858 B
C
#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;
|
|
}
|