mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Add function to pump IPC process until string match
Refactor the recovery tests to not carry a local duplicated copy of the pump_until function which pumps a process until a defined string is seen on a stream. This reduces duplication, and is in preparation for another patch which will also use this functionality. Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion https://postgr.es/m/YgynUafCyIu3jIhC@paquier.xyz
This commit is contained in:
@ -73,6 +73,7 @@ our @EXPORT = qw(
|
||||
system_log
|
||||
run_log
|
||||
run_command
|
||||
pump_until
|
||||
|
||||
command_ok
|
||||
command_fails
|
||||
@ -408,6 +409,28 @@ sub run_command
|
||||
|
||||
=pod
|
||||
|
||||
=item pump_until(proc, timeout, stream, until)
|
||||
|
||||
Pump until string is matched on the specified stream, or timeout occurs.
|
||||
|
||||
=cut
|
||||
|
||||
sub pump_until
|
||||
{
|
||||
my ($proc, $timeout, $stream, $until) = @_;
|
||||
$proc->pump_nb();
|
||||
while (1)
|
||||
{
|
||||
last if $$stream =~ /$until/;
|
||||
return 0 if ($timeout->is_expired);
|
||||
return 0 if (not $proc->pumpable());
|
||||
$proc->pump();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item generate_ascii_string(from_char, to_char)
|
||||
|
||||
Generate a string made of the given range of ASCII characters.
|
||||
|
Reference in New Issue
Block a user