diff --git a/nixos/lib/test-driver/test-driver.pl b/nixos/lib/test-driver/test-driver.pl index a3354fb0e1eb8..33194fa3ecdcc 100644 --- a/nixos/lib/test-driver/test-driver.pl +++ b/nixos/lib/test-driver/test-driver.pl @@ -158,6 +158,25 @@ sub runTests { } } +sub record { + my ($name, $display) = @_; + + my $n; + for ($n = 899; $n >=0; $n--) { + $log->log("waiting for vnc for $name on display $display"); + last if system("nc -z 127.0.0.1 590$display") == 0; + sleep 1; + } + + $log->log("starting recording for $name on display $display"); + my $recording = Cwd::abs_path "./$name-$display.flv"; + + my $pid = fork(); die "cannot fork" unless defined $pid; + if ($pid == 0) { + exec "flvrec.py -o $recording 127.0.0.1 590$display" or _exit(1); + } + die unless -e "$recording"; +} # Create an empty raw virtual disk with the given name and size (in # MiB). diff --git a/nixos/lib/testing.nix b/nixos/lib/testing.nix index 532fff681d379..007ee1aeb1025 100644 --- a/nixos/lib/testing.nix +++ b/nixos/lib/testing.nix @@ -29,7 +29,7 @@ rec { cp ${./test-driver/Logger.pm} $libDir/Logger.pm wrapProgram $out/bin/nixos-test-driver \ - --prefix PATH : "${lib.makeBinPath [ qemu vde2 netpbm coreutils ]}" \ + --prefix PATH : "${lib.makeBinPath [ qemu vde2 netpbm coreutils vnc2flv netcat ]}" \ --prefix PERL5LIB : "${with perlPackages; lib.makePerlPath [ TermReadLineGnu XMLWriter IOTty FileSlurp ]}:$out/lib/perl5/site_perl" ''; }; @@ -51,6 +51,8 @@ rec { LOGFILE=$out/log.xml tests='eval $ENV{testScript}; die $@ if $@;' ${driver}/bin/nixos-test-driver + cp ./*.flv $out/ # */ + # Generate a pretty-printed log. xsltproc --output $out/log.html ${./test-driver/log2html.xsl} $out/log.xml ln -s ${./test-driver/logfile.css} $out/logfile.css @@ -131,8 +133,8 @@ rec { test = passMeta (runTests driver); report = passMeta (releaseTools.gcovReport { coverageRuns = [ test ]; }); - in (if makeCoverageReport then report else test) // { - inherit nodes driver test; + in (if makeCoverageReport then report else test) // { + inherit nodes driver test; }; runInMachine = diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 26f7945a4eda0..e6b08db5e5ac6 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -35,6 +35,7 @@ let qemuGraphics = if cfg.graphics then "" else "-nographic"; kernelConsole = if cfg.graphics then "" else "console=${serialDevice}"; + vncDisplay = if cfg.vncDisplay == null then "" else "-vnc :${toString cfg.vncDisplay}"; ttys = [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ]; # Shell script to start the VM. @@ -106,6 +107,7 @@ let ''} \ $extraDisks \ ${qemuGraphics} \ + ${vncDisplay} \ ${toString config.virtualisation.qemu.options} \ $QEMU_OPTS \ $@ @@ -247,6 +249,18 @@ in ''; }; + virtualisation.vncDisplay = + mkOption { + default = null; + type = types.int; + description = + '' + If specified, expose a VNC server for the specified display. + It will listen on 5900 + the option, ie: 5, will be + listening on 5905. + ''; + }; + virtualisation.cores = mkOption { default = 1; diff --git a/nixos/tests/keymap.nix b/nixos/tests/keymap.nix index c431c1a341744..726c64d96a886 100644 --- a/nixos/tests/keymap.nix +++ b/nixos/tests/keymap.nix @@ -49,6 +49,7 @@ let machine.i18n.consoleKeyMap = mkOverride 900 layout; machine.services.xserver.layout = mkOverride 900 layout; machine.imports = [ ./common/x11.nix extraConfig ]; + machine.virtualisation.vncDisplay = 0; machine.services.xserver.displayManager.slim = { enable = true; @@ -107,7 +108,8 @@ let die "tests for $desc failed" if $exitcode ne 0; }; } - + $machine->start; + record "machine", 0; $machine->waitForX; mkTest "VT keymap", "openvt -sw --";