Source commit: 309831e1e021f962c118452336776fd9a94025f9 Public tree identity: sha256:6fa95c1745579bd6256dbeb3d476db0b07c2f24aa9213b0f7783ce1adfc8aca5
115 lines
3.2 KiB
JavaScript
115 lines
3.2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const assert = require("assert");
|
|
const cp = require("child_process");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const repo = path.resolve(__dirname, "..");
|
|
const wasmTarget = path.join(
|
|
repo,
|
|
"target",
|
|
"wasm32-unknown-unknown",
|
|
"debug",
|
|
"launch_build_demo.wasm"
|
|
);
|
|
|
|
cp.execFileSync(
|
|
"cargo",
|
|
["build", "-p", "launch-build-demo", "--target", "wasm32-unknown-unknown"],
|
|
{ cwd: repo, stdio: "inherit" }
|
|
);
|
|
|
|
assert(fs.existsSync(wasmTarget), `missing compiled Wasm module at ${wasmTarget}`);
|
|
|
|
const output = cp.execFileSync(
|
|
"cargo",
|
|
[
|
|
"run",
|
|
"-q",
|
|
"-p",
|
|
"disasmer-node",
|
|
"--bin",
|
|
"disasmer-wasmtime-smoke",
|
|
"--",
|
|
wasmTarget,
|
|
"task_add_one",
|
|
"41",
|
|
"42",
|
|
],
|
|
{ cwd: repo, encoding: "utf8" }
|
|
);
|
|
|
|
const report = JSON.parse(output);
|
|
assert.strictEqual(report.type, "wasmtime_task_smoke");
|
|
assert.strictEqual(report.export, "task_add_one");
|
|
assert.strictEqual(report.arg, 41);
|
|
assert.strictEqual(report.result, 42);
|
|
|
|
const debugOutput = cp.execFileSync(
|
|
"cargo",
|
|
[
|
|
"run",
|
|
"-q",
|
|
"-p",
|
|
"disasmer-node",
|
|
"--bin",
|
|
"disasmer-wasmtime-smoke",
|
|
"--",
|
|
"--debug-freeze-resume",
|
|
wasmTarget,
|
|
"task_add_one",
|
|
"41",
|
|
"42",
|
|
],
|
|
{ cwd: repo, encoding: "utf8" }
|
|
);
|
|
const debugReport = JSON.parse(debugOutput);
|
|
assert.strictEqual(debugReport.type, "wasmtime_debug_freeze_resume_smoke");
|
|
assert.strictEqual(debugReport.export, "task_add_one");
|
|
assert.strictEqual(debugReport.task, "task_add_one");
|
|
assert.strictEqual(debugReport.frozen_state, "Frozen");
|
|
assert.strictEqual(debugReport.resumed_state, "Running");
|
|
assert(debugReport.stack_frames.some((frame) => String(frame).includes("task_add_one")));
|
|
assert(
|
|
debugReport.local_values.some(
|
|
([name, value]) => name === "wasm_local_0" && String(value).includes("41")
|
|
),
|
|
"Wasmtime debug snapshot must expose the real i32 argument as a frame local"
|
|
);
|
|
assert.strictEqual(debugReport.node_runtime_captured_wasm_locals, true);
|
|
assert.strictEqual(debugReport.result, 42);
|
|
assert.strictEqual(debugReport.node_runtime_reached_wasm_task, true);
|
|
|
|
const hostCommandOutput = cp.execFileSync(
|
|
"cargo",
|
|
[
|
|
"run",
|
|
"-q",
|
|
"-p",
|
|
"disasmer-node",
|
|
"--bin",
|
|
"disasmer-wasmtime-smoke",
|
|
"--",
|
|
"--host-command",
|
|
],
|
|
{ cwd: repo, encoding: "utf8" }
|
|
);
|
|
const hostCommandReport = JSON.parse(hostCommandOutput);
|
|
assert.strictEqual(hostCommandReport.type, "wasmtime_host_command_smoke");
|
|
assert.strictEqual(hostCommandReport.export, "compile-linux");
|
|
assert.strictEqual(hostCommandReport.export_result, 0);
|
|
assert.strictEqual(hostCommandReport.virtual_thread, "compile-linux");
|
|
assert.strictEqual(hostCommandReport.stdout, "linux-build-artifact");
|
|
assert.strictEqual(
|
|
hostCommandReport.staged_artifact.path,
|
|
"/vfs/artifacts/linux/app.tar.zst"
|
|
);
|
|
assert.strictEqual(hostCommandReport.large_bytes_uploaded, false);
|
|
assert.strictEqual(hostCommandReport.manifest_objects, 1);
|
|
assert.strictEqual(hostCommandReport.node_host_import, "disasmer.cmd_run");
|
|
assert.strictEqual(hostCommandReport.flagship_linux_build_task, true);
|
|
assert.strictEqual(hostCommandReport.node_executed_host_command, true);
|
|
assert.strictEqual(hostCommandReport.hosted_control_plane_ran_command, false);
|
|
|
|
console.log("Wasmtime node smoke passed");
|