#!/usr/bin/env node const assert = require("assert"); const cp = require("child_process"); const path = require("path"); const repo = path.resolve(__dirname, ".."); const baseImage = "docker.io/library/alpine:3.20"; function run(command, args, options = {}) { return cp.execFileSync(command, args, { cwd: repo, encoding: "utf8", stdio: options.stdio || ["ignore", "pipe", "pipe"] }); } function incomplete(reason) { const error = new Error(`Linux Podman backend incomplete: ${reason}`); error.code = "DISASMER_PODMAN_INCOMPLETE"; throw error; } function ensurePodmanBaseImage() { try { run("podman", ["--version"]); } catch (error) { incomplete(`podman command is unavailable (${error.message})`); } let rootless; try { rootless = run("podman", ["info", "--format", "{{.Host.Security.Rootless}}"]).trim(); } catch (error) { incomplete(`podman info did not report rootless status (${error.message})`); } if (rootless !== "true") { incomplete(`podman is not running in rootless mode (reported ${JSON.stringify(rootless)})`); } try { run("podman", ["image", "exists", baseImage]); } catch (_) { try { run("podman", ["pull", baseImage], { stdio: "inherit" }); } catch (error) { incomplete(`unable to make ${baseImage} available (${error.message})`); } } } try { ensurePodmanBaseImage(); const stdout = run("cargo", [ "run", "-q", "-p", "disasmer-node", "--bin", "disasmer-podman-smoke" ]); const report = JSON.parse(stdout.trim().split("\n").at(-1)); assert.strictEqual(report.podman_status, "completed"); assert.strictEqual(report.status_code, 0); assert.strictEqual(report.stdout, "podman-ok:node-local source\n"); assert.strictEqual(report.large_bytes_uploaded, false); assert.strictEqual(report.uses_full_repo_tarball, false); assert.strictEqual(report.coordinator_routed_file_reads, false); assert.strictEqual(report.staged_artifact.path, "/vfs/artifacts/podman-smoke.txt"); console.log("Podman backend smoke passed"); } catch (error) { if (error.code === "DISASMER_PODMAN_INCOMPLETE") { console.error(error.message); process.exit(2); } throw error; }