41 lines
2.5 KiB
JavaScript
41 lines
2.5 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import { loadSimulationCase, toWorkerConfiguration } from "../workspace/sim-case-loader.mjs";
|
|
import { SimSession, CONTEXT_ID } from "./sim-session.mjs";
|
|
|
|
const CASES = [
|
|
["linuxcnc/configs/sim/axis/ja_tests/xz/xz.ini", "linuxcnc/configs/sim/axis/ja_tests/xz/xz_cmds.hal"],
|
|
["linuxcnc/configs/sim/axis/ja_tests/xz/xz_both.ini", "linuxcnc/configs/sim/axis/ja_tests/xz/xz_both_cmds.hal"],
|
|
["linuxcnc/configs/sim/axis/ja_tests/xz/xz_both_auto.ini", "linuxcnc/configs/sim/axis/ja_tests/xz/xz_both_auto_cmds.hal"],
|
|
];
|
|
const fetchImpl = async (url) => {
|
|
try {
|
|
const body = await readFile(new URL(`../../${String(url).replace(/^\//, "")}`, import.meta.url));
|
|
return { ok: true, text: async () => body.toString("utf8") };
|
|
} catch {
|
|
return { ok: false, text: async () => "" };
|
|
}
|
|
};
|
|
const core = { _sim_create() { return 0; }, _sim_load_workspace() { return 0; }, _sim_protocol_reset() {}, _sim_protocol_accept() { return 0; } };
|
|
|
|
const results = [];
|
|
for (const [path, generatedHal] of CASES) {
|
|
const bundle = await loadSimulationCase({ path, fetchImpl });
|
|
assert.equal(bundle.status, "ready");
|
|
assert.deepEqual(bundle.missing, []);
|
|
const halFixture = bundle.runtime_fixtures.find((row) => row.generated_hal === generatedHal);
|
|
assert.ok(halFixture);
|
|
assert.equal(halFixture.config_path, "linuxcnc/configs/sim/axis/ja_tests/xz/xzbase.inc");
|
|
const session = new SimSession(core, { sessionId: path });
|
|
const base = { schema_version: 1, context_id: CONTEXT_ID, session_id: path };
|
|
session.accept({ ...base, kind: "HELLO", seq: 1, payload: {} });
|
|
session.accept({ ...base, kind: "SESSION_ATTACH", seq: 2, operation_id: "attach", payload: {} });
|
|
const response = session.accept({ ...base, kind: "LOAD_WORKSPACE", seq: 3, operation_id: "load", payload: { root_path: "/workspace", configuration: toWorkerConfiguration(bundle) } });
|
|
assert.equal(response.kind, "COMMAND_RESULT");
|
|
assert.equal(response.payload.configuration.state, "TASK_READY");
|
|
assert.equal(response.payload.configuration.hal.blocked_count, 0);
|
|
results.push({ path, state: response.payload.configuration.state, loader_hash: bundle.state_hash, startup_hash: response.payload.configuration.state_hash, generated_hal: generatedHal });
|
|
}
|
|
|
|
console.log(JSON.stringify({ schema: "sim-case-batch-s8-03-sample.v1", status: "verified", cases: results, fixture_policy: "user-authorized-runtime-copy", boundary: "XZ identity/BOTH/AUTO cases share exact xz.var and xz.tbl inputs; unrelated cases remain outside this batch" }));
|