Skip to content

Differential coverage, date binning, various new features and refactoring - #169

Closed
henry2cox wants to merge 1 commit into
linux-test-project:masterfrom
henry2cox:diffcov_merge
Closed

henry2cox wants to merge 1 commit into
linux-test-project:masterfrom
henry2cox:diffcov_merge

Conversation

@henry2cox

@henry2cox henry2cox commented Nov 10, 2022 •

Copy link
Copy Markdown
Collaborator

this PR subsumes PR #86 which was created some time ago.
It contains all the same code, adds all the same features, and makes all the same changes.
The only substantial change vs the 'diffcov_initial' branch mentioned in #86 is (automated) reformatting of code.

The aim of the new branch - and the aim of this PR - is to make it very easy to merge to master.

Commit comment from merge branch says it all:

(Squashed commit of all changes from the 'diffcov_initial' branch:)
New features and enhancements (compared to lcov 1.16):

New features and capabilities fall into 6 major categories:

a) Categorization

 This refers primarily to differentical coverage categorization as
 well as date- and owner-binning.  See https://arxiv.org/abs/2008.07947
 or https://ieeexplore.ieee.org/document/9438597 for a detailed
 description of the concepts and discussion of several possible use models.
 A video presentation of the basic ideas can be found at
 http://doi.org/10.5281/zenodo.4653252

 Differential categorization and binning are orthogonal in the sense
 that you can generate differential report without binning as well
 as 'vanilla' coverage reports with binning.  See the above papers
 and the genhtml man page for details.

 Related options:
    --baseline-file, --diff-file, --annotate-script, --date-bins,
    --new-file-as-baseline, --elide-path-mismtach

b) Error handling

 A generic - but very simple - error handler has been added to the
 lcov tool suite.  The error handler is used to report exceptions,
 and provides a mechanism for the user to ignore the particular
 message if desired.
 See the genhtml/lcov/geninfo man pages for details.

 Note that some errors are unrecoverable - and cannot be suppressed or
 ignored.

 Related options:  --ignore-error, --keep-going

c) Navigation and display:

 Navigation aids such as hyperlinks to the first uncovered region,
 to the next uncovered region, etc. have been implemented.  Similarly,
 new tables, new columns, and new links between tables enable the
 user to identify the author of particular code (covered or not
 covered), as well as the time period when the code was written.

 Collectively, these features help the user to quickly identify the
 cause of code coverage issues, and to then decide what to do.

 An option to generate a 'hierarchical' coverage report (which follows
 the source code directory structure) as well as various other small
 features (tooltip popups, user-specified HTML header, footer, and
 table labels, etc.) are also available.

 See the genhtml man page for some details, as well as the
 'gendiffcov/simple' testcases for some examples.

  Related options:
      --baseline-title, --baseline-date, --current-date, --hierarchical,
      --show-owners, --show-noncode, --show-navigation

d) Data manipulation

 Filters are used to suppress or remove certain coverage artifacts -
 for example, branches generated by the compiler (e.g., for exception
 handling).  These artifacts can overwhelm the user code and obscure
 coverage features that are interesting to the user.

 Other options are used to focus on or to exclude certain sections
 of code, as well as to do regexp replacement of file names.
 (Path munging is useful primarily when the build structure does
 not exactly match the layout in your revision control system; this
 is common in large projects with reusable components.)

 See the lcov/geninfo/genhtml man pages for a detailed description of
 the available filters and manipulation features.

 Related options:
    --include, --exclude, --omit-lines, --substitute, --filter

e) Callbacks/customization

 The user can supply callbacks which are used to:

i) interface with the revision control system
   Sample scripts:
     - Perforce:  see 'p4diff' and 'p4annotate'
     - Git: see 'gitdiff' and 'gitblame'
ii) verify that source code versions are compatible, and 
     - Sample scripts: see 'get_signature', 'getp4version' 
iii) enforce a desired code coverage criteria
      -  Sample script: criteria

