summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/virtualization/qemu
diff options
context:
space:
mode:
authorRobert Scott <code@humanleg.org.uk>2021-12-03 21:35:35 +0000
committerRobert Scott <code@humanleg.org.uk>2022-02-06 18:31:29 +0000
commit5adc3817a0d658252131b3fe3df08ca134551ebd (patch)
tree719f349bf8e46b78c1af8f0a4985ab2f1f4fba15 /pkgs/applications/virtualization/qemu
parentdf68f3a71e458fb6b1c461d4278554acd8e32ec4 (diff)
qemu: fixup basic tests, enable in passthru.tests
these may not be reliable enough to enable by default, but enabling them as a passthru may allow us to get a feel for which platforms have trouble with them
Diffstat (limited to 'pkgs/applications/virtualization/qemu')
-rw-r--r--pkgs/applications/virtualization/qemu/default.nix42
1 files changed, 40 insertions, 2 deletions
diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix
index c45c519f370c..6fc60629292c 100644
--- a/pkgs/applications/virtualization/qemu/default.nix
+++ b/pkgs/applications/virtualization/qemu/default.nix
@@ -2,7 +2,7 @@
, perl, pixman, vde2, alsa-lib, texinfo, flex
, bison, lzo, snappy, libaio, libtasn1, gnutls, nettle, curl, ninja, meson, sigtool
, makeWrapper, runtimeShell
-, attr, libcap, libcap_ng
+, attr, libcap, libcap_ng, socat
, CoreServices, Cocoa, Hypervisor, rez, setfile
, numaSupport ? stdenv.isLinux && !stdenv.isAarch32, numactl
, seccompSupport ? stdenv.isLinux, libseccomp
@@ -31,6 +31,8 @@
++ ["${stdenv.hostPlatform.qemuArch}-softmmu"])
else null)
, nixosTestRunner ? false
+, doCheck ? false
+, qemu # for passthru.tests
}:
let
@@ -217,7 +219,6 @@ stdenv.mkDerivation rec {
++ lib.optional smbdSupport "--smbd=${samba}/bin/smbd"
++ lib.optional uringSupport "--enable-linux-io-uring";
- doCheck = false; # tries to access /dev
dontWrapGApps = true;
# QEMU attaches entitlements with codesign and strip removes those,
@@ -241,6 +242,40 @@ stdenv.mkDerivation rec {
'';
preBuild = "cd build";
+ # tests can still timeout on slower systems
+ inherit doCheck;
+ checkInputs = [ socat ];
+ preCheck = ''
+ # time limits are a little meagre for a build machine that's
+ # potentially under load.
+ substituteInPlace ../tests/unit/meson.build \
+ --replace 'timeout: slow_tests' 'timeout: 50 * slow_tests'
+ substituteInPlace ../tests/qtest/meson.build \
+ --replace 'timeout: slow_qtests' 'timeout: 50 * slow_qtests'
+ substituteInPlace ../tests/fp/meson.build \
+ --replace 'timeout: 90)' 'timeout: 300)'
+
+ # point tests towards correct binaries
+ substituteInPlace ../tests/unit/test-qga.c \
+ --replace '/bin/echo' "$(type -P echo)"
+ substituteInPlace ../tests/unit/test-io-channel-command.c \
+ --replace '/bin/socat' "$(type -P socat)"
+
+ # combined with a long package name, some temp socket paths
+ # can end up exceeding max socket name len
+ substituteInPlace ../tests/qtest/bios-tables-test.c \
+ --replace 'qemu-test_acpi_%s_tcg_%s' '%s_%s'
+
+ # get-fsinfo attempts to access block devices, disallowed by sandbox
+ sed -i -e '/\/qga\/get-fsinfo/d' -e '/\/qga\/blacklist/d' \
+ ../tests/unit/test-qga.c
+ '' + lib.optionalString stdenv.isDarwin ''
+ # skip test that stalls on darwin, perhaps due to subtle differences
+ # in fifo behaviour
+ substituteInPlace ../tests/unit/meson.build \
+ --replace "'test-io-channel-command'" "#'test-io-channel-command'"
+ '';
+
# Add a ‘qemu-kvm’ wrapper for compatibility/convenience.
postInstall = ''
ln -s $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} $out/bin/qemu-kvm
@@ -248,6 +283,9 @@ stdenv.mkDerivation rec {
passthru = {
qemu-system-i386 = "bin/qemu-system-i386";
+ tests = {
+ qemu-tests = qemu.override { doCheck = true; };
+ };
};
# Builds in ~3h with 2 cores, and ~20m with a big-parallel builder.