Skip to content

Commit 73986ad

Browse files
committed
travisci updates for php7.1, php7.2 and php7.3
- fixed unstable tests - add pthreads for php7.2
1 parent 8846341 commit 73986ad

File tree

4 files changed

+85
-25
lines changed

4 files changed

+85
-25
lines changed

.travis.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
dist: trusty
2+
13
language: php
24
php:
5+
#- nightly requires more changes
6+
#- 7.4 requires more changes
7+
- 7.3
8+
- 7.2
9+
- 7.1
310
- 7.0
411
- 5.6
512
- 5.5
@@ -10,19 +17,18 @@ env:
1017
- LIBZMQ_VERSION=3.2.5
1118
- LIBZMQ_VERSION=4.0.7 LIBSODIUM_VERSION=1.0.8
1219
- LIBZMQ_VERSION=4.1.4 LIBSODIUM_VERSION=1.0.8
13-
- LIBZMQ_VERSION=master LIBSODIUM_VERSION=1.0.8
20+
- LIBZMQ_VERSION=master LIBSODIUM_VERSION=1.0.18
1421
addons:
1522
apt:
1623
packages:
1724
- uuid-dev
25+
- libtool
1826

1927
before_script:
20-
- phpenv config-rm xdebug.ini
28+
- phpenv config-rm xdebug.ini || true
2129

2230
script: travis/script.sh $HOME/zeromq-cache $LIBZMQ_VERSION $LIBSODIUM_VERSION $CZMQ_VERSION
23-
#cache:
24-
# directories:
25-
# - travis/cache
31+
2632
sudo: false
2733

2834
cache:

tests/028-xpub.phpt

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Test send / recv with XPUB and XSUB sockets
44
<?php
55
require_once(dirname(__FILE__) . '/skipif.inc');
66
if(!defined('ZMQ::SOCKET_XPUB')) die('skip');
7+
if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR < 3) {
8+
die ("skip This test is for libzmq version 3.x and up");
9+
}
710
?>
811
--FILE--
912
<?php

tests/052-pthreads.phpt

+48-18
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,79 @@ Test pthreads integration
1717
$threads = 10;
1818

1919
class MyWorker extends Thread {
20-
public $sendThisBack;
20+
private $sendThisBack;
2121

2222
public function __construct($sendThisBack){
2323
$this->sendThisBack = $sendThisBack;
2424
}
2525

2626
public function run() {
2727
$context = ZMQContext::acquire();
28-
2928
$socket = $context->getSocket(ZMQ::SOCKET_PUSH);
3029
$socket->connect ("inproc://pthreads-test");
3130
$socket->send($this->sendThisBack);
32-
33-
sleep(2);
31+
usleep(500 * 1000);
3432
}
3533
}
3634

37-
$context = ZMQContext::acquire();
38-
39-
40-
$socket = $context->getSocket(ZMQ::SOCKET_PULL);
41-
$socket->bind("inproc://pthreads-test");
42-
$socket->setSockOpt(ZMQ::SOCKOPT_HWM, 1000);
35+
class MyServer extends Thread {
36+
private $threads;
37+
38+
public function __construct($threads){
39+
$this->threads = $threads;
40+
}
41+
42+
public function run() {
43+
$context = ZMQContext::acquire();
44+
$socket = $context->getSocket(ZMQ::SOCKET_PULL);
45+
$socket->bind("inproc://pthreads-test");
46+
$socket->setSockOpt(ZMQ::SOCKOPT_HWM, 1000);
47+
usleep(500 * 1000);
48+
49+
echo 'Receiving responses' . PHP_EOL;
50+
$responses = array();
51+
for ($i = 0; $i < $this->threads; $i++) {
52+
$responses[] = $socket->recv();
53+
}
54+
sort($responses);
55+
foreach($responses as $response){
56+
echo $response . PHP_EOL;
57+
}
58+
}
59+
}
4360

44-
$request = array();
61+
$server = new MyServer($threads);
62+
$server->start();
63+
echo 'Server started' . PHP_EOL;
4564

65+
$requests = array();
4666
for ($i = 0; $i < $threads; $i++) {
4767
$requests[$i] = new MyWorker("thr_$i");
4868
$requests[$i]->start();
4969
}
50-
51-
var_dump($context->getSocketCount());
70+
echo 'Workers started' . PHP_EOL;
5271

5372
for ($i = 0; $i < $threads; $i++) {
5473
$requests[$i]->join();
5574
}
56-
57-
for ($i = 0; $i < $threads; $i++) {
58-
$socket->recv();
59-
}
75+
$server->join();
76+
echo 'All requests pushed' . PHP_EOL;
6077

6178
echo "OK";
6279

6380
--EXPECT--
64-
int(11)
81+
Server started
82+
Workers started
83+
Receiving responses
84+
thr_0
85+
thr_1
86+
thr_2
87+
thr_3
88+
thr_4
89+
thr_5
90+
thr_6
91+
thr_7
92+
thr_8
93+
thr_9
94+
All requests pushed
6595
OK

travis/script.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ if test "x$4" != "x"; then
2121
CZMQ_VERSION=$4
2222
fi
2323

24-
BUILD_PTHREADS=`php -r 'die(PHP_ZTS == 1 && PHP_VERSION_ID >= 70000 ? "yes" : "no");'`
24+
# pthreads only available for php7.0 and php7.2 (2020-02)
25+
# 7.1 and 7.3 is not compiling, no more support for php7.4 and up, package is discontinued
26+
BUILD_PTHREADS=`php -r 'die(PHP_ZTS == 1 && ((PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70100) || (PHP_VERSION_ID >= 70200 && PHP_VERSION_ID < 70300)) ? "yes" : "no");'`
2527

2628
LIBSODIUM_PREFIX="${CACHE_DIR}/libsodium-${LIBSODIUM_VERSION}"
2729
LIBZMQ_PREFIX="${CACHE_DIR}/libzmq-${LIBZMQ_VERSION}-libsodium-${LIBSODIUM_VERSION}"
@@ -204,7 +206,26 @@ make_test() {
204206

205207
if test "${BUILD_PTHREADS}" = "yes"
206208
then
207-
pecl install pthreads
209+
210+
PHP_VERSION_MAJOR_MINOR=`php -r 'die(PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION);'`
211+
echo "PHP Version is: $PHP_VERSION_MAJOR_MINOR"
212+
213+
if test "$PHP_VERSION_MAJOR_MINOR" = "7.3"
214+
then
215+
# pthreads from from github master branch (not "yet" released) -> is broken for php7.3
216+
pecl install --ignore-errors https://github.com/krakjoe/pthreads/archive/master.tar.gz
217+
elif test "$PHP_VERSION_MAJOR_MINOR" = "7.2"
218+
then
219+
# pthreads from from github release directly
220+
pecl install --ignore-errors https://github.com/krakjoe/pthreads/archive/v3.2.0.tar.gz
221+
elif test "$PHP_VERSION_MAJOR_MINOR" = "7.1"
222+
then
223+
# pthreads from from github release directly -> is broken for php7.1
224+
pecl install --ignore-errors https://github.com/krakjoe/pthreads/archive/v3.1.6.tar.gz
225+
else
226+
# pthreads from pear release till 7.0
227+
pecl install pthreads
228+
fi
208229
pthreads_flag="extension=pthreads.so"
209230
fi
210231

0 commit comments

Comments
 (0)