···
-
{ debug ? false, ... } @ args:
-
import ./make-test.nix ({ pkgs, ... }: with pkgs.lib; let
testVMConfig = vmName: attrs: { config, pkgs, ... }: let
guestAdditions = pkgs.linuxPackages.virtualboxGuestAdditions;
···
test2.vmScript = dhcpScript;
-
meta = with pkgs.stdenv.lib.maintainers; {
-
maintainers = [ aszlig wkennington ];
-
machine = { pkgs, lib, config, ... }: {
-
mkVMConf = name: val: val.machine // { key = "${name}-config"; };
-
vmConfigs = mapAttrsToList mkVMConf vboxVMs;
-
in [ ./common/user-account.nix ./common/x11.nix ] ++ vmConfigs;
-
virtualisation.memorySize = 2048;
-
virtualisation.virtualbox.host.enable = true;
-
users.extraUsers.alice.extraGroups = let
-
inherit (config.virtualisation.virtualbox.host) enableHardening;
-
in lib.mkIf enableHardening (lib.singleton "vboxusers");
-
my $esc = $_[0] =~ s/'/'\\${"'"}'/gr;
-
return "su - alice -c '$esc'";
-
$machine->succeed(ru("VBoxManage ".$_[0]));
-
${concatStrings (mapAttrsToList (_: getAttr "testSubs") vboxVMs)}
-
${mkLog "$HOME/.config/VirtualBox/VBoxSVC.log" "HOST-SVC"}
-
subtest "simple-gui", sub {
-
$machine->succeed(ru "VirtualBox &");
-
$machine->waitForWindow(qr/Oracle VM VirtualBox Manager/);
-
$machine->screenshot("gui_manager_started");
-
$machine->sendKeys("ret");
-
$machine->screenshot("gui_manager_sent_startup");
-
waitForStartup_simple (sub {
-
$machine->sendKeys("ret");
-
$machine->screenshot("gui_started");
-
$machine->screenshot("gui_booted");
-
$machine->screenshot("gui_stopped");
-
$machine->sendKeys("ctrl-q");
-
$machine->screenshot("gui_manager_stopped");
-
subtest "simple-cli", sub {
-
$machine->screenshot("cli_started");
-
$machine->screenshot("cli_booted");
-
subtest "privilege-escalation", sub {
$machine->fail("test -e '/root/VirtualBox VMs'");
$machine->fail("test -e '/root/.config/VirtualBox'");
$machine->succeed("test -e '/home/alice/VirtualBox VMs'");
-
return join("\n", grep { $_ !~ /^UUID:/ } split(/\n/, $_[0]))."\n";
-
subtest "host-usb-permissions", sub {
-
my $userUSB = removeUUIDs vbm("list usbhost");
-
my $rootUSB = removeUUIDs $machine->succeed("VBoxManage list usbhost");
-
die "USB host devices differ for root and normal user"
-
if $userUSB ne $rootUSB;
-
die "No USB host devices found" if $userUSB =~ /<none>/;
-
subtest "systemd-detect-virt", sub {
-
vbm("startvm detectvirt");
-
waitForStartup_detectvirt;
-
waitForVMBoot_detectvirt;
-
my $result = $machine->succeed("cat '$detectvirt_sharepath/result'");
-
die "systemd-detect-virt returned \"$result\" instead of \"oracle\""
-
if $result ne "oracle";
-
subtest "net-hostonlyif", sub {
-
$machine->screenshot("net_booted");
-
my $test1IP = waitForIP_test1 1;
-
my $test2IP = waitForIP_test2 1;
-
$machine->succeed("echo '$test2IP' | netcat -c '$test1IP' 1234");
-
$machine->succeed("echo '$test1IP' | netcat -c '$test2IP' 1234");
-
$machine->waitUntilSucceeds("netcat -c '$test1IP' 5678 >&2");
-
$machine->waitUntilSucceeds("netcat -c '$test2IP' 5678 >&2");