diff --git a/lib/test-driver/test-driver.pl b/lib/test-driver/test-driver.pl index 739753baeb1c..88bce47b23f0 100644 --- a/lib/test-driver/test-driver.pl +++ b/lib/test-driver/test-driver.pl @@ -26,7 +26,9 @@ sub runTests { # 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"); + my $gcovDir = "/sys/kernel/debug/gcov"; + + my ($status, $out) = $vm->execute("test -e $gcovDir"); next if $status != 0; # Figure out where to put the *.gcda files so that the report @@ -35,13 +37,8 @@ sub runTests { 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"); + # Copy all the *.gcda files. + $vm->execute("for d in $gcovDir/nix/store/*/.build/linux-*; do for i in \$(cd \$d && find -name '*.gcda'); do echo \$i; mkdir -p $coverageDir/\$(dirname \$i); cp -v \$d/\$i $coverageDir/\$i; done; done"); } } diff --git a/modules/testing/test-instrumentation.nix b/modules/testing/test-instrumentation.nix index 75133b72a22d..4c6b1a54afd5 100644 --- a/modules/testing/test-instrumentation.nix +++ b/modules/testing/test-instrumentation.nix @@ -36,6 +36,10 @@ with pkgs.lib; mkdir /hostfs/$hostTmpDir/coverage-data ln -s /hostfs/$hostTmpDir/coverage-data /tmp/coverage-data ) + + # Mount debugfs to gain access to the kernel coverage data (if + # available). + mount -t debugfs none /sys/kernel/debug || true ''; # If the kernel has been built with coverage instrumentation, make diff --git a/tests/subversion.nix b/tests/subversion.nix index 6f3fe09ccb99..43eba8e16591 100644 --- a/tests/subversion.nix +++ b/tests/subversion.nix @@ -27,7 +27,11 @@ let # special patch to make coverage data available under /proc. kernel = pkgs.kernel.override (orig: { stdenv = cleanupBuildTree (keepBuildTree orig.stdenv); - kernelPatches = orig.kernelPatches ++ pkgs.lib.singleton pkgs.kernelPatches.gcov_2_6_28; + extraConfig = + '' + GCOV_KERNEL y + GCOV_PROFILE_ALL y + ''; }); };