1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
| | # 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, jq, meson, ninja, e2fsprogs, glib, tar2ext4, libressl, qemu_kvm
}:
let
combined = callSpectrumPackage ../../combined {};
live = combined.eosimages.image;
appimage = writeShellScript "test.appimage" ''
#!/bin/execlineb -P
echo hello world
'';
ncVm = callSpectrumPackage ../../../vm/make-vm.nix {} {
providers.net = [ "sys.netvm" ];
type = "nix";
run = writeShellScript "run" ''
set -x
while :; do echo hello | ${libressl.nc}/bin/nc -Nw 2 -6 fd00::2 1234; done
'';
};
portalVm = callSpectrumPackage ../../../vm/make-vm.nix {} {
type = "nix";
run = writeShellScript "run" ''
set -x
${lib.getExe' glib "gdbus"} call --session \
--dest org.freedesktop.portal.Desktop \
--object-path /org/freedesktop/portal/desktop \
--method org.freedesktop.portal.FileChooser.OpenFile \
"" "" '@a{sv} {}' || sleep inf
'';
};
userData = runCommand "user-data.img" {
nativeBuildInputs = [ e2fsprogs tar2ext4 ];
__structuredAttrs = true;
unsafeDiscardReferences = { out = true; };
dontFixup = true;
} ''
tar -Pcvf root.tar \
--transform=s,^${appimage},test.appimage, ${appimage} \
--transform=s,^${ncVm},vms/nc, ${ncVm} \
--transform=s,^${portalVm},vms/portal, ${portalVm}
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.difference
(lib.fileset.intersection src ./.)
(lib.fileset.maybeMissing ./build))
../../../scripts/run-qemu.sh;
};
sourceRoot = "source/release/checks/integration";
nativeBuildInputs = [ meson ninja ];
nativeCheckInputs = [ qemu_kvm ];
doCheck = true;
dontAddTimeoutMultiplier = true;
mesonCheckFlags = lib.optionals stdenv.hostPlatform.isAarch64 [
# Tests are run with TCG on aarch64.
"--timeout-multiplier=15"
];
installPhase = ''
runHook preInstall
cp meson-logs/testlog.txt $out
runHook postInstall
'';
shellHook = ''
unset QEMU_SYSTEM
'';
env = {
QEMU_SYSTEM = "qemu-system-${stdenv.hostPlatform.qemuArch} -nographic";
EFI_PATH = "${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd";
COMBINED_PATH = combined;
LIVE_PATH = live;
USER_DATA_PATH = userData;
};
passthru = {
inherit userData;
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 = [ clang-tools jq ] ++ nativeBuildInputs;
buildPhase = ''
jq -r '.[].file | select(endswith(".c"))' compile_commands.json |
xargs clang-tidy --warnings-as-errors='*'
touch $out
exit 0
'';
}
);
};
};
})) (_: {})
|