xref: /PHP-7.0/sapi/fpm/tests/007.phpt (revision ad7ed6fe)
1--TEST--
2FPM: Test IPv6 all addresses and access_log (bug #68421)
3--SKIPIF--
4<?php include "skipif.inc";
5      @stream_socket_client('tcp://[::1]:0', $errno);
6      if ($errno != 111) die('skip IPv6 not supported.');
7?>
8--FILE--
9<?php
10
11include "include.inc";
12
13$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
14$accfile = dirname(__FILE__).'/php-fpm.acc.tmp';
15$port = 9000+PHP_INT_SIZE;
16
17$cfg = <<<EOT
18[global]
19error_log = $logfile
20[unconfined]
21listen = [::]:$port
22access.log = $accfile
23ping.path = /ping
24ping.response = pong
25pm = dynamic
26pm.max_children = 5
27pm.start_servers = 2
28pm.min_spare_servers = 1
29pm.max_spare_servers = 3
30EOT;
31
32$fpm = run_fpm($cfg, $tail);
33if (is_resource($fpm)) {
34    fpm_display_log($tail, 2);
35    try {
36		var_dump(strpos(run_request('127.0.0.1', $port), 'pong'));
37		echo "IPv4 ok\n";
38	} catch (Exception $e) {
39		echo "IPv4 error\n";
40	}
41    try {
42		var_dump(strpos(run_request('[::1]', $port), 'pong'));
43		echo "IPv6 ok\n";
44	} catch (Exception $e) {
45		echo "IPv6 error\n";
46	}
47    proc_terminate($fpm);
48    stream_get_contents($tail);
49    fclose($tail);
50    proc_close($fpm);
51
52    echo file_get_contents($accfile);
53}
54
55?>
56--EXPECTF--
57[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
58[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
59int(%d)
60IPv4 ok
61int(%d)
62IPv6 ok
63127.0.0.1 %s "GET /ping" 200
64::1 %s "GET /ping" 200
65--CLEAN--
66<?php
67    $logfile = dirname(__FILE__).'/php-fpm.log.tmp';
68    @unlink($logfile);
69	$accfile = dirname(__FILE__).'/php-fpm.acc.tmp';
70    @unlink($accfile);
71?>
72