From 7937fef2f7be13988e73bc47f4b67b3201203123 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Tue, 3 Oct 2006 10:45:39 +0200 Subject: [PATCH] fix lcov report output --- build.py | 17 ++++++++++++----- utils/lcov/geninfo | 44 +++++++++++++++++++++++++++++++++----------- utils/lcov/lcov | 3 +++ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/build.py b/build.py index 22fe2aeb7..19aeefb27 100644 --- a/build.py +++ b/build.py @@ -30,9 +30,12 @@ import SCons # to get an ARGUMENTS defined correctly try: ARGUMENTS = SCons.Script.ARGUMENTS + COMMAND_LINE_TARGETS = SCons.Script.COMMAND_LINE_TARGETS except AttributeError: from SCons.Script.SConscript import Arguments + from SCons.Script.SConscript import CommandLineTargets ARGUMENTS = Arguments + COMMAND_LINE_TARGETS = CommandLineTargets class Ns3Module: def __init__ (self, name, dir): @@ -350,14 +353,18 @@ class Ns3: gcov_env.Alias ('lcov-report') if 'lcov-report' in COMMAND_LINE_TARGETS: lcov_report_dir = os.path.join (self.build_dir, 'lcov-report') - create_dir_command = "rm -rf " + lcov_report_dir + - " && mkdir " + lcov_report_dir + ";" + create_dir_command = "rm -rf " + lcov_report_dir + create_dir_command += " && mkdir " + lcov_report_dir + ";" gcov_env.Execute (create_dir_command) info_file = os.path.join (lcov_report_dir, 'ns3.info') - lcov_command = "utils/lcov/lcov -c -d . -o " info_file + lcov_command = "utils/lcov/lcov -c -d . -o " + info_file + lcov_command += " --source-dirs=" + os.getcwd () + lcov_command += ":" + os.path.join (os.getcwd (), + variant.build_root, + 'include') gcov_env.Execute (lcov_command) - genhtml_command = "utils/lcov/genhtml -o " + lcov_report_data + - " " + info_file + genhtml_command = "utils/lcov/genhtml -o " + lcov_report_dir + genhtml_command += " " + info_file gcov_env.Execute (genhtml_command) diff --git a/utils/lcov/geninfo b/utils/lcov/geninfo index c0a3a94ff..2c534dfc8 100755 --- a/utils/lcov/geninfo +++ b/utils/lcov/geninfo @@ -96,6 +96,7 @@ our $graph_file_extension; our $data_file_extension; our @data_directory; our $test_name = ""; +our $source_dirs = ""; our $quiet; our $help; our $output_filename; @@ -141,6 +142,7 @@ if ($config) # Parse command line options if (!GetOptions("test-name=s" => \$test_name, "output-filename=s" => \$output_filename, + "source-dirs=s" => \$source_dirs, "no-checksum" => \$nochecksum, "version" =>\$version, "quiet" => \$quiet, @@ -705,6 +707,28 @@ sub process_dafile($) } +# cleanup_path (path) +sub cleanup_path($@) +{ + my $result = shift @_; + + # Remove // + $result =~ s/\/\//\//g; + + # Remove . + $result =~ s/\/\.\//\//g; + + # Solve .. + while ($result =~ s/\/[^\/]+\/\.\.\//\//) + { + } + + # Remove preceding .. + $result =~ s/^\/\.\.\//\//g; + + return $result; +} + # # solve_relative_path(path, dir) # @@ -724,19 +748,17 @@ sub solve_relative_path($$) $result = "$path/$result"; } - # Remove // - $result =~ s/\/\//\//g; + $result = cleanup_path ($result); - # Remove . - $result =~ s/\/\.\//\//g; - - # Solve .. - while ($result =~ s/\/[^\/]+\/\.\.\//\//) - { + if (-f $result) { + return $result; + } + for my $prefix (split (':', $source_dirs)) { + $result = cleanup_path ("$prefix/$dir"); + if (-f $result) { + return $result; + } } - - # Remove preceding .. - $result =~ s/^\/\.\.\//\//g; return $result; } diff --git a/utils/lcov/lcov b/utils/lcov/lcov index 32c2fbd7d..706bb5101 100755 --- a/utils/lcov/lcov +++ b/utils/lcov/lcov @@ -134,6 +134,7 @@ our $reset; # If set, reset all coverage data to zero our $capture; # If set, capture data our $output_filename; # Name for file to write coverage data to our $test_name = ""; # Test case name +our $source_dirs = ""; our $quiet = ""; # If set, suppress information messages our $help; # Help option flag our $version; # Version option flag @@ -196,6 +197,7 @@ if (!GetOptions("directory|d|di=s" => \@directory, "capture|c" => \$capture, "output-file=s" => \$output_filename, "test-name=s" => \$test_name, + "source-dirs=s" => \$source_dirs, "zerocounters" => \$reset, "quiet" => \$quiet, "help" => \$help, @@ -456,6 +458,7 @@ sub userspace_capture() { @param = (@param, "--no-checksum"); } + @param = (@param, "--source-dirs", $source_dirs); system(@param); exit($? >> 8);