From 2d687618f3034fee135fbbb7a85449e551987486 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Tue, 4 Feb 2020 05:05:43 -0500 Subject: [PATCH] test/match: do not ignore all input when passing \n Match script before this change ignored all input when passing just a new line in ignore file. This was because \n symbol was stripped from that particular line (chop()) leaving empty string. This always matched all of the input when using index(). Now when comparing the input line and ignore line, we check that ignore line is not empty. Besides that, to still allow ignoring new lines we check and compare both strings directly. Changed chop() to chomp() to prevent further breakage, difference is that chomp() only strips new line characters. As that was the original intention anyway. The loop changed so we exit on first instance of ignored line matching, rather than mention particular line multiple times for each matched ignore. Signed-off-by: Tomasz Zawadzki Change-Id: I62d48e1130c600ffff6713d2748239cc955bbe9e Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/483834 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- test/app/match/match | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/app/match/match b/test/app/match/match index 7c1cdc45b..63fee5203 100755 --- a/test/app/match/match +++ b/test/app/match/match @@ -188,16 +188,22 @@ sub strip_it { foreach $line_in (@lines_in) { my @i_lines = @i_file; foreach $i_line (@i_lines) { - chop($i_line); - if (index($line_in, $i_line) != -1) { + # Check if both ignore and input lines are new lines + if ($i_line eq "\n" && $line_in eq "\n") { $ignore_it = 1; - if ($opt_v) { - print "Ignoring (from $file): $line_in"; - } + last; + } + # Find the ignore string in input line + chomp($i_line); + if (index($line_in, $i_line) != -1 && length($i_line) != 0) { + $ignore_it = 1; + last; } } if ($ignore_it == 0) { $output .= $line_in; + } elsif($opt_v) { + print "Ignoring (from $file): $line_in"; } $ignore_it = 0; }