(sandbox_name: &str)
| 101 | } |
| 102 | |
| 103 | async fn assert_vm_overlay_root(sandbox_name: &str) { |
| 104 | let script = concat!( |
| 105 | "set -eu; ", |
| 106 | "test \"$(stat -f -c %T /)\" = \"overlayfs\"; ", |
| 107 | "printf \"overlay-write\\n\" > /sandbox/overlay-check; ", |
| 108 | "test \"$(cat /sandbox/overlay-check)\" = \"overlay-write\"; ", |
| 109 | "if [ -e /opt/openshell/tls/tls.key ]; then ", |
| 110 | "test \"$(stat -c %a /opt/openshell/tls/tls.key)\" = \"600\"; ", |
| 111 | "fi; ", |
| 112 | "echo vm-overlay-ok", |
| 113 | ); |
| 114 | |
| 115 | let mut exec_cmd = openshell_cmd(); |
| 116 | exec_cmd |
| 117 | .args(["sandbox", "exec", "--name", sandbox_name, "--no-tty", "--"]) |
| 118 | .arg("sh") |
| 119 | .arg("-lc") |
| 120 | .arg(script) |
| 121 | .stdout(Stdio::piped()) |
| 122 | .stderr(Stdio::piped()); |
| 123 | |
| 124 | let output = exec_cmd |
| 125 | .output() |
| 126 | .await |
| 127 | .expect("failed to run VM overlay assertion"); |
| 128 | let combined = strip_ansi(&format!( |
| 129 | "{}{}", |
| 130 | String::from_utf8_lossy(&output.stdout), |
| 131 | String::from_utf8_lossy(&output.stderr), |
| 132 | )); |
| 133 | |
| 134 | assert!( |
| 135 | output.status.success() && combined.contains("vm-overlay-ok"), |
| 136 | "VM overlay assertion failed (status {:?}):\n{combined}", |
| 137 | output.status.code(), |
| 138 | ); |
| 139 | } |
no test coverage detected