1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 04:37:38 +02:00

Wait for children that are being tested

This commit is contained in:
Robert Gust-Bardon
2018-06-18 11:25:41 -05:00
parent 25c427a0e4
commit 23fd84fec0

View File

@@ -131,7 +131,7 @@ class ErrorHandlerTest extends TestCase
* @depends testRegisterSignalHandler * @depends testRegisterSignalHandler
* @requires function pcntl_fork * @requires function pcntl_fork
* @requires function pcntl_sigprocmask * @requires function pcntl_sigprocmask
* @requires function pcntl_wait * @requires function pcntl_waitpid
*/ */
public function testRegisterDefaultPreviousSignalHandler($signo, $callPrevious, $expected) public function testRegisterDefaultPreviousSignalHandler($signo, $callPrevious, $expected)
{ {
@@ -159,7 +159,7 @@ class ErrorHandlerTest extends TestCase
} }
$this->assertNotSame(-1, $pid); $this->assertNotSame(-1, $pid);
$this->assertNotSame(-1, pcntl_wait($status)); $this->assertNotSame(-1, pcntl_waitpid($pid, $status));
$this->assertNotSame(-1, $status); $this->assertNotSame(-1, $status);
$this->assertSame($expected, file_get_contents($path)); $this->assertSame($expected, file_get_contents($path));
} }
@@ -213,7 +213,7 @@ class ErrorHandlerTest extends TestCase
* @dataProvider restartSyscallsProvider * @dataProvider restartSyscallsProvider
* @depends testRegisterDefaultPreviousSignalHandler * @depends testRegisterDefaultPreviousSignalHandler
* @requires function pcntl_fork * @requires function pcntl_fork
* @requires function pcntl_wait * @requires function pcntl_waitpid
*/ */
public function testRegisterSyscallRestartingSignalHandler($restartSyscalls) public function testRegisterSyscallRestartingSignalHandler($restartSyscalls)
{ {
@@ -236,20 +236,20 @@ class ErrorHandlerTest extends TestCase
$errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, false, $restartSyscalls, false); $errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, false, $restartSyscalls, false);
if ($restartSyscalls) { if ($restartSyscalls) {
// pcntl_wait is expected to be restarted after the signal handler. // pcntl_wait is expected to be restarted after the signal handler.
$this->assertNotSame(-1, pcntl_wait($status)); $this->assertNotSame(-1, pcntl_waitpid($pid, $status));
} else { } else {
// pcntl_wait is expected to be interrupted when the signal handler is invoked. // pcntl_wait is expected to be interrupted when the signal handler is invoked.
$this->assertSame(-1, pcntl_wait($status)); $this->assertSame(-1, pcntl_waitpid($pid, $status));
} }
$this->assertSame($restartSyscalls, microtime(true) - $microtime > 0.15); $this->assertSame($restartSyscalls, microtime(true) - $microtime > 0.15);
$this->assertTrue(pcntl_signal_dispatch()); $this->assertTrue(pcntl_signal_dispatch());
$this->assertCount(1, $handler->getRecords()); $this->assertCount(1, $handler->getRecords());
if ($restartSyscalls) { if ($restartSyscalls) {
// The child has already exited. // The child has already exited.
$this->assertSame(-1, pcntl_wait($status)); $this->assertSame(-1, pcntl_waitpid($pid, $status));
} else { } else {
// The child has not exited yet. // The child has not exited yet.
$this->assertNotSame(-1, pcntl_wait($status)); $this->assertNotSame(-1, pcntl_waitpid($pid, $status));
} }
} }