From da0e642c2b12f974d77fce4ed2c180d2fa518970 Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 17 Sep 2015 14:12:24 +0200 Subject: [PATCH] tests/virtualbox: Add systemd-detect-virt subtest. Addresses #9876 in the way that we want to make sure that VirtualBox 5.x is going to be properly detected. Right now the result is "kvm", so the subtest fails as expected with: error: systemd-detect-virt returned "kvm" instead of "oracle" at (eval 14) line 414, <__ANONIO__> line 92. Signed-off-by: aszlig --- nixos/tests/virtualbox.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index a944c9caf35..1a5a6f7b5bb 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -189,6 +189,8 @@ import ./make-test.nix ({ pkgs, ... }: with pkgs.lib; let }; testSubs = '' + my ${"$" + name}_sharepath = '${sharePath}'; + sub checkRunning_${name} { my $cmd = 'VBoxManage list runningvms | grep -q "^\"${name}\""'; my ($status, $out) = $machine->execute(ru $cmd); @@ -295,9 +297,15 @@ import ./make-test.nix ({ pkgs, ... }: with pkgs.lib; let echo "$otherIP reachable" | ${pkgs.netcat}/bin/netcat -clp 5678 || : ''; + sysdDetectVirt = pkgs: '' + ${pkgs.systemd}/bin/systemd-detect-virt > /mnt-root/result + ''; + vboxVMs = mapAttrs createVM { simple = {}; + detectvirt.vmScript = sysdDetectVirt; + test1.vmFlags = hostonlyVMFlags; test1.vmScript = dhcpScript; @@ -381,6 +389,18 @@ in { destroyVM_simple; + subtest "systemd-detect-virt", sub { + createVM_detectvirt; + vbm("startvm detectvirt"); + waitForStartup_detectvirt; + waitForVMBoot_detectvirt; + shutdownVM_detectvirt; + my $result = $machine->succeed("cat '$detectvirt_sharepath/result'"); + chomp $result; + die "systemd-detect-virt returned \"$result\" instead of \"oracle\"" + if $result ne "oracle"; + }; + subtest "net-hostonlyif", sub { createVM_test1; createVM_test2;