xref: /PHP-5.6/sapi/fpm/tests/017.phpt (revision 3a3f67f7)
1--TEST--
2FPM: Test fastcgi_finish_request function
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--FILE--
6<?php
7
8include "include.inc";
9
10$logfile = __DIR__.'/php-fpm.log.tmp';
11$srcfile = __DIR__.'/php-fpm.tmp.php';
12$port = 9000+PHP_INT_SIZE;
13
14$cfg = <<<EOT
15[global]
16error_log = $logfile
17[unconfined]
18listen = 127.0.0.1:$port
19pm = dynamic
20pm.max_children = 5
21pm.start_servers = 1
22pm.min_spare_servers = 1
23pm.max_spare_servers = 3
24EOT;
25
26$code = <<<EOT
27<?php
28echo "Test Start\n";
29fastcgi_finish_request();
30echo "Test End\n";
31EOT;
32file_put_contents($srcfile, $code);
33
34$fpm = run_fpm($cfg, $tail);
35if (is_resource($fpm)) {
36    fpm_display_log($tail, 2);
37    try {
38		$req = run_request('127.0.0.1', $port, $srcfile);
39		echo strstr($req, "Test Start");
40		echo "Request ok\n";
41	} catch (Exception $e) {
42		echo "Request error\n";
43	}
44    proc_terminate($fpm);
45    echo stream_get_contents($tail);
46    fclose($tail);
47    proc_close($fpm);
48}
49
50?>
51Done
52--EXPECTF--
53[%s] NOTICE: fpm is running, pid %d
54[%s] NOTICE: ready to handle connections
55Test Start
56
57Request ok
58[%s] NOTICE: Terminating ...
59[%s] NOTICE: exiting, bye-bye!
60Done
61--CLEAN--
62<?php
63	$logfile = __DIR__.'/php-fpm.log.tmp';
64	$srcfile = __DIR__.'/php-fpm.tmp.php';
65    @unlink($logfile);
66    @unlink($srcfile);
67?>