mirror of
https://github.com/torvalds/linux.git
synced 2026-05-02 13:32:40 -04:00
perf testsuite: Add common output checking helpers
As a form of validation, it is a common practice to check the outputs of commands whether they contain expected patterns or match a certain regex. Add helpers for verifying that all regexes are found in the output, that all lines match any pattern from a set and that a certain expression is not present in the output. In verbose mode these helpers log mismatches for easier failure investigation. Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com> Signed-off-by: Michael Petlan <mpetlan@redhat.com> Cc: kjain@linux.ibm.com Cc: atrajeev@linux.vnet.ibm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20240215110231.15385-6-mpetlan@redhat.com
This commit is contained in:
committed by
Namhyung Kim
parent
c8eb2a9ff8
commit
61d348f1e9
34
tools/perf/tests/shell/common/check_no_patterns_found.pl
Executable file
34
tools/perf/tests/shell/common/check_no_patterns_found.pl
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/perl
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
@regexps = @ARGV;
|
||||
|
||||
$quiet = 1;
|
||||
$quiet = 0 if (defined $ENV{TESTLOG_VERBOSITY} && $ENV{TESTLOG_VERBOSITY} ge 2);
|
||||
|
||||
%found = ();
|
||||
$passed = 1;
|
||||
|
||||
while (<STDIN>)
|
||||
{
|
||||
s/\n//;
|
||||
|
||||
for $r (@regexps)
|
||||
{
|
||||
if (/$r/)
|
||||
{
|
||||
$found{$r} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for $r (@regexps)
|
||||
{
|
||||
if (exists $found{$r})
|
||||
{
|
||||
print "Regexp found: \"$r\"\n" unless $quiet;
|
||||
$passed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
exit ($passed == 0);
|
||||
Reference in New Issue
Block a user