Merge pull request #5574 from nicolasnoble/python2

Adding a python_wrapper.sh script to call in an appropriate python2 interpreter
pull/5494/head
Jan Tattermusch 9 years ago
commit 47277bc127
  1. 34
      test/core/httpcli/httpcli_test.c
  2. 36
      test/core/httpcli/httpscli_test.c
  3. 47
      tools/distrib/python_wrapper.sh

@ -144,31 +144,35 @@ int main(int argc, char **argv) {
char *lslash = strrchr(me, '/');
char *args[4];
int port = grpc_pick_unused_port_or_die();
int arg_shift = 0;
/* figure out where we are */
char *root;
if (lslash) {
root = gpr_malloc((size_t)(lslash - me + 1));
memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
root = gpr_strdup(".");
}
GPR_ASSERT(argc <= 2);
if (argc == 2) {
args[0] = gpr_strdup(argv[1]);
} else {
/* figure out where we are */
char *root;
if (lslash) {
root = gpr_malloc((size_t)(lslash - me + 1));
memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
root = gpr_strdup(".");
}
gpr_asprintf(&args[0], "%s/../../test/core/httpcli/test_server.py", root);
gpr_free(root);
arg_shift = 1;
gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root);
gpr_asprintf(&args[1], "%s/../../test/core/httpcli/test_server.py", root);
}
/* start the server */
args[1] = "--port";
gpr_asprintf(&args[2], "%d", port);
server = gpr_subprocess_create(3, (const char **)args);
args[1 + arg_shift] = "--port";
gpr_asprintf(&args[2 + arg_shift], "%d", port);
server = gpr_subprocess_create(3 + arg_shift, (const char **)args);
GPR_ASSERT(server);
gpr_free(args[0]);
gpr_free(args[2]);
if (arg_shift) gpr_free(args[1]);
gpr_free(args[2 + arg_shift]);
gpr_free(root);
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(5, GPR_TIMESPAN)));

@ -146,32 +146,36 @@ int main(int argc, char **argv) {
char *lslash = strrchr(me, '/');
char *args[5];
int port = grpc_pick_unused_port_or_die();
int arg_shift = 0;
/* figure out where we are */
char *root;
if (lslash) {
root = gpr_malloc((size_t)(lslash - me + 1));
memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
root = gpr_strdup(".");
}
GPR_ASSERT(argc <= 2);
if (argc == 2) {
args[0] = gpr_strdup(argv[1]);
} else {
/* figure out where we are */
char *root;
if (lslash) {
root = gpr_malloc((size_t)(lslash - me + 1));
memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
root = gpr_strdup(".");
}
gpr_asprintf(&args[0], "%s/../../test/core/httpcli/test_server.py", root);
gpr_free(root);
arg_shift = 1;
gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root);
gpr_asprintf(&args[1], "%s/../../test/core/httpcli/test_server.py", root);
}
/* start the server */
args[1] = "--port";
gpr_asprintf(&args[2], "%d", port);
args[3] = "--ssl";
server = gpr_subprocess_create(4, (const char **)args);
args[1 + arg_shift] = "--port";
gpr_asprintf(&args[2 + arg_shift], "%d", port);
args[3 + arg_shift] = "--ssl";
server = gpr_subprocess_create(4 + arg_shift, (const char **)args);
GPR_ASSERT(server);
gpr_free(args[0]);
gpr_free(args[2]);
if (arg_shift) gpr_free(args[1]);
gpr_free(args[2 + arg_shift]);
gpr_free(root);
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(5, GPR_TIMESPAN)));

@ -0,0 +1,47 @@
#!/bin/sh
# Copyright 2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
for p in python2.7 python2.6 python2 python not_found ; do
python=`which $p || echo not_found`
if [ -x "$python" ] ; then
break
fi
done
if [ -x "$python" ] ; then
exec $python $@
else
echo "No acceptable version of python found on the system"
exit 1
fi
Loading…
Cancel
Save