test: add --mode vm, the autopkgtest escape hatch
VM virtualization is the one backend pkh does not reimplement: the qemu runner carries the serial-console protocol, image overlay management and reboot support, and it is the only one satisfying isolation-machine/needs-reboot tests. pkh execs the installed autopkgtest with its qemu runner (--image required, --cpus/--ram-size passthrough) in its own process group so Ctrl+C reaches the testbed cleanup, parses the --summary file back into the pkh report model and maps autopkgtest's exit classes onto the 0/1/2 contract (12/14/16/20 are runtime errors; the raw code rides the JSON report). Pockets, PPAs and injection are refused in vm mode for now: they would need the keyring setup inside the image.
This commit is contained in:
1 parent
15cc19007f
commit
7790b9452d
5 files changed
+334
-16
No files matched your search
+17
-2
@@ -17,6 +17,9 @@ pub enum TestMode {
|
||||
Chroot,
|
||||
/// The current context directly: no isolation, tests can rewrite it.
|
||||
Local,
|
||||
/// A qemu virtual machine, through the installed autopkgtest's qemu
|
||||
/// runner — the one backend pkh does not reimplement.
|
||||
Vm,
|
||||
}
|
||||
|
||||
impl TestMode {
|
||||
@@ -25,6 +28,7 @@ impl TestMode {
|
||||
match self {
|
||||
TestMode::Chroot => "chroot",
|
||||
TestMode::Local => "local",
|
||||
TestMode::Vm => "vm",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +37,7 @@ impl TestMode {
|
||||
match value {
|
||||
"chroot" => Some(TestMode::Chroot),
|
||||
"local" => Some(TestMode::Local),
|
||||
"vm" => Some(TestMode::Vm),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -58,6 +63,12 @@ pub struct TestOptions<'a> {
|
||||
pub inject: Vec<String>,
|
||||
/// Testbed mode; defaults to [`TestMode::Chroot`].
|
||||
pub mode: Option<TestMode>,
|
||||
/// VM image for [`TestMode::Vm`] (required there).
|
||||
pub image: Option<PathBuf>,
|
||||
/// VM virtual CPUs ([`TestMode::Vm`], passthrough).
|
||||
pub cpus: Option<u32>,
|
||||
/// VM memory size in MiB ([`TestMode::Vm`], passthrough).
|
||||
pub ram_size: Option<String>,
|
||||
/// Explicit binary packages to test; overrides the `pkh deb` output
|
||||
/// reuse.
|
||||
pub debs: Vec<PathBuf>,
|
||||
@@ -106,6 +117,9 @@ impl Default for TestOptions<'_> {
|
||||
ppa: Vec::new(),
|
||||
inject: Vec::new(),
|
||||
mode: None,
|
||||
image: None,
|
||||
cpus: None,
|
||||
ram_size: None,
|
||||
debs: Vec::new(),
|
||||
no_build: false,
|
||||
build: false,
|
||||
@@ -197,8 +211,9 @@ mod tests {
|
||||
fn mode_parsing() {
|
||||
assert_eq!(TestMode::parse("chroot"), Some(TestMode::Chroot));
|
||||
assert_eq!(TestMode::parse("local"), Some(TestMode::Local));
|
||||
assert_eq!(TestMode::parse("vm"), None);
|
||||
assert_eq!(TestMode::parse("vm"), Some(TestMode::Vm));
|
||||
assert_eq!(TestMode::parse("other"), None);
|
||||
assert_eq!(TestMode::default(), TestMode::Chroot);
|
||||
assert_eq!(TestMode::Local.label(), "local");
|
||||
assert_eq!(TestMode::Vm.label(), "vm");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user