mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Move pump_until to TestLib.pm.
The subroutine pump_until provides the functionality to poll until the given string is matched, or a timeout occurs. This can be used from other places as well, so moving it to TestLib.pm. The immediate need is for an upcoming regression test patch for dropdb utility. Author: Vignesh C Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/CAP_rwwmLJJbn70vLOZFpxGw3XD7nLB_7+NKz46H5EOO2k5H7OQ@mail.gmail.com
This commit is contained in:
@ -860,6 +860,43 @@ sub command_checks_all
|
||||
|
||||
=pod
|
||||
|
||||
=item pump_until(proc, timeout, stream, untl)
|
||||
|
||||
# Pump until string is matched, or timeout occurs
|
||||
|
||||
=cut
|
||||
|
||||
sub pump_until
|
||||
{
|
||||
my ($proc, $timeout, $stream, $untl) = @_;
|
||||
$proc->pump_nb();
|
||||
while (1)
|
||||
{
|
||||
last if $$stream =~ /$untl/;
|
||||
if ($timeout->is_expired)
|
||||
{
|
||||
diag("aborting wait: program timed out");
|
||||
diag("stream contents: >>", $$stream, "<<");
|
||||
diag("pattern searched for: ", $untl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
if (not $proc->pumpable())
|
||||
{
|
||||
diag("aborting wait: program died");
|
||||
diag("stream contents: >>", $$stream, "<<");
|
||||
diag("pattern searched for: ", $untl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
$proc->pump();
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
Reference in New Issue
Block a user