From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Cc: Yureka <yuka@yuka.dev>
Subject: [PATCH 2/8] release/checks/integration: init from networking
Date: Fri, 13 Jun 2025 16:05:02 +0200 [thread overview]
Message-ID: <20250613140508.76998-3-hi@alyssa.is> (raw)
In-Reply-To: <20250613140508.76998-1-hi@alyssa.is>
Combining integration tests into a single Meson project will allow
easily sharing code between tests.
Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
release/checks/default.nix | 4 +-
release/checks/integration/default.nix | 87 +++++++++++++++++++
release/checks/integration/meson.build | 16 ++++
release/checks/integration/meson_options.txt | 6 ++
.../test.c => integration/networking.c} | 4 +-
release/checks/networking/default.nix | 62 -------------
release/checks/pkg-tests.nix | 2 +-
7 files changed, 114 insertions(+), 67 deletions(-)
create mode 100644 release/checks/integration/default.nix
create mode 100644 release/checks/integration/meson.build
create mode 100644 release/checks/integration/meson_options.txt
rename release/checks/{networking/test.c => integration/networking.c} (98%)
delete mode 100644 release/checks/networking/default.nix
diff --git a/release/checks/default.nix b/release/checks/default.nix
index e8ade9f..4c5ea2a 100644
--- a/release/checks/default.nix
+++ b/release/checks/default.nix
@@ -14,9 +14,9 @@ import ../../lib/call-package.nix ({ callSpectrumPackage }:
doc-anchors = callSpectrumPackage ./doc-anchors.nix {};
- pkg-tests = callSpectrumPackage ./pkg-tests.nix {};
+ integration = callSpectrumPackage ./integration {};
- networking = callSpectrumPackage ./networking {};
+ pkg-tests = callSpectrumPackage ./pkg-tests.nix {};
no-roothash = callSpectrumPackage ./no-roothash.nix {};
diff --git a/release/checks/integration/default.nix b/release/checks/integration/default.nix
new file mode 100644
index 0000000..f2996fd
--- /dev/null
+++ b/release/checks/integration/default.nix
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: MIT
+# SPDX-FileCopyrightText: 2023, 2025 Alyssa Ross <hi@alyssa.is>
+
+import ../../../lib/call-package.nix (
+{ callSpectrumPackage, src, lib, stdenv, runCommand, writeShellScript
+, clang-tools, meson, ninja, e2fsprogs, tar2ext4, libressl, qemu_kvm
+}:
+
+let
+ live = callSpectrumPackage ../../live {};
+
+ ncVm = callSpectrumPackage ../../../vm/make-vm.nix {} {
+ providers.net = [ "sys.netvm" ];
+ type = "nix";
+ run = writeShellScript "run" ''
+ set -x
+ while ! echo hello | ${libressl.nc}/bin/nc -N 10.0.2.2 1234; do :; done
+ '';
+ };
+
+ userData = runCommand "user-data.img" {
+ nativeBuildInputs = [ e2fsprogs tar2ext4 ];
+ } ''
+ tar --transform=s,^${ncVm},vms/nc, -Pcvf root.tar ${ncVm}
+ tar2ext4 -i root.tar -o $out
+ tune2fs -U a7834806-2f82-4faf-8ac4-4f8fd8a474ca $out
+ '';
+in
+
+stdenv.mkDerivation (finalAttrs: {
+ name = "spectrum-integration-tests";
+
+ src = lib.fileset.toSource {
+ root = ../../..;
+ fileset = lib.fileset.union
+ (lib.fileset.intersection src ./.)
+ ../../../scripts/run-qemu.sh;
+ };
+ sourceRoot = "source/release/checks/integration";
+
+ nativeBuildInputs = [ meson ninja ];
+ nativeCheckInputs = [ qemu_kvm ];
+
+ mesonFlags = [
+ "-Defi=${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd"
+ "-Dimg=${live}"
+ "-Duser_data=${userData}"
+ ];
+
+ doCheck = true;
+
+ installPhase = ''
+ runHook preInstall
+ cp meson-logs/testlog.txt $out
+ runHook postInstall
+ '';
+
+ shellHook = ''
+ unset QEMU_SYSTEM
+ '';
+
+ env = {
+ QEMU_SYSTEM = "qemu-system-${stdenv.hostPlatform.qemuArch} -nographic";
+ };
+
+ passthru.tests = {
+ clang-tidy = finalAttrs.finalPackage.overrideAttrs (
+ { name, src, nativeBuildInputs ? [], ... }:
+ {
+ name = "${name}-clang-tidy";
+
+ src = lib.fileset.toSource {
+ root = ../../..;
+ fileset = lib.fileset.union (lib.fileset.fromSource src) ../../../.clang-tidy;
+ };
+
+ nativeBuildInputs = nativeBuildInputs ++ [ clang-tools ];
+
+ buildPhase = ''
+ clang-tidy --warnings-as-errors='*' -p . ../*.c ../*.h
+ touch $out
+ exit 0
+ '';
+ }
+ );
+ };
+})) (_: {})
diff --git a/release/checks/integration/meson.build b/release/checks/integration/meson.build
new file mode 100644
index 0000000..3f273b4
--- /dev/null
+++ b/release/checks/integration/meson.build
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2025 Alyssa Ross <hi@alyssa.is>
+
+project('spectrum-integration-tests', 'c',
+ default_options : { 'c_std': 'c23' },
+ meson_version : '>=1.6.0')
+
+add_project_arguments('-D_GNU_SOURCE', language : 'c')
+
+test('networking', executable('networking', 'networking.c'),
+ args : [
+ find_program('../../../scripts/run-qemu.sh'),
+ get_option('efi'),
+ get_option('img'),
+ get_option('user_data'),
+ ])
diff --git a/release/checks/integration/meson_options.txt b/release/checks/integration/meson_options.txt
new file mode 100644
index 0000000..2d290de
--- /dev/null
+++ b/release/checks/integration/meson_options.txt
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2025 Alyssa Ross <hi@alyssa.is>
+
+option('efi', type : 'string')
+option('img', type : 'string')
+option('user_data', type : 'string')
diff --git a/release/checks/networking/test.c b/release/checks/integration/networking.c
similarity index 98%
rename from release/checks/networking/test.c
rename to release/checks/integration/networking.c
index 2bf0eb4..44dccf3 100644
--- a/release/checks/networking/test.c
+++ b/release/checks/integration/networking.c
@@ -321,8 +321,8 @@ int main(int argc, char *argv[])
"mount \"$(findfs UUID=a7834806-2f82-4faf-8ac4-4f8fd8a474ca)\" /run/mnt\n"
"s6-rc -bu change vmm-env\n"
"vm-import user /run/mnt/vms\n"
- "vm-start user.vm\n"
- "tail -Fc +0 /run/log/current /run/user.vm.log\r\n",
+ "vm-start user.nc\n"
+ "tail -Fc +0 /run/log/current /run/user.nc.log\r\n",
console) == EOF) {
fputs("error writing to console\n", stderr);
exit(EXIT_FAILURE);
diff --git a/release/checks/networking/default.nix b/release/checks/networking/default.nix
deleted file mode 100644
index 4280e7e..0000000
--- a/release/checks/networking/default.nix
+++ /dev/null
@@ -1,62 +0,0 @@
-# SPDX-License-Identifier: MIT
-# SPDX-FileCopyrightText: 2023, 2025 Alyssa Ross <hi@alyssa.is>
-
-import ../../../lib/call-package.nix (
-{ callSpectrumPackage, lib, stdenv, runCommand, runCommandCC, writeShellScript
-, clang-tools, e2fsprogs, tar2ext4, libressl, qemu_kvm
-}:
-
-let
- live = callSpectrumPackage ../../live {};
-
- vm = callSpectrumPackage ../../../vm/make-vm.nix {} {
- providers.net = [ "sys.netvm" ];
- type = "nix";
- run = writeShellScript "run" ''
- set -x
- while ! echo hello | ${libressl.nc}/bin/nc -N 10.0.2.2 1234; do :; done
- '';
- };
-
- userData = runCommand "user-data.img" {
- nativeBuildInputs = [ e2fsprogs tar2ext4 ];
- } ''
- tar --transform=s,^${vm},vms/vm, -Pcvf root.tar ${vm}
- tar2ext4 -i root.tar -o $out
- tune2fs -U a7834806-2f82-4faf-8ac4-4f8fd8a474ca $out
- '';
-
- cflags = [ "-std=c23" "-D_GNU_SOURCE" ];
-
- test = runCommandCC "test" {} ''
- $CC -o $out ${lib.escapeShellArgs cflags} ${./test.c}
- '';
-
- testScript = writeShellScript "spectrum-networking-test" ''
- PATH=${lib.escapeShellArg (lib.makeBinPath [ qemu_kvm ])}:"$PATH"
- exec ${test} \
- ${../../../scripts/run-qemu.sh} \
- ${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd \
- ${live} \
- ${userData}
- '';
-in
-
-runCommand "run-${testScript.name}" {
- inherit testScript userData;
-
- passthru.tests = {
- clang-tidy = runCommand "run-${testScript.name}-clang-tidy" {
- nativeBuildInputs = [ clang-tools ];
- } ''
- clang-tidy --config-file=${../../../.clang-tidy} --warnings-as-errors='*' \
- ${lib.escapeShellArgs (map (flag: "--extra-arg=${flag}") cflags)} \
- ${./test.c}
- touch $out
- '';
- };
-} ''
- export QEMU_SYSTEM='qemu-system-${stdenv.hostPlatform.qemuArch} -nographic'
- $testScript
- touch $out
-'') (_: {})
diff --git a/release/checks/pkg-tests.nix b/release/checks/pkg-tests.nix
index 97baaf3..cf58603 100644
--- a/release/checks/pkg-tests.nix
+++ b/release/checks/pkg-tests.nix
@@ -9,7 +9,7 @@ import ../../lib/call-package.nix (
lseek = lib.recurseIntoAttrs lseek.tests;
- networking = lib.recurseIntoAttrs (callSpectrumPackage ./networking {}).tests;
+ integration = lib.recurseIntoAttrs (callSpectrumPackage ./integration {}).tests;
start-vmm = lib.recurseIntoAttrs start-vmm.tests;
--
2.49.0
next prev parent reply other threads:[~2025-06-13 14:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 14:05 [PATCH 0/8] Change serial getty instances dynamically Alyssa Ross
2025-06-13 14:05 ` [PATCH 1/8] host/rootfs: poll active consoles for serial getty Alyssa Ross
2025-06-28 19:54 ` Alyssa Ross
2025-06-13 14:05 ` Alyssa Ross [this message]
2025-06-28 19:54 ` [PATCH 2/8] release/checks/integration: init from networking Alyssa Ross
2025-06-13 14:05 ` [PATCH 3/8] release/checks/integration: use default Meson timeout Alyssa Ross
2025-06-13 14:05 ` [PATCH 4/8] release/checks/integration: extract config struct Alyssa Ross
2025-06-28 19:54 ` Alyssa Ross
2025-06-13 14:05 ` [PATCH 5/8] release/checks/integration: run from tmpdir Alyssa Ross
2025-06-13 14:05 ` [PATCH 6/8] release/checks/integration: name QEMU arg pointers Alyssa Ross
2025-06-28 19:54 ` Alyssa Ross
2025-06-13 14:05 ` [PATCH 7/8] release/checks/integration: extract library Alyssa Ross
2025-06-28 19:54 ` Alyssa Ross
2025-06-13 14:05 ` [PATCH 8/8] release/checks/integration: test late serial Alyssa Ross
2025-06-28 19:54 ` 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=20250613140508.76998-3-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=devel@spectrum-os.org \
--cc=yuka@yuka.dev \
/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).