Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

section could not be matched when sectionFileName="/xxx/../xx" #351

Open
agfn opened this issue Nov 25, 2021 · 3 comments · May be fixed by #352
Open

section could not be matched when sectionFileName="/xxx/../xx" #351

agfn opened this issue Nov 25, 2021 · 3 comments · May be fixed by #352
Assignees
Labels

Comments

@agfn
Copy link

agfn commented Nov 25, 2021

Describe the bug

When sectionFileName inlcov.info file contains .., function checkSectionAbsolute (used to match coverage section and source file) does not work correctly.

To Reproduce
Steps to reproduce the behaviour:

  1. lcov.info contains the follow content:
SF:/home/lt/projects/libfuzz/json-c/build/../arraylist.c
FN:40,array_list_new
FN:45,array_list_new2
FN:65,array_list_free
FN:75,array_list_get_idx
FN:107,array_list_shrink
FN:130,array_list_put_idx
...
end_of_record
  1. Then, you will found json-c/arraylist.c file will be marked as "No Coverage". Because checkSectionAbsolute only check suffix, and
    sectionFileName is not simplified absolute path.

Expected behaviour

Screenshots

image

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Extension Version: github master brach
  • VSCode Version 1.62.0

Additional context
Add any other context about the problem here.

@agfn
Copy link
Author

agfn commented Nov 25, 2021

can be fixed by the following patch:

--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -1,3 +1,4 @@
+import {normalize} from "path";
 
 /**
  * Finds the matching suffixes of the string, stripping off the non-matching starting characters.
@@ -28,7 +29,7 @@ export function findIntersect(base: string, comparee: string): string {
  * @param fileName File name to remove OS specific features
  */
 export function normalizeFileName(fileName: string): string {
-    let name = fileName;
+    let name = normalize(fileName);
     // make file path relative and OS independent
     name = name.toLocaleLowerCase();
     // remove all file slashes

@ryanluker ryanluker added this to the 2.9.0 milestone Nov 25, 2021
@ryanluker
Copy link
Owner

ryanluker commented Nov 28, 2021

@agfn Thanks for the ticket and the fix! This will go out in 2.9.0 and I will try to get a PR up today for you to review (the fix is pretty much what you added above but I am trying to add some test coverage to prevent regressions in the future).

@ryanluker ryanluker self-assigned this Nov 28, 2021
ryanluker added a commit that referenced this issue Dec 5, 2021
Co-authored-by: ryanluker <[email protected]>
Co-authored-by: agfn <[email protected]>
@ryanluker ryanluker linked a pull request Dec 5, 2021 that will close this issue
@ryanluker ryanluker linked a pull request Dec 5, 2021 that will close this issue
@ryanluker
Copy link
Owner

@agfn I have a first try here at the fix you mentioned #352 there might be a bit of cleanup left over as normalizing the file name causes some other tests to fail 🤔.

The failing tests are just unit level ones though, so most likely just a simple cleanup 😁.

@ryanluker ryanluker modified the milestones: 2.9.0, 2.10.0 Jan 14, 2022
@ryanluker ryanluker modified the milestones: 2.10.0, 2.11.0 Apr 3, 2022
@ryanluker ryanluker removed this from the 2.11.0 milestone May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants