From 132ce6a232e3a82967d5fcccda01fc33179163ff Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 4 Mar 2015 17:29:14 -0800 Subject: [PATCH 1/3] Added CONFIG environment variable to build and test scripts, fixed some bugs --- tools/run_tests/build_node.sh | 8 ++--- tools/run_tests/jobset.py | 6 +++- tools/run_tests/run_node.sh | 4 +++ tools/run_tests/run_tests.py | 55 +++++++++++++++++++++++++++++++++-- 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/tools/run_tests/build_node.sh b/tools/run_tests/build_node.sh index c3e88c565d2..c85ecf1b259 100755 --- a/tools/run_tests/build_node.sh +++ b/tools/run_tests/build_node.sh @@ -36,12 +36,8 @@ CONFIG=${CONFIG:-opt} # change to grpc repo root cd $(dirname $0)/../.. -# tells npm install to look for files in that directory -export GRPC_ROOT=`pwd` -# tells npm install the subdirectory with library files -export GRPC_LIB_SUBDIR=libs/$CONFIG -# tells npm install not to use default locations -export GRPC_NO_INSTALL=yes +export CXXFLAGS=-I`pwd`/include +export LDFLAGS=-L`pwd`/libs/$CONFIG cd src/node diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py index ad65da535b4..26caf031c3a 100755 --- a/tools/run_tests/jobset.py +++ b/tools/run_tests/jobset.py @@ -136,7 +136,7 @@ def which(filename): class JobSpec(object): """Specifies what to run for a job.""" - def __init__(self, cmdline, shortname=None, environ={}, hash_targets=[]): + def __init__(self, cmdline, shortname=None, environ=None, hash_targets=None): """ Arguments: cmdline: a list of arguments to pass as the command line @@ -144,6 +144,10 @@ class JobSpec(object): hash_targets: which files to include in the hash representing the jobs version (or empty, indicating the job should not be hashed) """ + if environ is None: + environ = {} + if hash_targets is None: + hash_targets = [] self.cmdline = cmdline self.environ = environ self.shortname = cmdline[0] if shortname is None else shortname diff --git a/tools/run_tests/run_node.sh b/tools/run_tests/run_node.sh index ccf1b9d6f54..3a82c04a8ef 100755 --- a/tools/run_tests/run_node.sh +++ b/tools/run_tests/run_node.sh @@ -30,9 +30,13 @@ set -ex +CONFIG=${CONFIG:-opt} + # change to grpc repo root cd $(dirname $0)/../.. root=`pwd` +export LD_LIBRARY_PATH=$root/libs/$CONFIG + $root/src/node/node_modules/mocha/bin/mocha $root/src/node/test diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index e1e4a4ba204..63bd0b7e8c9 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -51,11 +51,14 @@ os.chdir(ROOT) # SimpleConfig: just compile with CONFIG=config, and run the binary to test class SimpleConfig(object): - def __init__(self, config, environ={}): + def __init__(self, config, environ=None): + if environ is None: + environ = {} self.build_config = config self.maxjobs = 2 * multiprocessing.cpu_count() self.allow_hashing = (config != 'gcov') self.environ = environ + self.environ['CONFIG'] = config def job_spec(self, binary, hash_targets): return jobset.JobSpec(cmdline=[binary], @@ -67,7 +70,9 @@ class SimpleConfig(object): # ValgrindConfig: compile with some CONFIG=config, but use valgrind to run class ValgrindConfig(object): - def __init__(self, config, tool, args=[]): + def __init__(self, config, tool, args=None): + if args is None: + args = [] self.build_config = config self.tool = tool self.args = args @@ -104,6 +109,12 @@ class CLanguage(object): def build_steps(self): return [] + def supports_multi_config(self): + return True + + def __str__(self): + return self.make_target + class NodeLanguage(object): @@ -116,6 +127,12 @@ class NodeLanguage(object): def build_steps(self): return [['tools/run_tests/build_node.sh']] + def supports_multi_config(self): + return False + + def __str__(self): + return 'node' + class PhpLanguage(object): @@ -128,6 +145,12 @@ class PhpLanguage(object): def build_steps(self): return [['tools/run_tests/build_php.sh']] + def supports_multi_config(self): + return False + + def __str__(self): + return 'php' + class PythonLanguage(object): @@ -140,6 +163,12 @@ class PythonLanguage(object): def build_steps(self): return [['tools/run_tests/build_python.sh']] + def supports_multi_config(self): + return False + + def __str__(self): + return 'python' + class RubyLanguage(object): def test_specs(self, config, travis): @@ -151,6 +180,12 @@ class RubyLanguage(object): def build_steps(self): return [['tools/run_tests/build_ruby.sh']] + def supports_multi_config(self): + return False + + def __str__(self): + return 'ruby' + class CSharpLanguage(object): def test_specs(self, config, travis): @@ -162,6 +197,12 @@ class CSharpLanguage(object): def build_steps(self): return [['tools/run_tests/build_csharp.sh']] + def supports_multi_config(self): + return False + + def __str__(self): + return 'csharp' + # different configurations we can run under _CONFIGS = { 'dbg': SimpleConfig('dbg'), @@ -226,6 +267,13 @@ build_configs = set(cfg.build_config for cfg in run_configs) make_targets = [] languages = set(_LANGUAGES[l] for l in args.language) + +if len(build_configs) > 1: + for language in languages: + if not language.supports_multi_config(): + print language, 'does not support multiple build configurations' + sys.exit(1) + build_steps = [jobset.JobSpec(['make', '-j', '%d' % (multiprocessing.cpu_count() + 1), 'EXTRA_DEFINES=GRPC_TEST_SLOWDOWN_MACHINE_FACTOR=%f' % args.slowdown, @@ -233,7 +281,8 @@ build_steps = [jobset.JobSpec(['make', itertools.chain.from_iterable( l.make_targets() for l in languages)))) for cfg in build_configs] + list(set( - jobset.JobSpec(cmdline) + jobset.JobSpec(cmdline, environ={'CONFIG': cfg}) + for cfg in build_configs for l in languages for cmdline in l.build_steps())) one_run = set( From e40ff65efdbf844da9d6fb20ad6a25f31b783925 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 4 Mar 2015 17:29:32 -0800 Subject: [PATCH 2/3] Cleaned out some cruft from binding.gyp --- src/node/binding.gyp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/node/binding.gyp b/src/node/binding.gyp index 10afaf69627..6f7620d990f 100644 --- a/src/node/binding.gyp +++ b/src/node/binding.gyp @@ -24,7 +24,9 @@ 'link_settings': { 'libraries': [ '-lrt', - '-lpthread' + '-lpthread', + '-lgrpc', + '-lgpr' ], }, "target_name": "grpc", @@ -38,27 +40,6 @@ "ext/server.cc", "ext/server_credentials.cc", "ext/timeval.cc" - ], - 'conditions' : [ - ['no_install=="yes"', { - 'include_dirs': [ - "<(grpc_root)/include" - ], - 'link_settings': { - 'libraries': [ - '<(grpc_root)/<(grpc_lib_subdir)/libgrpc.a', - '<(grpc_root)/<(grpc_lib_subdir)/libgpr.a' - ] - } - }], - ['no_install!="yes"', { - 'link_settings': { - 'libraries': [ - '-lgrpc', - '-lgpr' - ] - } - }] ] } ] From 2decfa2f7caf67e6129c2e02a62b8feb2d20e3bd Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 4 Mar 2015 17:33:00 -0800 Subject: [PATCH 3/3] Removed extra variables --- src/node/binding.gyp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/node/binding.gyp b/src/node/binding.gyp index 6f7620d990f..7ef3bdf4bde 100644 --- a/src/node/binding.gyp +++ b/src/node/binding.gyp @@ -1,9 +1,4 @@ { - "variables" : { - 'no_install': "