MantisBT - CMake
View Issue Details
0011717CMakeCTestpublic2011-01-17 17:212012-07-09 06:52
Marco Craveiro 
David Cole 
normalminoralways
closedfixed 
LinuxUbuntu10.10
CMake 2.8.3 
CMake 2.8.7CMake 2.8.7 
0011717: gcov: handling the same file name in different directories
i've been trying to use ctest's coverage support on a project that uses
the same file name in different directories, e.g.:

serialisation/some_class_name.hpp
streaming/some_class_name.hpp
...

due to the parameters passed in to gcov by ctest, this results in naming
clashes when generating the *.gcov files from the different *.gcda input
files.

symptoms of this problem:
-------------------------
1. errors such as:

  Error(s) while accumulating results:
  Problem reading source file: some_file_name line:45 out total: 49
  Looks like there are more lines in the file: };
  Looks like there are more lines in the file:
  Looks like there are more lines in the file:
<snip>

debugging ctest revealed that each of these is actually an error in a
different file, all of which suffering from the name clashing.

2. an error at the end of ctest even though the submission is
successful:

<snip>
   Submission successful
Error in read script: some_ctest_script.cmake
the following steps assume a linux environment with all development tools installed (gcov, gcc, cmake, tar, etc).

1. download the attachment cmake_gcov_bug.tgz. it contains the smallest amount of code i could come up with that illustrates the problem.
2. unpack it by running:

$ tar -zxf cmake_gcov_bug.tgz

3. run ctest:

$ cd cmake_gcov_bug
$ ctest -S CTest.cmake -VV

4. An error will occur:

<snip>
Error(s) while accumulating results:
  Looks like there are more lines in the file: class some_class_a
<snip>
Error in read script: /home/marco/code/cmake_gcov_bug/CTest.cmake
- the errors occur due to the gcov parameters passed in, which result in using "short" filenames.

- the problem should be fixed by adding the flag -p (--preserve-paths) to the gcov invocation in cmCTestCoverageHandler::HandleGCovCoverage (Source/CTest/cmCTestCoverageHandler.cxx). this code uses the gcov generated filename to process the file and works correctly with a longer filename.

- once processed into a SingleFileCoverageVector, it appears nothing else relies on the original gcov file name.

- patch will be attached subsequently as only one file can be uploaded from submission form.


No tags attached.
related to 0012415closed David Cole CTest doesn't push all generated coverage files to CDash 
related to 0012490closed David Cole Coverage counts 0 lines when path too long 
tgz cmake_gcov_bug.tgz (1,086) 2011-01-17 17:21
https://public.kitware.com/Bug/file/3640/cmake_gcov_bug.tgz
patch 0001-use-the-preserve-paths-flag-when-invoking-gcov-to-av.patch (1,255) 2011-01-17 17:22
https://public.kitware.com/Bug/file/3641/0001-use-the-preserve-paths-flag-when-invoking-gcov-to-av.patch
Issue History
2011-01-17 17:21Marco CraveiroNew Issue
2011-01-17 17:21Marco CraveiroFile Added: cmake_gcov_bug.tgz
2011-01-17 17:22Marco CraveiroFile Added: 0001-use-the-preserve-paths-flag-when-invoking-gcov-to-av.patch
2011-01-21 14:53Marco CraveiroNote Added: 0025009
2011-01-21 14:56Marco CraveiroNote Edited: 0025009bug_revision_view_page.php?bugnote_id=25009#r153
2011-01-26 09:35David ColeAssigned To => David Cole
2011-01-26 09:35David ColeStatusnew => assigned
2011-02-09 16:10David ColeNote Added: 0025360
2011-02-09 16:10David ColeStatusassigned => resolved
2011-02-09 16:10David ColeResolutionopen => fixed
2011-02-16 11:43David ColeTarget Version => CMake 2.8.5
2011-02-16 11:43David ColeSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=205#r205
2011-06-06 18:25David ColeStatusresolved => closed
2011-06-06 18:25David ColeNote Added: 0026720
2011-06-17 18:23David ColeFixed in Version => CMake 2.8.5
2011-06-17 18:23David ColeSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=362#r362
2011-10-05 17:31David ColeRelationship addedrelated to 0012415
2011-10-05 17:32David ColeRelationship addedrelated to 0012490
2011-10-22 11:11David ColeNote Added: 0027614
2011-10-22 11:11David ColeStatusclosed => feedback
2011-10-22 11:11David ColeResolutionfixed => reopened
2011-10-22 11:11David ColeFixed in VersionCMake 2.8.5 =>
2011-10-22 11:11David ColeTarget VersionCMake 2.8.5 => CMake 2.8.7
2011-10-22 11:16David ColeNote Added: 0027615
2011-10-22 11:16David ColeStatusfeedback => resolved
2011-10-22 11:16David ColeFixed in Version => CMake 2.8.7
2011-10-22 11:16David ColeResolutionreopened => fixed
2012-07-09 06:52David ColeNote Added: 0029972
2012-07-09 06:52David ColeStatusresolved => closed

Notes
(0025009)
Marco Craveiro   
2011-01-21 14:53   
(edited on: 2011-01-21 14:56)
Maximum filename size problem

One potential problem with this patch is creating filenames which are larger than the filesystem's filename size. For instance for Ext4 it appears to be 256 bytes [1]; because gcov concatenates both the full path to the CPP file as well as the full path to the header file, its not difficult to exceed 256 bytes.

[1] For details of filename sizes for different filesystems, see: http://en.wikipedia.org/wiki/Comparison_of_file_systems [^]

(0025360)
David Cole   
2011-02-09 16:10   
Fix pushed to 'next'
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6e02a3b2bf43f4785bb21eb1cf8bbc26ac1abc12 [^]
(0026720)
David Cole   
2011-06-06 18:25   
Closing resolved issues that have not been updated in more than 3 months.
(0027614)
David Cole   
2011-10-22 11:11   
The hard-coded addition of " -p" in this fix caused related issues 0012415 and 0012490. A different fix is required.
(0027615)
David Cole   
2011-10-22 11:16   
A new, different fix is now in CMake 'next':

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f309cba455d0a946e935f66a53561ba64717faf [^]

In order to add " -p" to the gcov command lines, please append " -p" to the advanced cache variable COVERAGE_EXTRA_FLAGS at CMake configure time. By default, the value of COVERAGE_EXTRA_FLAGS is "-l".

To enable using duplicate file names in your tree with nightly CMake from now on, or with CMake 2.8.7 or later, please set COVERAGE_EXTRA_FLAGS to "-l -p" in your individual build trees.
(0029972)
David Cole   
2012-07-09 06:52   
Closing resolved issues that have not been updated in more than 4 months.