From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 04/12] code_cov_parse_info: better handle include regexes
Date: Tue, 17 Jan 2023 15:05:59 +0100 [thread overview]
Message-ID: <20230117140607.2759816-5-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230117140607.2759816-1-mauro.chehab@linux.intel.com>
From: Mauro Carvalho Chehab <mchehab@kernel.org>
When there are both exclude and include regexes, the include ones
may be overriding the more generic excluded ones. So, handle them
first.
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
scripts/code_cov_parse_info | 38 ++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/scripts/code_cov_parse_info b/scripts/code_cov_parse_info
index ef44229983b6..3a503423861d 100755
--- a/scripts/code_cov_parse_info
+++ b/scripts/code_cov_parse_info
@@ -34,17 +34,24 @@ sub is_function_excluded($)
my $func = shift;
+ # Handle includes first, as, when there are both include and exclude
+ # includes should take preference, as they can be overriding exclude
+ # rules
+ foreach my $r (@func_include_regexes) {
+ return 0 if ($func =~ m/$r/);
+ }
+
foreach my $r (@func_exclude_regexes) {
return 1 if ($func =~ m/$r/);
}
- return 0 if (!@func_include_regexes);
-
- foreach my $r (@func_include_regexes) {
- return 0 if ($func =~ m/$r/);
+ # If there are no exclude regexes, only include functions that are
+ # explicitly included.
+ if ($#func_exclude_regexes == 0) {
+ return 1;
}
- return 1;
+ return 0;
}
sub is_file_excluded($)
@@ -1193,9 +1200,10 @@ Each line at B<[filter's file]> may contain a new regex:
=back
-When both include and exclude regexes are found, exclude regexes are
-applied first and any functions that don't match the include regular
-expressions from the B<[filter's file]> will be ignored.
+Include regexes are handled first, as they can override an exclude regex.
+
+When just include regexes are used, any functions that don't match the
+include regular expressions from the B<[filter's file]> will be ignored.
Please notice that, when this filter is used, B<--ignore-unused> will be
automaticaly enabled, as the final goal is to report per-function usage.
@@ -1204,7 +1212,8 @@ automaticaly enabled, as the final goal is to report per-function usage.
Include B<regex> to the function filter. Can be used multiple times.
-When used together with B<--func-filters>, regexes here are handled first.
+When used together with B<--func-filters> or B<--exclude-func>, regexes
+here are handled first.
Please notice that, when this filter is used, B<--ignore-unused> will be
automaticaly enabled, as the final goal is to report per-function usage.
@@ -1213,8 +1222,6 @@ automaticaly enabled, as the final goal is to report per-function usage.
Include B<regex> to the function filter. Can be used multiple times.
-When used together with B<--func-filters>, regexes here are handled first.
-
Please notice that, when this filter is used, B<--ignore-unused> will be
automaticaly enabled, as the final goal is to report per-function usage.
@@ -1244,22 +1251,19 @@ Each line at B<[filter's file]> may contain a new regex:
=back
-When both include and exclude regexes are found, exclude regexes are
-applied first and any functions that don't match the include regular
-expressions from the B<[filter's file]> will be ignored.
+Include regexes are handled first, as they can override an exclude regex.
=item B<--include-src> B<regex>
Include B<regex> to the sources filter. Can be used multiple times.
-When used together with B<--src-filters>, regexes here are handled first.
+When used together with B<--src-filters> and B<--exclude-src>, regexes
+here are handled first.
=item B<--exclude-src> B<regex>
Include B<regex> to the sources filter. Can be used multiple times.
-When used together with B<--src-filters>, regexes here are handled first.
-
=item B<--ignore-unused> or B<--ignore_unused>
Filters out unused C files and headers from the code coverage results.
--
2.39.0
next prev parent reply other threads:[~2023-01-17 14:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 14:05 [igt-dev] [PATCH i-g-t 00/12] Improve code coverage tool Mauro Carvalho Chehab
2023-01-17 14:05 ` [igt-dev] [PATCH i-g-t 01/12] code_cov_parse_info: silent some messages by default Mauro Carvalho Chehab
2023-01-17 14:05 ` [igt-dev] [PATCH i-g-t 02/12] code_cov_parse_info: do some renames to make it more coherent Mauro Carvalho Chehab
2023-01-17 14:05 ` [igt-dev] [PATCH i-g-t 03/12] code_cov_parse_info: use numberic sort for line numbers Mauro Carvalho Chehab
2023-01-17 14:05 ` Mauro Carvalho Chehab [this message]
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 05/12] code_cov_parse_info: add a tool to analyze branch coverage Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 06/12] code_cov_parse_info: add support for parsing JSON files Mauro Carvalho Chehab
2023-01-25 14:18 ` Kamil Konieczny
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 07/12] code_cov_parse_info: add support for compressed files Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 08/12] code_cov_parse_info: allow specifying the source directory Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 09/12] code_cov_parse_info: better handle branch filtering Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 10/12] code_cov_parse_info: filter out branches from headers by default Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 11/12] code_cov_parse_info: add support for filtering branches Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 12/12] code_cov_parse_info: add support for filtering Xe driver data Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230117140607.2759816-5-mauro.chehab@linux.intel.com \
--to=mauro.chehab@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox