diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | src/php/.gitignore | 5 | ||||
-rwxr-xr-x | src/php/bin/run_tests.sh | 16 | ||||
-rwxr-xr-x | src/php/ext/grpc/config.m4 | 17 | ||||
-rwxr-xr-x | tools/run_tests/build_php.sh | 21 | ||||
-rwxr-xr-x | tools/run_tests/run_tests.py | 101 |
6 files changed, 114 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore index bf57027c94..954b3cfcc1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ objs # cache for run_tests.py .run_tests_cache + diff --git a/src/php/.gitignore b/src/php/.gitignore index 00fbd965dc..0bb5f8e956 100755..100644 --- a/src/php/.gitignore +++ b/src/php/.gitignore @@ -15,4 +15,7 @@ run-tests.php install-sh libtool missing -mkinstalldirs
\ No newline at end of file +mkinstalldirs + +ext/grpc/ltmain.sh + diff --git a/src/php/bin/run_tests.sh b/src/php/bin/run_tests.sh index cf4cc78a52..28282c3e37 100755 --- a/src/php/bin/run_tests.sh +++ b/src/php/bin/run_tests.sh @@ -1,5 +1,17 @@ +#!/bin/sh # Loads the local shared library, and runs all of the test cases in tests/ # against it +set -e cd $(dirname $0) -php -d extension_dir=../ext/grpc/modules/ -d extension=grpc.so \ - /usr/local/bin/phpunit -v --debug --strict ../tests/unit_tests +default_extension_dir=`php -i | grep extension_dir | sed 's/.*=> //g'` + +# sym-link in system supplied extensions +for f in $default_extension_dir/*.so +do + ln -s $f ../ext/grpc/modules/$(basename $f) &> /dev/null || true +done + +php \ + -d extension_dir=../ext/grpc/modules/ \ + -d extension=grpc.so \ + `which phpunit` -v --debug --strict ../tests/unit_tests diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index d7d13f413e..27c67781e7 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -38,7 +38,9 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) - PHP_ADD_LIBPATH($GRPC_DIR/lib) + GRPC_LIBDIR=$GRPC_DIR/${GRPC_LIB_SUBDIR-lib} + + PHP_ADD_LIBPATH($GRPC_LIBDIR) PHP_CHECK_LIBRARY(gpr,gpr_now, [ @@ -48,18 +50,9 @@ if test "$PHP_GRPC" != "no"; then ],[ AC_MSG_ERROR([wrong gpr lib version or lib not found]) ],[ - -L$GRPC_DIR/lib + -L$GRPC_LIBDIR ]) - PHP_ADD_LIBRARY(event,,GRPC_SHARED_LIBADD) - PHP_ADD_LIBRARY(event) - - PHP_ADD_LIBRARY(event_pthreads,,GRPC_SHARED_LIBADD) - PHP_ADD_LIBRARY(event_pthreads) - - PHP_ADD_LIBRARY(event_core,,GRPC_SHARED_LIBADD) - PHP_ADD_LIBRARY(event_core) - PHP_CHECK_LIBRARY(grpc,grpc_channel_destroy, [ PHP_ADD_LIBRARY(grpc,,GRPC_SHARED_LIBADD) @@ -68,7 +61,7 @@ if test "$PHP_GRPC" != "no"; then ],[ AC_MSG_ERROR([wrong grpc lib version or lib not found]) ],[ - -L$GRPC_DIR/lib + -L$GRPC_LIBDIR ]) PHP_SUBST(GRPC_SHARED_LIBADD) diff --git a/tools/run_tests/build_php.sh b/tools/run_tests/build_php.sh new file mode 100755 index 0000000000..6841656bdb --- /dev/null +++ b/tools/run_tests/build_php.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -ex + +# change to grpc repo root +cd $(dirname $0)/../.. + +root=`pwd` +export GRPC_LIB_SUBDIR=libs/opt + +# make the libraries +make -j static_c + +# build php +cd src/php + +cd ext/grpc +phpize +./configure --enable-grpc=$root +make + diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index e8c121456a..d291abf3bf 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -20,6 +20,7 @@ class SimpleConfig(object): def __init__(self, config): self.build_config = config self.maxjobs = 32 * multiprocessing.cpu_count() + self.allow_hashing = (config != 'gcov') def run_command(self, binary): return [binary] @@ -32,11 +33,43 @@ class ValgrindConfig(object): self.build_config = config self.tool = tool self.maxjobs = 4 * multiprocessing.cpu_count() + self.allow_hashing = False def run_command(self, binary): return ['valgrind', binary, '--tool=%s' % self.tool] +class CLanguage(object): + + def __init__(self, make_target): + self.allow_hashing = True + self.make_target = make_target + + def test_binaries(self, config): + return glob.glob('bins/%s/*_test' % config) + + def make_targets(self): + return ['buildtests_%s' % self.make_target] + + def build_steps(self): + return [] + + +class PhpLanguage(object): + + def __init__(self): + self.allow_hashing = False + + def test_binaries(self, config): + return ['src/php/bin/run_tests.sh'] + + def make_targets(self): + return [] + + def build_steps(self): + return [['tools/run_tests/build_php.sh']] + + # different configurations we can run under _CONFIGS = { 'dbg': SimpleConfig('dbg'), @@ -51,9 +84,10 @@ _CONFIGS = { _DEFAULT = ['dbg', 'opt'] -_LANGUAGE_TEST_TARGETS = { - 'c++': 'buildtests_cxx', - 'c': 'buildtests_c', +_LANGUAGES = { + 'c++': CLanguage('cxx'), + 'c': CLanguage('c'), + 'php': PhpLanguage() } # parse command line @@ -62,7 +96,6 @@ argp.add_argument('-c', '--config', choices=['all'] + sorted(_CONFIGS.keys()), nargs='+', default=_DEFAULT) -argp.add_argument('-t', '--test-filter', nargs='*', default=['*']) argp.add_argument('-n', '--runs_per_test', default=1, type=int) argp.add_argument('-f', '--forever', default=False, @@ -73,9 +106,9 @@ argp.add_argument('--newline_on_success', action='store_const', const=True) argp.add_argument('-l', '--language', - choices=sorted(_LANGUAGE_TEST_TARGETS.keys()), + choices=sorted(_LANGUAGES.keys()), nargs='+', - default=sorted(_LANGUAGE_TEST_TARGETS.keys())) + default=sorted(_LANGUAGES.keys())) args = argp.parse_args() # grab config @@ -84,8 +117,18 @@ run_configs = set(_CONFIGS[cfg] _CONFIGS.iterkeys() if x == 'all' else [x] for x in args.config)) build_configs = set(cfg.build_config for cfg in run_configs) -make_targets = set(_LANGUAGE_TEST_TARGETS[x] for x in args.language) -filters = args.test_filter + +make_targets = [] +languages = set(_LANGUAGES[l] for l in args.language) +build_steps = [['make', + '-j', '%d' % (multiprocessing.cpu_count() + 1), + 'CONFIG=%s' % cfg] + list(set( + itertools.chain.from_iterable(l.make_targets() + for l in languages))) + for cfg in build_configs] + list( + itertools.chain.from_iterable(l.build_steps() + for l in languages)) + runs_per_test = args.runs_per_test forever = args.forever @@ -127,37 +170,30 @@ class TestCache(object): def _build_and_run(check_cancelled, newline_on_success, cache): """Do one pass of building & running tests.""" # build latest, sharing cpu between the various makes - if not jobset.run( - (['make', - '-j', '%d' % (multiprocessing.cpu_count() + 1), - 'CONFIG=%s' % cfg] + list(make_targets) - for cfg in build_configs), - check_cancelled, maxjobs=1): + if not jobset.run(build_steps): return 1 # run all the tests - if not jobset.run( - itertools.ifilter( - lambda x: x is not None, ( - config.run_command(x) - for config in run_configs - for filt in filters - for x in itertools.chain.from_iterable(itertools.repeat( - glob.glob('bins/%s/%s_test' % ( - config.build_config, filt)), - runs_per_test)))), - check_cancelled, - newline_on_success=newline_on_success, - maxjobs=min(c.maxjobs for c in run_configs), - cache=cache): + one_run = dict( + (' '.join(config.run_command(x)), config.run_command(x)) + for config in run_configs + for language in args.language + for x in _LANGUAGES[language].test_binaries(config.build_config) + ).values() + all_runs = itertools.chain.from_iterable( + itertools.repeat(one_run, runs_per_test)) + if not jobset.run(all_runs, check_cancelled, + newline_on_success=newline_on_success, + maxjobs=min(c.maxjobs for c in run_configs), + cache=cache): return 2 return 0 -test_cache = (None if runs_per_test != 1 - or 'gcov' in build_configs - or 'valgrind' in build_configs +test_cache = (None + if not all(x.allow_hashing + for x in itertools.chain(languages, run_configs)) else TestCache()) if test_cache: test_cache.maybe_load() @@ -177,6 +213,7 @@ if forever: 'All tests are now passing properly', do_newline=True) jobset.message('IDLE', 'No change detected') + if test_cache: test_cache.save() while not have_files_changed(): time.sleep(1) else: @@ -187,5 +224,5 @@ else: jobset.message('SUCCESS', 'All tests passed', do_newline=True) else: jobset.message('FAILED', 'Some tests failed', do_newline=True) - test_cache.save() + if test_cache: test_cache.save() sys.exit(result) |