Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/heimdall

crates/heimdall-container/tests/shim_no_pivot.rs

// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (C) 2026 Ignalina ApS and Vetra Automation AB

//! The shim says when it entered a job root without pivot_root (lane lsm-shim): the
//! response carries `no_pivot`, and a runner that predates the field still reads it.

use heimdall_container::shim::ShimResponse;

#[test]
fn a_no_pivot_job_says_so_and_an_older_answer_still_reads() {
    let r = ShimResponse {
        no_pivot: true,
        ..Default::default()
    };
    let j = serde_json::to_value(&r).unwrap();
    assert_eq!(j["no_pivot"], true, "{j}");
    // A pivoted job does not mention it (the answer stays what it was).
    let j = serde_json::to_value(ShimResponse::default()).unwrap();
    assert!(j.get("no_pivot").is_none(), "{j}");
    // The answer of a shim without the field reads as pivoted.
    let old: ShimResponse = serde_json::from_str(r#"{"exit_code":0}"#).unwrap();
    assert!(!old.no_pivot);
    assert!(heimdall_plain::rootfs::NO_PIVOT_NOTE.contains("MS_MOVE + chroot"));
}