Skip to content

Backport travis.sh from master / php7 branch #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 25, 2017
36 changes: 20 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
sudo: required
dist: trusty

language: php
php:
- 5.5
#- 5.4
#- 5.3
- 5.6

env:
- LIBMEMCACHED_VERSION=1.0.17
- LIBMEMCACHED_VERSION=1.0.16
- LIBMEMCACHED_VERSION=1.0.15
- LIBMEMCACHED_VERSION=1.0.14
- LIBMEMCACHED_VERSION=1.0.10
- LIBMEMCACHED_VERSION=1.0.8
- LIBMEMCACHED_VERSION=1.0.7
- LIBMEMCACHED_VERSION=1.0.6
- LIBMEMCACHED_VERSION=1.0.2
- LIBMEMCACHED_VERSION=0.53
- LIBMEMCACHED_VERSION=0.49
- LIBMEMCACHED_VERSION=0.44
- LIBMEMCACHED_VERSION=1.0.18 # Debian Jessie / Ubuntu Xenial
- LIBMEMCACHED_VERSION=1.0.16 # RHEL / CentOS 7
- LIBMEMCACHED_VERSION=1.0.8 # Debian Wheezy / Ubuntu Trusty
- LIBMEMCACHED_VERSION=1.0.2 # Ancient
- LIBMEMCACHED_VERSION=0.53 # Ancient

services:
- memcached # will start memcached
addons:
apt:
packages:
- sasl2-bin
- libsasl2-dev
- libevent-dev

before_script:
- ./.travis/travis.sh before_script $LIBMEMCACHED_VERSION

script:
- ./.travis/travis.sh script $LIBMEMCACHED_VERSION

