Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions nixos/lib/test-driver/test-driver.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
8 changes: 5 additions & 3 deletions nixos/lib/testing.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
'';
};
Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
14 changes: 14 additions & 0 deletions nixos/modules/virtualisation/qemu-vm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -106,6 +107,7 @@ let
''} \
$extraDisks \
${qemuGraphics} \
${vncDisplay} \
${toString config.virtualisation.qemu.options} \
$QEMU_OPTS \
$@
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion nixos/tests/keymap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 --";
Expand Down