xref: /linux/tools/perf/tests/shell/common/check_errors_whitelisted.pl (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1#!/usr/bin/perl
2# SPDX-License-Identifier: GPL-2.0
3
4$whitelist_file = shift;
5
6if (defined $whitelist_file)
7{
8	open (INFILE, $whitelist_file) or die "Checker error: Unable to open the whitelist file: $whitelist_file\n";
9	@regexps = <INFILE>;
10	close INFILE or die "Checker error: Unable to close the whitelist file: $whitelist_file\n";
11}
12else
13{
14	@regexps = ();
15}
16
17$max_printed_lines = 20;
18$max_printed_lines = $ENV{TESTLOG_ERR_MSG_MAX_LINES} if (defined $ENV{TESTLOG_ERR_MSG_MAX_LINES});
19
20$quiet = 1;
21$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2);
22
23$passed = 1;
24$lines_printed = 0;
25
26while (<STDIN>)
27{
28	s/\n//;
29
30	$line_matched = 0;
31	for $r (@regexps)
32	{
33		chomp $r;
34		if (/$r/)
35		{
36			$line_matched = 1;
37			last;
38		}
39	}
40
41	unless ($line_matched)
42	{
43		if ($lines_printed++ < $max_printed_lines)
44		{
45			print "Line did not match any pattern: \"$_\"\n" unless $quiet;
46		}
47		$passed = 0;
48	}
49}
50
51exit ($passed == 0);
52