cache:
directories:
- $HOME/cache
80 changes: 50 additions & 30 deletions .travis/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ function validate_package_xml() {

function install_libmemcached() {

if test -d "${LIBMEMCACHED_PREFIX}"
then
echo "Using cached libmemcached: ${LIBMEMCACHED_PREFIX}"
return
fi

wget "https://launchpad.net/libmemcached/1.0/${LIBMEMCACHED_VERSION}/+download/libmemcached-${LIBMEMCACHED_VERSION}.tar.gz" -O libmemcached-${LIBMEMCACHED_VERSION}.tar.gz

tar xvfz libmemcached-${LIBMEMCACHED_VERSION}.tar.gz
Expand Down Expand Up @@ -81,35 +87,52 @@ function install_msgpack() {
popd
}

function install_sasl() {
function install_memcached() {
local prefix="${HOME}/cache/memcached-sasl-${MEMCACHED_VERSION}"

if test -d "$prefix"
then
echo "Using cached memcached: ${prefix}"
return
fi

wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz -O memcached-1.4.15.tar.gz
tar xfz memcached-1.4.15.tar.gz
wget http://www.memcached.org/files/memcached-${MEMCACHED_VERSION}.tar.gz -O memcached-${MEMCACHED_VERSION}.tar.gz
tar xfz memcached-${MEMCACHED_VERSION}.tar.gz

pushd memcached-1.4.15
./configure --enable-sasl --prefix="${HOME}/memcached"
pushd memcached-${MEMCACHED_VERSION}
./configure --enable-sasl --enable-sasl-pwdb --prefix="${prefix}"
make
make install
popd
}

function run_memcached() {
local prefix="${HOME}/cache/memcached-sasl-${MEMCACHED_VERSION}"

sudo apt-get install sasl2-bin
export SASL_CONF_PATH="${HOME}/sasl2"
export SASL_CONF_PATH="/tmp/sasl2"

if test -d "${SASL_CONF_PATH}"
then
rm -rf "${SASL_CONF_PATH}"
fi

# Create config path
mkdir "${SASL_CONF_PATH}"
export MEMCACHED_SASL_PWDB="${SASL_CONF_PATH}/sasldb2"

# Create configuration
cat<<EOF > "${SASL_CONF_PATH}/memcached.conf"
mech_list: PLAIN
plainlog_level: 5
sasldb_path: ${SASL_CONF_PATH}/sasldb2
sasldb_path: ${MEMCACHED_SASL_PWDB}
EOF

# Create password
echo "test" | /usr/sbin/saslpasswd2 -c memcached -a memcached -f "${SASL_CONF_PATH}/sasldb2"
echo "test" | /usr/sbin/saslpasswd2 -c memcached -a memcached -f "${MEMCACHED_SASL_PWDB}"

# Run normal memcached
"${prefix}/bin/memcached" -d -p 11211

# Run memcached on port 11212 with SASL support
"${HOME}/memcached/bin/memcached" -S -d -p 11212
"${prefix}/bin/memcached" -S -d -p 11212
}

function build_php_memcached() {
Expand All @@ -129,7 +152,8 @@ function build_php_memcached() {
sasl_flag="--enable-memcached-sasl"
fi

./configure --with-libmemcached-dir="$LIBMEMCACHED_PREFIX" $protocol_flag $sasl_flag --enable-memcached-json --enable-memcached-igbinary --enable-memcached-msgpack
# ./configure --with-libmemcached-dir="$LIBMEMCACHED_PREFIX" $protocol_flag $sasl_flag
./configure --with-libmemcached-dir="$LIBMEMCACHED_PREFIX" $protocol_flag $sasl_flag --enable-memcached-json --enable-memcached-msgpack --enable-memcached-igbinary
make
make install
popd
Expand All @@ -152,30 +176,24 @@ EOF
function run_memcached_tests() {
export NO_INTERACTION=1
export REPORT_EXIT_STATUS=1
export TEST_PHP_EXECUTABLE=`which php`
export TEST_PHP_EXECUTABLE=$(which php)

pushd "${PHP_MEMCACHED_BUILD_DIR}/memcached-${PHP_MEMCACHED_VERSION}"
# We have one xfail test, we run it separately
php run-tests.php -d extension=msgpack.so -d extension=igbinary.so -d extension=memcached.so -n ./tests/expire.phpt
php run-tests.php -d extension=memcached.so -n ./tests/expire.phpt
rm ./tests/expire.phpt

# Run normal tests
php run-tests.php -d extension=msgpack.so -d extension=igbinary.so -d extension=memcached.so -n ./tests/*.phpt
php run-tests.php --show-diff -d extension=modules/memcached.so -d extension=msgpack.so -d extension=igbinary.so -n ./tests/*.phpt
retval=$?
for i in `ls tests/*.out 2>/dev/null`; do
echo "-- START ${i}";
cat $i;
echo "";
echo "-- END";
done
popd

return $retval;
}

# Command line arguments
ACTION=$1
LIBMEMCACHED_VERSION=$2
MEMCACHED_VERSION="1.4.25"

if test "x$ACTION" = "x"; then
echo "Usage: $0 <action> <libmemcached version>"
Expand All @@ -187,11 +205,15 @@ if test "x$LIBMEMCACHED_VERSION" = "x"; then
exit 1
fi

if test "x$3" != "x"; then
MEMCACHED_VERSION=$3
fi

# the extension version
PHP_MEMCACHED_VERSION=$(php -r '$sxe = simplexml_load_file ("package.xml"); echo (string) $sxe->version->release;')

# Libmemcached install dir
LIBMEMCACHED_PREFIX="${HOME}/libmemcached-${LIBMEMCACHED_VERSION}"
LIBMEMCACHED_PREFIX="${HOME}/cache/libmemcached-${LIBMEMCACHED_VERSION}"

# Where to do the build
PHP_MEMCACHED_BUILD_DIR="/tmp/php-memcached-build"
Expand All @@ -216,13 +238,11 @@ case $ACTION in
# Install igbinary extension
install_igbinary

# install msgpack
# Install msgpack extension
install_msgpack

# install SASL
if test "x$ENABLE_SASL" = "xyes"; then
install_sasl
fi

install_memcached
run_memcached
;;

script)
Expand Down
5 changes: 5 additions & 0 deletions tests/config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ function memc_create_combinations ($name, $serializer, $ignore_object_type = fal
),
);
}

function memc_get_version($memc, $host = '') {
$version = $memc->getVersion();
return array_pop($version);
}
4 changes: 3 additions & 1 deletion tests/expire.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Memcached store, fetch & touch expired key
--XFAIL--
https://code.google.com/p/memcached/issues/detail?id=275
--SKIPIF--
<?php if (!extension_loaded("memcached")) print "skip";
<?php
$min_version = "1.4.8";
include dirname(__FILE__) . "/skipif.inc";
if (!method_exists("memcached", "touch")) die ("skip memcached::touch is not available");
?>
--FILE--
Expand Down
8 changes: 6 additions & 2 deletions tests/gh_155.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
--TEST--
Test for bug 155
--SKIPIF--
<?php if (!extension_loaded("memcached")) print "skip"; ?>
<?php
$min_version = "1.4.8";
include dirname(__FILE__) . "/skipif.inc";
if (Memcached::LIBMEMCACHED_VERSION_HEX < 0x01000016) die ('skip too old libmemcached');
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
Expand Down Expand Up @@ -38,4 +42,4 @@ TOUCH: SUCCESS
TOUCH: SUCCESS
GET: SUCCESS
GET: SUCCESS
DONE
DONE
6 changes: 4 additions & 2 deletions tests/gh_77.phpt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
--TEST--
Test for Github issue #77
--SKIPIF--
<?php if (!extension_loaded("memcached")) print "skip";
if (Memcached::LIBMEMCACHED_VERSION_HEX < 0x01000016) die ('skip too old libmemcached');
<?php
$min_version = "1.4.8";
include dirname(__FILE__) . "/skipif.inc";
if (Memcached::LIBMEMCACHED_VERSION_HEX < 0x01000016) die ('skip too old libmemcached');
?>
--FILE--
<?php
Expand Down
16 changes: 16 additions & 0 deletions tests/skipif.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
if (!extension_loaded("memcached")) {
die("skip memcached is not loaded\n");
}

include dirname(__FILE__) . "/config.inc";

if (($m = memc_get_instance()) === NULL) {
die ("skip can not connect to server\n");
}

if (isset($min_version)) {
if (version_compare(memc_get_version($m), $min_version, "<")) {
die("skip version of server pool is too old, $min_version is required\n");
}
}
6 changes: 4 additions & 2 deletions tests/touch_binary.phpt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
--TEST--
Touch in binary mode
--SKIPIF--
<?php if (!extension_loaded("memcached")) print "skip";
if (Memcached::LIBMEMCACHED_VERSION_HEX < 0x01000016) die ('skip too old libmemcached');
<?php
$min_version = "1.4.8"; //TOUCH is added since 1.4.8
include dirname(__FILE__) . "/skipif.inc";
if (Memcached::LIBMEMCACHED_VERSION_HEX < 0x01000016) die ('skip too old libmemcached');
?>
--FILE--
<?php
Expand Down