mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 22:34:33 +01:00
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 <[email protected]> Signed-off-by: Michael Petlan <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected]
35 lines
424 B
Perl
Executable File
35 lines
424 B
Perl
Executable File
#!/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);
|