Commit 2d687618 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Jim Harris
Browse files

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: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I62d48e1130c600ffff6713d2748239cc955bbe9e
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/483834


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent dc06a06d
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -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;
	}