diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-05-04 08:07:29 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-05-04 08:07:29 +0300 |
commit | 1ec4123409240adfba2f48700114065e7aeb6950 (patch) | |
tree | 6e2e01b1f798591bee066df983f06c68c1448fed | |
parent | a2882eca83cad33ca046fbdc47cac16108cb2bd4 (diff) | |
download | vmdb2-1ec4123409240adfba2f48700114065e7aeb6950.tar.gz |
check-one --maybe-boot and refactoring
Sponsored-by: author
-rwxr-xr-x | check-one | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -33,6 +33,7 @@ class Config: p.add_argument("--mklabel", action="store", choices=["msdos", "gpt"]) p.add_argument("--arch", action="store") p.add_argument("--boot", action="store_true") + p.add_argument("--maybe-boot", action="store_true") p.add_argument("--verbose", action="store_true") args = p.parse_args() @@ -41,12 +42,18 @@ class Config: self.vmdb_filename = args.vmdb self.vmdb = yaml.safe_load(open(self.vmdb_filename)) self.boot = args.boot + self.maybe_boot = args.maybe_boot self.verbose = args.verbose if args.arch: - self.qemu = QEMUS.get(args.arch) + arch = args.arch else: - self.qemu = QEMUS.get(self.default_arch()) + arch = self.default_arch() + self.qemu = QEMUS.get(arch) + if self.boot and not self.qemu: + sys.exit( + f"Can't boot architecture {arch}: don't know of an emulator for it" + ) mklabel = self._step("mklabel") debootstrap = self._step("debootstrap") @@ -173,13 +180,17 @@ expect eof with open(qemu_sh, "w") as f: f.write(qemu_script) os.chmod(qemu_sh, 0o755) + with open(expect_txt, "w") as f: f.write(expect_script) - subprocess.run( - ["expect", "-d", expect_txt], check=True, capture_output=not config.verbose + p = subprocess.run( + ["expect", "-d", expect_txt], check=False, capture_output=not config.verbose ) shutil.rmtree(tmp) + if p.returncode != 0: + sys.stderr.write(p.stderr.decode()) + sys.exit(f"{config.image()} failed to boot") print(f"verified that {config.image()} boots OK") @@ -191,6 +202,8 @@ def main(): run_vmdb2(config) if config.boot: smoke_test(config) + elif config.maybe_boot and config.qemu: + smoke_test(config) main() |