summaryrefslogtreecommitdiff
path: root/sapi/fpm/tests
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2020-02-23 18:32:20 +0000
committerJakub Zelenka <bukka@php.net>2020-02-23 18:32:20 +0000
commitee0579350feb211f9715057cca0095d83b187408 (patch)
treef9bf690d93f390dcb58a256e4f9fb731a3f1c1c4 /sapi/fpm/tests
parent0aad7999e75898518db348a6b9b620e391d726cb (diff)
parent0bc6a66a7a0624e63edcd2499f91b227cdb77f47 (diff)
downloadphp-git-ee0579350feb211f9715057cca0095d83b187408.tar.gz
Merge branch 'PHP-7.4'
Diffstat (limited to 'sapi/fpm/tests')
-rw-r--r--sapi/fpm/tests/log-bm-in-shutdown-fn.phpt49
-rw-r--r--sapi/fpm/tests/log-bwp-msg-flush-split-fallback.phpt49
-rw-r--r--sapi/fpm/tests/log-bwp-msg-flush-split-real.phpt46
3 files changed, 144 insertions, 0 deletions
diff --git a/sapi/fpm/tests/log-bm-in-shutdown-fn.phpt b/sapi/fpm/tests/log-bm-in-shutdown-fn.phpt
new file mode 100644
index 0000000000..f968bf9f08
--- /dev/null
+++ b/sapi/fpm/tests/log-bm-in-shutdown-fn.phpt
@@ -0,0 +1,49 @@
+--TEST--
+FPM: Log message in shutdown function
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+log_limit = 1024
+log_buffering = yes
+[unconfined]
+listen = {{ADDR}}
+pm = dynamic
+pm.max_children = 5
+pm.start_servers = 1
+pm.min_spare_servers = 1
+pm.max_spare_servers = 3
+catch_workers_output = yes
+EOT;
+
+$code = <<<EOT
+<?php
+register_shutdown_function(function() {
+ error_log(str_repeat('e', 80));
+});
+EOT;
+
+$tester = new FPM\Tester($cfg, $code);
+$tester->start();
+$tester->expectLogStartNotices();
+$tester->request()->expectEmptyBody();
+$tester->terminate();
+$tester->expectFastCGIErrorMessage('e', 1050, 80);
+$tester->expectLogMessage('NOTICE: PHP message: ' . str_repeat('e', 80), 1050);
+$tester->close();
+
+?>
+Done
+--EXPECT--
+Done
+--CLEAN--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>
diff --git a/sapi/fpm/tests/log-bwp-msg-flush-split-fallback.phpt b/sapi/fpm/tests/log-bwp-msg-flush-split-fallback.phpt
new file mode 100644
index 0000000000..0c152619a9
--- /dev/null
+++ b/sapi/fpm/tests/log-bwp-msg-flush-split-fallback.phpt
@@ -0,0 +1,49 @@
+--TEST--
+FPM: Buffered worker output plain log with msg with flush split in buffer
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+[unconfined]
+listen = {{ADDR}}
+pm = dynamic
+pm.max_children = 5
+pm.start_servers = 1
+pm.min_spare_servers = 1
+pm.max_spare_servers = 3
+catch_workers_output = yes
+decorate_workers_output = no
+EOT;
+
+$code = <<<EOT
+<?php
+file_put_contents('php://stderr', str_repeat('a', 1021) . "\0fabc");
+EOT;
+
+$tester = new FPM\Tester($cfg, $code);
+$tester->start();
+$tester->expectLogStartNotices();
+$tester->request()->expectEmptyBody();
+$tester->terminate();
+$lines = $tester->getLogLines(2);
+var_dump($lines[0] === str_repeat('a', 1021) . "\0f\n");
+var_dump($lines[1] === "abc\n");
+$tester->close();
+
+?>
+Done
+--EXPECT--
+bool(true)
+bool(true)
+Done
+--CLEAN--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>
diff --git a/sapi/fpm/tests/log-bwp-msg-flush-split-real.phpt b/sapi/fpm/tests/log-bwp-msg-flush-split-real.phpt
new file mode 100644
index 0000000000..63b2555de7
--- /dev/null
+++ b/sapi/fpm/tests/log-bwp-msg-flush-split-real.phpt
@@ -0,0 +1,46 @@
+--TEST--
+FPM: Buffered worker output plain log with msg with flush split in buffer
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+[unconfined]
+listen = {{ADDR}}
+pm = dynamic
+pm.max_children = 5
+pm.start_servers = 1
+pm.min_spare_servers = 1
+pm.max_spare_servers = 3
+catch_workers_output = yes
+decorate_workers_output = no
+EOT;
+
+$code = <<<EOT
+<?php
+file_put_contents('php://stderr', str_repeat('a', 1022) . "\0fscf\0");
+EOT;
+
+$tester = new FPM\Tester($cfg, $code);
+$tester->start();
+$tester->expectLogStartNotices();
+$tester->request()->expectEmptyBody();
+$tester->terminate();
+var_dump($tester->getLastLogLine() === str_repeat('a', 1022) . "\n");
+$tester->close();
+
+?>
+Done
+--EXPECT--
+bool(true)
+Done
+--CLEAN--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>