Allow selecting poll strategy, start to stub ev_poll_posix.c

pull/5647/head
Craig Tiller 9 years ago
parent ee821bb10b
commit 253bd50167
  1. 1645
      src/core/iomgr/ev_poll_posix.c
  2. 41
      src/core/iomgr/ev_poll_posix.h
  3. 79
      src/core/iomgr/ev_posix.c
  4. 24
      test/core/end2end/gen_build_yaml.py
  5. 12
      tools/run_tests/run_tests.py
  6. 36619
      tools/run_tests/tests.json

File diff suppressed because it is too large Load Diff

@ -0,0 +1,41 @@
/*
*
* Copyright 2015-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.
*
*/
#ifndef GRPC_INTERNAL_CORE_IOMGR_EV_POLL_POSIX_H
#define GRPC_INTERNAL_CORE_IOMGR_EV_POLL_POSIX_H
#include "src/core/iomgr/ev_posix.h"
const grpc_event_engine_vtable *grpc_init_poll_posix(void);
#endif // GRPC_INTERNAL_CORE_IOMGR_EV_POLL_AND_EPOLL_POSIX_H

@ -33,19 +33,94 @@
#include "src/core/iomgr/ev_posix.h"
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
#include "src/core/iomgr/ev_poll_and_epoll_posix.h"
#include "src/core/iomgr/ev_poll_posix.h"
#include "src/core/support/env.h"
static const grpc_event_engine_vtable *g_event_engine;
void grpc_event_engine_init(void) {
if ((g_event_engine = grpc_init_poll_and_epoll_posix())) {
typedef const grpc_event_engine_vtable *(*event_engine_factory_fn)(void);
typedef struct {
const char *name;
event_engine_factory_fn factory;
} event_engine_factory;
static const event_engine_factory g_factories[] = {
{"poll", grpc_init_poll_posix}, {"legacy", grpc_init_poll_and_epoll_posix},
};
static void add(const char *beg, const char *end, char ***ss, size_t *ns) {
size_t n = *ns;
size_t np = n + 1;
char *s;
size_t len;
GPR_ASSERT(end >= beg);
len = (size_t)(end - beg);
s = gpr_malloc(len + 1);
memcpy(s, beg, len);
s[len] = 0;
*ss = gpr_realloc(*ss, sizeof(char **) * np);
(*ss)[n] = s;
*ns = np;
}
static void split(const char *s, char ***ss, size_t *ns) {
const char *c = strchr(s, ',');
if (c == NULL) {
add(s, s + strlen(s), ss, ns);
} else {
add(s, c, ss, ns);
split(c + 1, ss, ns);
}
}
static bool is(const char *want, const char *have) {
return 0 == strcmp(want, "all") || 0 == strcmp(want, have);
}
static void try_engine(const char *engine) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(g_factories); i++) {
if (is(engine, g_factories[i].name)) {
if ((g_event_engine = g_factories[i].factory())) {
return;
}
}
}
}
void grpc_event_engine_init(void) {
char *s = gpr_getenv("GRPC_POLL_STRATEGY");
if (s == NULL) {
s = gpr_strdup("all");
}
char **strings = NULL;
size_t nstrings = 0;
split(s, &strings, &nstrings);
for (size_t i = 0; g_event_engine == NULL && i < nstrings; i++) {
try_engine(strings[i]);
}
for (size_t i = 0; i < nstrings; i++) {
gpr_free(strings[i]);
}
gpr_free(strings);
gpr_free(s);
if (g_event_engine == NULL) {
gpr_log(GPR_ERROR, "No event engine could be initialized");
abort();
}
}
void grpc_event_engine_shutdown(void) { g_event_engine->shutdown_engine(); }

@ -47,6 +47,15 @@ default_secure_fixture_options = default_unsecure_fixture_options._replace(secur
uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix'])
# map a platform to available polling strategies
POLLING_STRATEGY = {
'windows': ['all'],
'linux': ['poll', 'legacy'],
'mac': ['poll'],
'posix': ['poll'],
}
# maps fixture name to whether it requires the security library
END2END_FIXTURES = {
'h2_compress': default_unsecure_fixture_options,
@ -241,17 +250,22 @@ def main():
{
'name': '%s_test' % f,
'args': [t],
'env': {
'GRPC_POLL_STRATEGY': poll_strategy
},
'exclude_configs': [],
'platforms': END2END_FIXTURES[f].platforms,
'ci_platforms': (END2END_FIXTURES[f].platforms
if END2END_FIXTURES[f].ci_mac else without(
END2END_FIXTURES[f].platforms, 'mac')),
'platforms': [platform],
'ci_platforms': [platform],
'flaky': False,
'language': 'c',
'cpu_cost': END2END_TESTS[t].cpu_cost,
}
for f in sorted(END2END_FIXTURES.keys())
for t in sorted(END2END_TESTS.keys()) if compatible(f, t)
for t in sorted(END2END_TESTS.keys())
for platform in sorted(END2END_FIXTURES[f].platforms)
for poll_strategy in POLLING_STRATEGY[platform]
if compatible(f, t)
and (END2END_FIXTURES[f].ci_mac or platform != 'mac')
] + [
{
'name': '%s_nosec_test' % f,

@ -159,13 +159,21 @@ class CLanguage(object):
target['name'])
else:
binary = 'bins/%s/%s' % (self.config.build_config, target['name'])
env = {}
shortname = ' '.join(cmdline)
if 'env' in target:
tenv = target['env']
env.update(tenv)
shortname += ' '
shortname += ' '.join('%s=%s' % (key, tenv[key]) for key in sorted(tenv.keys()))
env['GRPC_DEFAULT_SSL_ROOTS_FILE_PATH'] = (
_ROOT + '/src/core/tsi/test_creds/ca.pem')
if os.path.isfile(binary):
cmdline = [binary] + target['args']
out.append(self.config.job_spec(cmdline, [binary],
shortname=' '.join(cmdline),
cpu_cost=target['cpu_cost'],
environ={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
_ROOT + '/src/core/tsi/test_creds/ca.pem'}))
environ=env))
elif self.args.regex == '.*' or self.platform == 'windows':
print '\nWARNING: binary not found, skipping', binary
return sorted(out)

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save