xref: /PHP-7.0/sapi/fpm/tests/004.phpt (revision ad7ed6fe)
1--TEST--
2FPM: Test IPv4/IPv6 support
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$port = 9000+PHP_INT_SIZE;
15
16$cfg = <<<EOT
17[global]
18error_log = $logfile
19[unconfined]
20listen = [::]:$port
21pm = dynamic
22pm.max_children = 5
23pm.start_servers = 2
24pm.min_spare_servers = 1
25pm.max_spare_servers = 3
26EOT;
27
28$fpm = run_fpm($cfg, $tail);
29if (is_resource($fpm)) {
30    fpm_display_log($tail, 2);
31    $i = 0;
32    while (($i++ < 60) && !($fp = @fsockopen('127.0.0.1', $port))) {
33        usleep(50000);
34    }
35    if ($fp) {
36        echo "Done IPv4\n";
37        fclose($fp);
38    }
39    while (($i++ < 60) && !($fp = @fsockopen('[::1]', $port))) {
40        usleep(50000);
41    }
42    if ($fp) {
43        echo "Done IPv6\n";
44        fclose($fp);
45    }
46    proc_terminate($fpm);
47    stream_get_contents($tail);
48    fclose($tail);
49    proc_close($fpm);
50}
51
52?>
53--EXPECTF--
54[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
55[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
56Done IPv4
57Done IPv6
58--CLEAN--
59<?php
60    $logfile = dirname(__FILE__).'/php-fpm.log.tmp';
61    @unlink($logfile);
62?>
63