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