From e7acca2ba3c44d5d2ab3154fb04ce8a0b9d14801 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 1 Sep 2009 22:50:46 +0000 Subject: [PATCH] * Cleanup the kernel coverage analysis. svn path=/nixos/trunk/; revision=16919 --- lib/test-driver/test-driver.pl | 21 +++++++++++++++++++++ modules/testing/test-instrumentation.nix | 5 +++++ tests/subversion.nix | 8 -------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/test-driver/test-driver.pl b/lib/test-driver/test-driver.pl index f76d01199a5d..739753baeb1c 100644 --- a/lib/test-driver/test-driver.pl +++ b/lib/test-driver/test-driver.pl @@ -22,6 +22,27 @@ sub startAll { sub runTests { eval "$context $ENV{tests}"; die $@ if $@; + + # Copy the kernel coverage data for each machine, if the kernel + # has been compiled with coverage instrumentation. + foreach my $vm (values %vms) { + my ($status, $out) = $vm->execute("test -e /proc/gcov"); + next if $status != 0; + + # Figure out where to put the *.gcda files so that the report + # generator can find the corresponding kernel sources. + my $kernelDir = $vm->mustSucceed("echo \$(dirname \$(readlink -f /var/run/current-system/kernel))/.build/linux-*"); + chomp $kernelDir; + my $coverageDir = "/hostfs" . $vm->stateDir() . "/coverage-data/$kernelDir"; + + # Copy all the *.gcda files. The ones under + # /proc/gcov/module/nix/store are the kernel modules in the + # initrd to which we have applied nuke-refs in + # makeModuleClosure. This confuses the gcov module a bit. + $vm->execute("for i in \$(cd /proc/gcov && find -name module -prune -o -name '*.gcda'); do echo \$i; mkdir -p $coverageDir/\$(dirname \$i); cp -v /proc/gcov/\$i $coverageDir/\$i; done"); + + $vm->execute("for i in \$(cd /proc/gcov/module/nix/store/*/.build/* && find -name module -prune -o -name '*.gcda'); do mkdir -p $coverageDir/\$(dirname \$i); cp /proc/gcov/module/nix/store/*/.build/*/\$i $coverageDir/\$i; done"); + } } diff --git a/modules/testing/test-instrumentation.nix b/modules/testing/test-instrumentation.nix index b64dc70ab307..85f892e887f4 100644 --- a/modules/testing/test-instrumentation.nix +++ b/modules/testing/test-instrumentation.nix @@ -31,6 +31,11 @@ with pkgs.lib; ln -s /hostfs/$hostTmpDir/coverage-data /tmp/coverage-data ) ''; + + # If the kernel has been built with coverage instrumentation, make + # it available under /proc/gcov. + boot.kernelModules = [ "gcov-proc" ]; + }; } diff --git a/tests/subversion.nix b/tests/subversion.nix index 481ab12a4abe..5c26c9cd8026 100644 --- a/tests/subversion.nix +++ b/tests/subversion.nix @@ -51,7 +51,6 @@ rec { { config, pkgs, ... }: { - boot.kernelModules = [ "gcov-proc" ]; services.httpd.enable = true; services.httpd.adminAddr = "e.dolstra@tudelft.nl"; services.httpd.extraSubservices = @@ -131,13 +130,6 @@ rec { # Stop Apache to gather all the coverage data. $webserver->stopJob("httpd"); $webserver->execute("sleep 10"); # !!! - - # !!! move this to build-vms.nix - my $kernelDir = $webserver->mustSucceed("echo \$(dirname \$(readlink -f /var/run/current-system/kernel))/.build/linux-*"); - chomp $kernelDir; - my $coverageDir = "/hostfs" . $webserver->stateDir() . "/coverage-data/$kernelDir"; - $webserver->execute("for i in \$(cd /proc/gcov && find -name module -prune -o -name '*.gcda'); do echo \$i; mkdir -p $coverageDir/\$(dirname \$i); cp -v /proc/gcov/\$i $coverageDir/\$i; done"); - $webserver->execute("for i in \$(cd /proc/gcov/module/nix/store/*/.build/* && find -name module -prune -o -name '*.gcda'); do mkdir -p $coverageDir/\$(dirname \$i); cp /proc/gcov/module/nix/store/*/.build/*/\$i $coverageDir/\$i; done"); ''; report = makeReport test;