Skip to content

Commit

Permalink
lib/lkp_pattern.rb: add parentheses for regexp to obtain the matching…
Browse files Browse the repository at this point in the history
… fragment

In commit dd9da9f, new code was introduced to replace
load_regular_expressions method, but missed to add the surrounding
parentheses, so other code cannot obtain the matching fragment, leading
to many spec failures.

Add the parentheses back to obtain the matching fragment correctly.

== fix issue ==

[    0.861994] sysctl could not get directory: /debug/test_sysctl/mnt/mnt_error -30
----------------

Traceback (most recent call last):
	3: from /lkp/yujie/src/stats/dmesg:107:in `<main>'
	2: from /lkp/yujie/src/stats/dmesg:107:in `each'
	1: from /lkp/yujie/src/stats/dmesg:142:in `block in <main>'
/lkp/yujie/src/lib/dmesg.rb:239:in `analyze_error_id': undefined method `sub' for nil:NilClass (NoMethodError)

Add another spec to ensure the error is correctly captured and parsed.

Fixes: dd9da9f ("lib/lkp_pattern.rb: load pattern by removing line started with # or empty")
Signed-off-by: Yujie Liu <yujie.liu@intel.com>
Signed-off-by: Philip Li <philip.li@intel.com>
  • Loading branch information
Yujie-Liu authored and rli9 committed May 13, 2024
1 parent 508f45b commit 669f7a4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lkp_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def regexp
.reject(&:empty?)
.reject { |line| line.start_with?('#') }

@regexp = Regexp.new lines.join('|')
@regexp = Regexp.new "(#{lines.join('|')})"
end

def patterns
Expand Down
1 change: 1 addition & 0 deletions spec/stats/dmesg/82
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ 0.861994] sysctl could not get directory: /debug/test_sysctl/mnt/mnt_error -30
9 changes: 9 additions & 0 deletions spec/stats/dmesg/82.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boot_failures: 1

# sysctl could not get directory:
sysctl_could_not_get_directory: 1
message:sysctl_could_not_get_directory: [ 0.861994] sysctl could not get directory: /debug/test_sysctl/mnt/mnt_error -30
pattern:sysctl_could_not_get_directory: sysctl could not get directory:

timestamp:last: 0.861994
timestamp:sysctl_could_not_get_directory: 0.861994

0 comments on commit 669f7a4

Please sign in to comment.