nixosTests: switch from deprecated copy_from_vm to copy_from_machine

This commit is contained in:
Jacek Galowicz
2026-04-21 10:14:49 +00:00
committed by Jacek Galowicz
parent 786d0f4374
commit f99f026911
23 changed files with 38 additions and 38 deletions

View File

@@ -140,7 +140,7 @@
machine.succeed(f"pkill {gui_app}", timeout=5)
machine.succeed("echo 'test completed succeessfully' > /${testName}", timeout=5)
machine.copy_from_vm('/${testName}')
machine.copy_from_machine('/${testName}')
machine.shutdown()
'';

View File

@@ -36,7 +36,7 @@
# wait until the pdf files are completely produced and readable by alice
machine.wait_until_succeeds(f"su - alice -c 'pdfinfo /var/spool/cups-pdf-{name}/users/alice/*.pdf'")
machine.succeed(f"cp /var/spool/cups-pdf-{name}/users/alice/*.pdf /tmp/{name}.pdf")
machine.copy_from_vm(f"/tmp/{name}.pdf", "")
machine.copy_from_machine(f"/tmp/{name}.pdf", "")
run(f"${lib.getExe hostPkgs.imagemagickBig} -density 300 $out/{name}.pdf $out/{name}.jpeg", shell=True, check=True)
assert text.encode() in run(f"${lib.getExe hostPkgs.tesseract} $out/{name}.jpeg stdout", shell=True, check=True, capture_output=True).stdout
'';

View File

@@ -91,7 +91,7 @@
"${exe} file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga >&2 &"
)
wait_for_sound(machine)
machine.copy_from_vm("/tmp/record.wav")
machine.copy_from_machine("/tmp/record.wav")
with subtest("Close sound test tab"):
machine.execute("xdotool key ctrl+w")

View File

@@ -270,7 +270,7 @@ let
server.succeed("${serverSystem}/specialisation/dump/bin/switch-to-configuration test")
server.systemctl("start forgejo-dump")
assert "Zstandard compressed data" in server.succeed("file ${dumpFile}")
server.copy_from_vm("${dumpFile}")
server.copy_from_machine("${dumpFile}")
'';
};
in

View File

@@ -59,7 +59,7 @@
lib.pipe nodes [
builtins.attrNames
(map (node: ''
${node}.copy_from_vm(
${node}.copy_from_machine(
${node}.succeed("readlink -f /etc/locale.conf").strip(),
"${node}"
)

View File

@@ -80,6 +80,6 @@ in
'LOCALE': 'en_US',
})
machine.succeed(f"curl 'localhost:${toString port}/process?{query}' -o ./audio.wav")
machine.copy_from_vm("./audio.wav")
machine.copy_from_machine("./audio.wav")
'';
}

View File

@@ -223,7 +223,7 @@ in
appservice.wait_for_open_port(11111)
with subtest("copy the registration file"):
appservice.copy_from_vm("/var/lib/matrix-appservice-irc/registration.yml")
appservice.copy_from_machine("/var/lib/matrix-appservice-irc/registration.yml")
homeserver.copy_from_host(
str(pathlib.Path(os.environ.get("out", os.getcwd())) / "registration.yml"), "/"
)

View File

@@ -114,7 +114,7 @@
machine.wait_for_text("alice@machine")
machine.send_chars("test-wayland\n")
machine.wait_for_file("/tmp/test-wayland-exit-ok")
machine.copy_from_vm("/tmp/test-wayland.out")
machine.copy_from_machine("/tmp/test-wayland.out")
machine.screenshot("foot_wayland_info")
# please actually register that we want to close the window
@@ -135,7 +135,7 @@
machine.wait_for_text("alice@machine")
machine.send_chars("test-x11\n")
machine.wait_for_file("/tmp/test-x11-exit-ok")
machine.copy_from_vm("/tmp/test-x11.out")
machine.copy_from_machine("/tmp/test-x11.out")
machine.screenshot("alacritty_glinfo")
# please actually register that we want to close the window

View File

@@ -108,7 +108,7 @@
machine.wait_for_text(r"(alice|machine)")
machine.send_chars("test-wayland\n")
machine.wait_for_file("/tmp/test-wayland-exit-ok")
machine.copy_from_vm("/tmp/test-wayland.out")
machine.copy_from_machine("/tmp/test-wayland.out")
machine.screenshot("foot_wayland_info")
# please actually register that we want to close the window
@@ -128,7 +128,7 @@
machine.wait_for_text(r"(alice|machine)")
machine.send_chars("test-x11\n")
machine.wait_for_file("/tmp/test-x11-exit-ok")
machine.copy_from_vm("/tmp/test-x11.out")
machine.copy_from_machine("/tmp/test-x11.out")
machine.screenshot("alacritty_glinfo")
# please actually register that we want to close the window

View File

@@ -140,7 +140,7 @@ in
# to perform the following test:
client.fail(f"{mpc} -h serverPulseAudio status")
# For inspecting these files
serverALSA.copy_from_vm("/run/mpd/mpd.conf", "ALSA")
serverPulseAudio.copy_from_vm("/run/mpd/mpd.conf", "PulseAudio")
serverALSA.copy_from_machine("/run/mpd/mpd.conf", "ALSA")
serverPulseAudio.copy_from_machine("/run/mpd/mpd.conf", "PulseAudio")
'';
}

View File

@@ -95,6 +95,6 @@ in
## Check that it contains the title of the score
machine.succeed('pdfgrep "Untitled score" "/root/Untitled score.pdf"')
machine.copy_from_vm("/root/Untitled score.pdf")
machine.copy_from_machine("/root/Untitled score.pdf")
'';
}

View File

@@ -78,11 +78,11 @@ in
with subtest("debugging: /dev/video0 works"):
machine.succeed("v4l2-ctl --all >&2")
machine.succeed("fswebcam --no-banner /tmp/webcam.jpg")
machine.copy_from_vm("/tmp/webcam.jpg", "webcam")
machine.copy_from_machine("/tmp/webcam.jpg", "webcam")
# scan with the webcam
machine.succeed("scanimage -o /tmp/scan.png >&2")
machine.copy_from_vm("/tmp/scan.png", "scan")
machine.copy_from_machine("/tmp/scan.png", "scan")
# the image should contain "${text}"
output = machine.succeed("tesseract /tmp/scan.png -")

View File

@@ -79,7 +79,7 @@
with subtest("Environment variables have been substituted"):
base.succeed("grep -q somesecret /run/searx/settings.yml")
base.copy_from_vm("/run/searx/settings.yml")
base.copy_from_machine("/run/searx/settings.yml")
with subtest("Basic setup is working"):
base.wait_for_open_port(8080)

View File

@@ -148,7 +148,7 @@
machine.send_chars("test-x11\n")
machine.wait_for_file("/tmp/test-x11-exit-ok")
print(machine.succeed("cat /tmp/test-x11.out"))
machine.copy_from_vm("/tmp/test-x11.out")
machine.copy_from_machine("/tmp/test-x11.out")
machine.screenshot("alacritty_glinfo")
machine.succeed("pkill alacritty")
@@ -160,7 +160,7 @@
machine.send_chars("test-wayland\n")
machine.wait_for_file("/tmp/test-wayland-exit-ok")
print(machine.succeed("cat /tmp/test-wayland.out"))
machine.copy_from_vm("/tmp/test-wayland.out")
machine.copy_from_machine("/tmp/test-wayland.out")
machine.screenshot("foot_wayland_info")
machine.send_key("alt-shift-q")
machine.wait_until_fails("pgrep foot")

View File

@@ -149,7 +149,7 @@
machine.send_chars("test-x11\n")
machine.wait_for_file("/tmp/test-x11-exit-ok")
print(machine.succeed("cat /tmp/test-x11.out"))
machine.copy_from_vm("/tmp/test-x11.out")
machine.copy_from_machine("/tmp/test-x11.out")
machine.screenshot("alacritty_glinfo")
machine.succeed("pkill alacritty")
@@ -161,7 +161,7 @@
machine.send_chars("test-wayland\n")
machine.wait_for_file("/tmp/test-wayland-exit-ok")
print(machine.succeed("cat /tmp/test-wayland.out"))
machine.copy_from_vm("/tmp/test-wayland.out")
machine.copy_from_machine("/tmp/test-wayland.out")
machine.screenshot("foot_wayland_info")
machine.send_key("alt-shift-q")
machine.wait_until_fails("pgrep foot")

View File

