From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Cc: Ryan Lahfa <ryan@lahfa.xyz>
Subject: [PATCH] release/checks/try.nix: init
Date: Fri, 26 May 2023 21:07:58 +0000 [thread overview]
Message-ID: <20230526210757.397735-1-hi@alyssa.is> (raw)
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>
---
Documentation for reviewing patches:
https://spectrum-os.org/doc/contributing/reviewing-patches.html
release/checks/default.nix | 2 ++
release/checks/try.nix | 50 ++++++++++++++++++++++++++++++++++++++
release/live/default.nix | 2 +-
3 files changed, 53 insertions(+), 1 deletion(-)
create mode 100644 release/checks/try.nix
diff --git a/release/checks/default.nix b/release/checks/default.nix
index f8a3f9b..bf26b9a 100644
--- a/release/checks/default.nix
+++ b/release/checks/default.nix
@@ -15,4 +15,6 @@ import ../../lib/eval-config.nix ({ ... } @ args:
rustfmt = import ./rustfmt.nix args;
shellcheck = import ./shellcheck.nix args;
+
+ try = import ./try.nix args;
})
diff --git a/release/checks/try.nix b/release/checks/try.nix
new file mode 100644
index 0000000..73539ef
--- /dev/null
+++ b/release/checks/try.nix
@@ -0,0 +1,50 @@
+# 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 ({ pkgs, ... }: {
+ name = "try-spectrum-test";
+ nodes = {};
+
+ testScript = ''
+ import shlex
+ import subprocess
+
+ conf = subprocess.run([
+ "${pkgs.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
+
+ flags = " ".join(map(shlex.quote, [
+ "qemu-kvm",
+ "-m", "512",
+ "-kernel", "${live.rootfs.kernel}/${pkgs.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()
+ '';
+}))
diff --git a/release/live/default.nix b/release/live/default.nix
index b7ee036..6df73d4 100644
--- a/release/live/default.nix
+++ b/release/live/default.nix
@@ -48,6 +48,6 @@ stdenvNoCC.mkDerivation {
enableParallelBuilding = true;
- passthru = { inherit rootfs; };
+ passthru = { inherit initramfs rootfs; };
}
) {})
--
2.37.1
next reply other threads:[~2023-05-26 21:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 21:07 Alyssa Ross [this message]
2023-05-27 13:48 ` [PATCH] release/checks/try.nix: init Ryan Lahfa
2023-05-27 14:38 ` Alyssa Ross
2023-05-27 14:53 ` Ryan Lahfa
2023-05-27 15:07 ` Alyssa Ross
2023-05-27 15:09 ` Ryan Lahfa
2023-05-27 15:10 ` Ryan Lahfa
2023-05-27 21:39 ` Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230526210757.397735-1-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=devel@spectrum-os.org \
--cc=ryan@lahfa.xyz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).