mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 18:41:52 +00:00
Make valgrind run on travis tests of v8js
Valgrind checks for invalid memory accesses and memory leaks. "-m" makes php unit tests use valgrind (and malloc instead of emalloc, etc.) (Takes around 20 minutes) Also support testing v8js with NTS (The default used by Travis is ZTS) One of the builds will download and install PHP. This will be cached. - This reproduces #247 on travis - For details on travis build caching, see https://docs.travis-ci.com/user/caching/#Pull-request-builds-and-caches Skip memory and time limit tests - Those are flaky with valgrind. The tests fail but don't have memory leaks. (When https://github.com/phpv8/v8js/pull/248 was tested) Use 5.7 (earliest ppa >= 5.6) for running valgrind checks. Fix ppa checks - The installation folder changed to /opt/libv8-5.7 - run tests both with and without valgrind in libv8 5.7 Otherwise, time limits and memory limits wouldn't be tested at all in 5.7 Always pass strings for splitting environment variables by spaces.
This commit is contained in:
parent
2356a898aa
commit
1ec2a57e44
15
.travis.yml
15
.travis.yml
@ -1,15 +1,28 @@
|
|||||||
language: php
|
language: php
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/travis_cache
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
- V8VER=5.7
|
||||||
- V8VER=5.2
|
- V8VER=5.2
|
||||||
- V8VER=5.1
|
- V8VER=5.1
|
||||||
|
# Some bugs in v8js only show up without zts enabled.
|
||||||
|
# Notices with valgrind in libv8 were fixed in later v8js versions.
|
||||||
|
- V8VER=5.7 VALGRIND=1
|
||||||
|
- V8VER=5.7 VALGRIND=1 PHP_NTS_USE=1 PHP_CONFIGURE_ARGS="--disable-all --disable-zts --enable-debug"
|
||||||
|
|
||||||
before_install: make -f Makefile.travis before_install
|
before_install: make -f Makefile.travis before_install
|
||||||
install: make -f Makefile.travis install
|
install:
|
||||||
|
# For NTS builds: Install NTS and set the php.ini to a different blank file.
|
||||||
|
- if [ "x$PHP_NTS_USE" != "x" ]; then export PHP_NTS_VERSION=$(./ci/get_global_php_version.sh); echo "Version is $PHP_NTS_VERSION"; ./ci/install_php_nts.sh || exit 1; export PATH="$(./ci/generate_php_install_dir.sh)/bin:$PATH"; export PHPRC=$PWD/ci/; else ./ci/wipe_travis_cache.sh; fi
|
||||||
|
- if [ "$VALGRIND" = 1 ]; then sudo apt-get install -qq valgrind; export TEST_PHP_ARGS="-m"; fi
|
||||||
|
- make -f Makefile.travis install
|
||||||
|
|
||||||
script: make -f Makefile.travis test
|
script: make -f Makefile.travis test
|
||||||
|
@ -11,9 +11,10 @@ before_install:
|
|||||||
install:
|
install:
|
||||||
sudo apt-get install -y libv8-$(V8VER)-dev
|
sudo apt-get install -y libv8-$(V8VER)-dev
|
||||||
|
|
||||||
|
# newer releases (E.g. 5.7) of the ppa install the headers and lib to /opt/libv8-VER
|
||||||
build:
|
build:
|
||||||
phpize
|
phpize
|
||||||
./configure
|
if [ -d /opt/libv8-$(V8VER) ]; then ./configure --with-v8js=/opt/libv8-$(V8VER); else ./configure; fi
|
||||||
$(MAKE) -j3
|
$(MAKE) -j3
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
|
20
ci/generate_php_install_dir.sh
Executable file
20
ci/generate_php_install_dir.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash -xeu
|
||||||
|
# Print a folder name based on the integer width(32 bit or 64 bit), whether or not NTS is used (implied by PHP_CONFIGURE_ARGS), and PHP_CONFIGURE_ARGS.
|
||||||
|
PHP_NTS_NORMAL_VERSION=${PHP_NTS_VERSION//RC[0-9]/}
|
||||||
|
if [ "$PHP_NTS_NORMAL_VERSION" = "7.1.0" ]; then
|
||||||
|
PHP_NTS_NORMAL_VERSION=7.1.0RC1
|
||||||
|
fi
|
||||||
|
PHP_INSTALL_DIR="$HOME/travis_cache/php-$PHP_NTS_NORMAL_VERSION"
|
||||||
|
if [ "${USE_32BIT:-0}" = "1" ]; then
|
||||||
|
PHP_INSTALL_DIR="$PHP_INSTALL_DIR-32bit"
|
||||||
|
else
|
||||||
|
PHP_INSTALL_DIR="$PHP_INSTALL_DIR-64bit"
|
||||||
|
fi
|
||||||
|
if [ "$PHP_NTS_USE" = "1" ]; then
|
||||||
|
PHP_INSTALL_DIR="$PHP_INSTALL_DIR-nts"
|
||||||
|
else
|
||||||
|
PHP_INSTALL_DIR="$PHP_INSTALL_DIR-zts"
|
||||||
|
fi
|
||||||
|
HASH=$(echo -n "$PHP_CONFIGURE_ARGS" | sha1sum | cut -c -4)
|
||||||
|
PHP_INSTALL_DIR="$PHP_INSTALL_DIR-$HASH"
|
||||||
|
echo -n "$PHP_INSTALL_DIR"
|
2
ci/get_global_php_version.sh
Executable file
2
ci/get_global_php_version.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
php -r "echo(preg_replace('/-dev|RC.*/','',PHP_VERSION));"
|
31
ci/install_php_nts.sh
Executable file
31
ci/install_php_nts.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash -xeu
|
||||||
|
|
||||||
|
echo "Attempting to install NTS PHP, NTS version '$PHP_NTS_VERSION'/ configure args '$PHP_CONFIGURE_ARGS'"
|
||||||
|
if [ "x$PHP_NTS_VERSION" = "x" -o "x$PHP_CONFIGURE_ARGS" = "x" ] ; then
|
||||||
|
echo "Missing nts version or configuration arguments";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
PHP_FOLDER="php-$PHP_NTS_VERSION"
|
||||||
|
PHP_INSTALL_DIR="$HOME/travis_cache/$PHP_FOLDER"
|
||||||
|
echo "Downloading $PHP_INSTALL_DIR\n"
|
||||||
|
if [ -x $PHP_INSTALL_DIR/bin/php ] ; then
|
||||||
|
echo "PHP $PHP_NTS_VERSION already installed and in cache at $HOME/travis_cache/$PHP_FOLDER";
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# Remove cache if it somehow exists
|
||||||
|
rm -rf $HOME/travis_cache/
|
||||||
|
# Otherwise, put a minimal installation inside of the cache.
|
||||||
|
PHP_TAR_FILE="$PHP_FOLDER.tar.bz2"
|
||||||
|
curl --verbose https://secure.php.net/distributions/$PHP_TAR_FILE -o $PHP_TAR_FILE
|
||||||
|
tar xjf $PHP_TAR_FILE
|
||||||
|
pushd $PHP_FOLDER
|
||||||
|
./configure $PHP_CONFIGURE_ARGS --prefix=$HOME/travis_cache/$PHP_FOLDER
|
||||||
|
make -j5
|
||||||
|
make install
|
||||||
|
popd
|
||||||
|
|
||||||
|
# Optionally, can make cached data smaller
|
||||||
|
# If no test files have --PHPDBG--, then phpdbg can be removed
|
||||||
|
# If no test files have --POST-- (or GET, etc), then php-cgi can be removed
|
||||||
|
|
||||||
|
echo "PHP $PHP_NTS_VERSION already installed and in cache at $HOME/travis_cache/$PHP_FOLDER";
|
1
ci/php.ini
Normal file
1
ci/php.ini
Normal file
@ -0,0 +1 @@
|
|||||||
|
; Intentionally left blank.
|
14
ci/wipe_travis_cache.sh
Executable file
14
ci/wipe_travis_cache.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash -xeu
|
||||||
|
# Ensure that ~/travis_cache is a folder with 0 files in it.
|
||||||
|
# This avoids accidentally caching left over files in s3.
|
||||||
|
CACHE_DIR="$HOME/travis_cache"
|
||||||
|
if [ -d "$CACHE_DIR" ]; then
|
||||||
|
if [ find "$CACHE_DIR" -mindepth 1 -print -quit | grep -q . ]; then
|
||||||
|
echo "$CACHE_DIR was not empty, clearing"
|
||||||
|
rm -rf $CACHE_DIR;
|
||||||
|
mkdir "$CACHE_DIR"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$CACHE_DIR did not exist, creating an empty directory to cache"
|
||||||
|
mkdir "$CACHE_DIR"
|
||||||
|
fi
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -3,3 +3,17 @@
|
|||||||
if (!extension_loaded('v8js')) {
|
if (!extension_loaded('v8js')) {
|
||||||
die("skip");
|
die("skip");
|
||||||
}
|
}
|
||||||
|
function skip_if_using_valgrind() {
|
||||||
|
// Travis encounters valgrind failures for tests of time and memory limits (even in libv8 5.7 PPA), but not able to reproduce this locally.
|
||||||
|
// NOTE: to debug this, try dumping *.mem if `make test` has a non-zero exit code
|
||||||
|
// VALGRIND_LAUNCHER doesn't exist for my env in 7.1, but 'TESTS' does
|
||||||
|
// Not exactly perfect to check for '-m', but close enough.
|
||||||
|
//
|
||||||
|
// Travis testing or full testing may use the environment variable TEST_PHP_ARGS
|
||||||
|
// But local testing may instead use TESTS
|
||||||
|
if (strlen($_ENV['VALGRIND_LAUNCHER'] ?? '') > 0 ||
|
||||||
|
in_array('-m', explode(' ', $_ENV['TESTS'] ?? '')) ||
|
||||||
|
in_array('-m', explode(' ', $_ENV['TEST_PHP_ARGS'] ?? ''))) {
|
||||||
|
die("skip test flaky on valgrind");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -7,6 +7,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
|||||||
if (getenv("SKIP_SLOW_TESTS")) {
|
if (getenv("SKIP_SLOW_TESTS")) {
|
||||||
die("skip slow test");
|
die("skip slow test");
|
||||||
}
|
}
|
||||||
|
skip_if_using_valgrind();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
Loading…
Reference in New Issue
Block a user