@@ -227,7 +227,7 @@ in
})
+ ''
# Useful for debugging later
machine.copy_from_vm("${configPath}", "before")
machine.copy_from_machine("${configPath}", "before")
machine.systemctl("restart syncthing-init.service")
machine.wait_for_unit("syncthing-init.service")
@@ -237,13 +237,13 @@ in
})
+ ''
# Useful for debugging later
machine.copy_from_vm("${configPath}", "after")
machine.copy_from_machine("${configPath}", "after")
# Copy the systemd unit's bash script, to inspect it for debugging.
mergeScript = machine.succeed(
"systemctl cat syncthing-init.service | "
"${pkgs.initool}/bin/initool g - Service ExecStart --value-only"
).strip() # strip from new lines
machine.copy_from_vm(mergeScript, "")
machine.copy_from_machine(mergeScript, "")
'';
}

View File

@@ -44,7 +44,7 @@
# We copy the main graph into the $out (toplevel), and we also copy
# the entire output directory with additional data
with subtest("Copying the resulting data into $out"):
machine.copy_from_vm("systemd-analyze/", "")
machine.copy_from_vm("systemd-analyze/systemd-analyze.svg", "")
machine.copy_from_machine("systemd-analyze/", "")
machine.copy_from_machine("systemd-analyze/systemd-analyze.svg", "")
'';
}

View File

@@ -37,7 +37,7 @@
with subtest("interactive shell with terminal in capsule"):
hello_output = machine.succeed("systemd-run -t --capsule=alice /run/current-system/sw/bin/bash -i -c 'hello | tee ~/hello'")
assert hello_output == "Hello, world!\r\n"
machine.copy_from_vm("/var/lib/capsules/alice/hello")
machine.copy_from_machine("/var/lib/capsules/alice/hello")
with subtest("capsule cleanup"):
machine.succeed("systemctl --capsule=alice stop sleeptest.service")

View File

@@ -41,7 +41,7 @@
client.succeed("task sync")
# Useful for debugging
client.copy_from_vm("/root/.task", "client")
server.copy_from_vm("${cfg.dataDir}", "server")
client.copy_from_machine("/root/.task", "client")
server.copy_from_machine("${cfg.dataDir}", "server")
'';
}

View File

@@ -55,13 +55,13 @@
# Make a screenshot and save the result:
machine.screenshot("tinywl_foot")
print(machine.succeed("cat /tmp/test-wayland.out"))
machine.copy_from_vm("/tmp/test-wayland.out")
machine.copy_from_machine("/tmp/test-wayland.out")
# Terminate cleanly:
machine.send_key("alt-esc")
machine.wait_until_fails("pgrep foot")
machine.wait_until_fails("pgrep tinywl")
machine.wait_for_file("/tmp/tinywl-exit-ok")
machine.copy_from_vm("/tmp/tinywl.log")
machine.copy_from_machine("/tmp/tinywl.log")
'';
}

View File

@@ -146,10 +146,10 @@
machine.succeed("scrot --display :0 /tmp/glxgears.png")
# Copy files down.
machine.copy_from_vm("/tmp/glxgears.png")
machine.copy_from_vm("/tmp/glxgears.stdout")
machine.copy_from_vm("/tmp/Xvnc.stdout")
machine.copy_from_vm("/tmp/Xvnc.stderr")
machine.copy_from_machine("/tmp/glxgears.png")
machine.copy_from_machine("/tmp/glxgears.stdout")
machine.copy_from_machine("/tmp/Xvnc.stdout")
machine.copy_from_machine("/tmp/Xvnc.stderr")
'';
}

View File

@@ -113,7 +113,7 @@ in
machine.succeed("run-goupile-test")
out_dir = os.environ.get("out", os.getcwd())
machine.copy_from_vm("/tmp/videos", out_dir)
machine.copy_from_machine("/tmp/videos", out_dir)
'';
# Debug interactively with:

View File

@@ -137,7 +137,7 @@ let
testScript = ''
# save hostapd config file for manual inspection
machine.wait_for_unit("hostapd.service")
machine.copy_from_vm("/run/hostapd/wlan0.hostapd.conf")
machine.copy_from_machine("/run/hostapd/wlan0.hostapd.conf")
${extraTestScript}
'';
@@ -257,7 +257,7 @@ in
machine.succeed("wpa_cli -i wlan0 list_networks | grep -q test2")
# save file for manual inspection
machine.copy_from_vm(config_file)
machine.copy_from_machine(config_file)
# check hardening options
machine.succeed("systemd-analyze security wpa_supplicant >&2")