diff options
author | Amit Kapila <akapila@postgresql.org> | 2019-11-28 08:28:17 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2019-11-28 08:28:17 +0530 |
commit | 290acac92b1d7bebb4ec68fe8b7a5cb442333eda (patch) | |
tree | cff15d2b4668349291e8ed8dd370c0080736683b /src/test/perl/TestLib.pm | |
parent | 60b35b7f1ea1d5cd17805e30299fd21616855b7d (diff) | |
download | postgresql-290acac92b1d7bebb4ec68fe8b7a5cb442333eda.tar.gz |
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
Diffstat (limited to 'src/test/perl/TestLib.pm')
-rw-r--r-- | src/test/perl/TestLib.pm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 458b801379..c0e636cfa1 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -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 |