See the genhtml/lcov/geninfo man pages for details.

Note that the various sample scripts are found in the source code 'bin'
directory, but are installed in the $LCOV_HOME/share/lcov/support-scripts
directory of the release.

Related options:
--annotate-script, --criteria-script, --version-script

f) Performance

 lcov/genhtml/geninfo have been refactored to parallelize computation
 across multiple cores, if requested.
 In general, this provides speedup that is nearly linear in the number
 of cores.
 There is also an option to throttle parallelism to not exceed peak
 memory consumption contraints, as well as options to enable simple
 profile data collection - so you can see where time in going and
 thus to hint at potential optimizations.  The 'spreadsheet.py
 script can be used to view generated profile data.

 See the genhtml/lcov/geninfo man pages for details

 Related options: --parallel, --memory, --profile

In general, the new features and options are implemented uniformly in lcov, genhtml, and geninfo. Most of the features can be enabled/disabled using either command line options or by setting defaults in your 'lcovrc' file. See the lcovrc man page for details.

Finally - and of interest onl to developers - the various lcov-related scripts have been refactored to use a common utility library. See the code in .../lib/lcovutil.pm for details.

Signed-off-by: Henry Cox henry.cox@mediatek.com

New features and enhancements (compared to lcov 1.16):

New features and capabilities fall into 6 major categories:

  a) Categorization

     This refers primarily to differentical coverage categorization as
     well as date- and owner-binning.  See https://arxiv.org/abs/2008.07947
     or https://ieeexplore.ieee.org/document/9438597 for a detailed
     description of the concepts and discussion of several possible use models.
     A video presentation of the basic ideas can be found at
     http://doi.org/10.5281/zenodo.4653252

     Differential categorization and binning are orthogonal in the sense
     that you can generate differential report without binning as well
     as 'vanilla' coverage reports with binning.  See the above papers
     and the genhtml man page for details.

     Related options:
        --baseline-file, --diff-file, --annotate-script, --date-bins,
        --new-file-as-baseline, --elide-path-mismtach

  b) Error handling

     A generic - but very simple - error handler has been added to the
     lcov tool suite.  The error handler is used to report exceptions,
     and provides a mechanism for the user to ignore the particular
     message if desired.
     See the genhtml/lcov/geninfo man pages for details.

     Note that some errors are unrecoverable - and cannot be suppressed or
     ignored.

     Related options:  --ignore-error, --keep-going

  c) Navigation and display:

     Navigation aids such as hyperlinks to the first uncovered region,
     to the next uncovered region, etc. have been implemented.  Similarly,
     new tables, new columns, and new links between tables enable the
     user to identify the author of particular code (covered or not
     covered), as well as the time period when the code was written.

     Collectively, these features help the user to quickly identify the
     cause of code coverage issues, and to then decide what to do.

     An option to generate a 'hierarchical' coverage report (which follows
     the source code directory structure) as well as various other small
     features (tooltip popups, user-specified HTML header, footer, and
     table labels, etc.) are also available.

     See the genhtml man page for some details, as well as the
     'gendiffcov/simple' testcases for some examples.

      Related options:
          --baseline-title, --baseline-date, --current-date, --hierarchical,
          --show-owners, --show-noncode, --show-navigation

  d) Data manipulation

     Filters are used to suppress or remove certain coverage artifacts -
     for example, branches generated by the compiler (e.g., for exception
     handling).  These artifacts can overwhelm the user code and obscure
     coverage features that are interesting to the user.

     Other options are used to focus on or to exclude certain sections
     of code, as well as to do regexp replacement of file names.
     (Path munging is useful primarily when the build structure does
     not exactly match the layout in your revision control system; this
     is common in large projects with reusable components.)

     See the lcov/geninfo/genhtml man pages for a detailed description of
     the available filters and manipulation features.

     Related options:
        --include, --exclude, --omit-lines, --substitute, --filter

  e) Callbacks/customization

     The user can supply callbacks which are used to:

        i) interface with the revision control system
           Sample scripts:
             - Perforce:  see 'p4diff' and 'p4annotate'
             - Git: see 'gitdiff' and 'gitblame'
        ii) verify that source code versions are compatible, and
            Sample scripts: see 'get_signature', 'getp4version'
        iii) enforce a desired code coverage criteria
             Sample script: criteria

     See the genhtml/lcov/geninfo man pages for details.

     Note that the various sample scripts are found in the source code 'bin'
     directory, but are installed in the $LCOV_HOME/share/lcov/support-scripts
     directory of the release.

     Related options:
       --annotate-script, --criteria-script, --version-script

  f) Performance

     lcov/genhtml/geninfo have been refactored to parallelize computation
     across multiple cores, if requested.
     In general, this provides speedup that is nearly linear in the number
     of cores.
     There is also an option to throttle parallelism to not exceed peak
     memory consumption contraints, as well as options to enable simple
     profile data collection - so you can see where time in going and
     thus to hint at potential optimizations.  The 'spreadsheet.py
     script can be used to view generated profile data.

     See the genhtml/lcov/geninfo man pages for details

     Related options: --parallel, --memory, --profile

