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
| | # 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()
'';
}))
|