xref: /linux/tools/perf/tests/shell/common/check_all_lines_matched.pl (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1#!/usr/bin/perl
2# SPDX-License-Identifier: GPL-2.0
3
4@regexps = @ARGV;
5
6$max_printed_lines = 20;
7$max_printed_lines = $ENV{TESTLOG_ERR_MSG_MAX_LINES} if (defined $ENV{TESTLOG_ERR_MSG_MAX_LINES});
8
9$quiet = 1;
10$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2);
11
12$passed = 1;
13$lines_printed = 0;
14
15while (<STDIN>)
16{
17	s/\n//;
18
19	$line_matched = 0;
20	for $r (@regexps)
21	{
22		if (/$r/)
23		{
24			$line_matched = 1;
25			last;
26		}
27	}
28
29	unless ($line_matched)
30	{
31		if ($lines_printed++ < $max_printed_lines)
32		{
33			print "Line did not match any pattern: \"$_\"\n" unless $quiet;
34		}
35		$passed = 0;
36	}
37}
38
39exit ($passed == 0);
40