In general, the new features and options are implemented uniformly in lcov,
genhtml, and geninfo.  Most of the features can be enabled/disabled
using either command line options or by setting defaults in your 'lcovrc'
file.  See the lcovrc man page for details.

Finally - and of interest onl to developers - the various lcov-related
scripts have been refactored to use a common utility library.
See the code in .../lib/lcovutil.pm for details.

Signed-off-by:  Henry Cox <henry.cox@mediatek.com>
@henry2cox

Copy link
Copy Markdown
Collaborator Author

I just fixed a few typos and updated the PR (force-push - sorry about that).
At Peter's request/suggestion, I'm cleaning up a bit so this can be safely merged.

Comment thread Makefile
# Set this variable during 'make install' to specify the Perl interpreter used in
# installed scripts, or leave empty to keep the current interpreter.
export LCOV_PERL_PATH := /usr/bin/perl
export LCOV_PERL_PATH := /usr/bin/env perl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to change this for the default case - the default should be that anything installed in /usr/bin specifies exactly how it needs to be run, including the full path to the associated script interpreter. Having /usr/bin/env in the mix for these installed files will change the behavior of global binaries depending on the path setting of each user. If there's a need to use env for installed files, a user can simply specify LCOV_PERL_PATH as part of the make install invocation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way is fine.
The main issue for me (and I suspect, for many other companies) is that some systems are pretty old, and their /usr/bin tools can be archaic. As a result, we very strongly recommend everyone to write scripts with /usr/bin/env.
But - a workaround exists, so this is not a major concern in this case.

Comment thread bin/checkstyle.sh
# Return absolute path
function realpath() {
local path="$1"
local path="$1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to switch to spaces for shell scripts as well? The current .editorconfig supports the 8-character tab indentation type instead which is also what I'd prefer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, either way is fine - though file-level consistency is important.
I guess we could augment the checks to look for anything that ends in .sh or .csh or whose first line matches #!.*(sh,ksh,bash,csh,tcsh) - and substitute spaces for tabs (or vice versa).

Comment thread bin/checkstyle.sh
# diff is default mode
MODE=${MODE:-diff}
MODE=${MODE@L}
#MODE=${MODE@L}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason why you commented this out?

@henry2cox

henry2cox commented Nov 16, 2022 via email

Copy link
Copy Markdown
Collaborator Author

@oberpar

oberpar commented Nov 17, 2022

Copy link
Copy Markdown
Contributor

Applied as 5f659f6 with the following minor changes:

  • revert changes to LCOV_PERL_PATH
  • revert indentation changes to existing shell scripts
  • whitespace fixes
  • add subject line
  • fixed typos in commit message

Thanks for your contribution and persistence in getting it merged :) And looking forward to a productive cooperation going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants