diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-05-26 20:44:34 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-05-27 21:35:31 +0000 |
commit | 6b34ec8a8ba7c48837edcec06be808d773ce793a (patch) | |
tree | f10ae4f37d5e4548e0d9057a4c826d0c34f34859 /release/checks/try.nix | |
parent | 1c6893145bdf023cd03b7675a18749ce8ed3803f (diff) | |
download | spectrum-6b34ec8a8ba7c48837edcec06be808d773ce793a.tar spectrum-6b34ec8a8ba7c48837edcec06be808d773ce793a.tar.gz spectrum-6b34ec8a8ba7c48837edcec06be808d773ce793a.tar.bz2 spectrum-6b34ec8a8ba7c48837edcec06be808d773ce793a.tar.lz spectrum-6b34ec8a8ba7c48837edcec06be808d773ce793a.tar.xz spectrum-6b34ec8a8ba7c48837edcec06be808d773ce793a.tar.zst spectrum-6b34ec8a8ba7c48837edcec06be808d773ce793a.zip |
release/checks/try.nix: init
This is a regression test for c7f87f3 ("host/rootfs: allow growing ext partition to fail"). It's the first time we're actually doing automated tests of a Spectrum boot. For now, I'm using the NixOS test framework, but because we're not using NixOS and not setting any NixOS options, it feels to me like it doesn't actually buy us very much, so if it doesn't start adding more value as we add more (or more complex) tests, it might be simpler to just use a shell/execline script for tests. Signed-off-by: Alyssa Ross <hi@alyssa.is> Message-Id: <20230526210757.397735-1-hi@alyssa.is> Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
Diffstat (limited to 'release/checks/try.nix')
-rw-r--r-- | release/checks/try.nix | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/release/checks/try.nix b/release/checks/try.nix new file mode 100644 index 0000000..62fade9 --- /dev/null +++ b/release/checks/try.nix @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> + +import ../../lib/eval-config.nix ({ config, ... }: + +let + live = import ../live { inherit config; }; +in + +config.pkgs.nixosTest ({ stdenv, mtools, ... }: { + name = "try-spectrum-test"; + nodes = {}; + + testScript = '' + import shlex + import subprocess + + conf = subprocess.run([ + "${mtools}/bin/mcopy", + "-i", + "${live}@@1M", + "::loader/entries/spectrum.conf", + "-", + ], stdout=subprocess.PIPE) + conf.check_returncode() + + cmdline = None + for line in conf.stdout.decode('utf-8').splitlines(): + key, value = line.split(' ', 1) + if key == 'options': + cmdline = value + break + + flags = " ".join(map(shlex.quote, [ + "qemu-kvm", + "-m", "512", + "-kernel", "${live.rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}", + "-initrd", "${live.initramfs}", + "-device", "qemu-xhci", + "-device", "usb-storage,drive=drive1,removable=true", + "-drive", "file=${live},id=drive1,format=raw,if=none,readonly=on", + "-append", f"panic=-1 {cmdline}", + ])) + + machine = create_machine({"startCommand": flags}) + + machine.start() + machine.wait_for_console_text("EXT4-fs \(sda4\): mounted filesystem") + machine.crash() + ''; +})) |