mirror of https://github.com/grpc/grpc.git
commit
693d2b48ab
100 changed files with 1736 additions and 413 deletions
@ -0,0 +1,98 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017, 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. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/lib/support/arena.h" |
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/atm.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/useful.h> |
||||
|
||||
#define ROUND_UP_TO_ALIGNMENT_SIZE(x) \ |
||||
(((x) + GPR_MAX_ALIGNMENT - 1u) & ~(GPR_MAX_ALIGNMENT - 1u)) |
||||
|
||||
typedef struct zone { |
||||
size_t size_begin; |
||||
size_t size_end; |
||||
gpr_atm next_atm; |
||||
} zone; |
||||
|
||||
struct gpr_arena { |
||||
gpr_atm size_so_far; |
||||
zone initial_zone; |
||||
}; |
||||
|
||||
gpr_arena *gpr_arena_create(size_t initial_size) { |
||||
initial_size = ROUND_UP_TO_ALIGNMENT_SIZE(initial_size); |
||||
gpr_arena *a = gpr_zalloc(sizeof(gpr_arena) + initial_size); |
||||
a->initial_zone.size_end = initial_size; |
||||
return a; |
||||
} |
||||
|
||||
size_t gpr_arena_destroy(gpr_arena *arena) { |
||||
gpr_atm size = gpr_atm_no_barrier_load(&arena->size_so_far); |
||||
zone *z = (zone *)gpr_atm_no_barrier_load(&arena->initial_zone.next_atm); |
||||
gpr_free(arena); |
||||
while (z) { |
||||
zone *next_z = (zone *)gpr_atm_no_barrier_load(&z->next_atm); |
||||
gpr_free(z); |
||||
z = next_z; |
||||
} |
||||
return (size_t)size; |
||||
} |
||||
|
||||
void *gpr_arena_alloc(gpr_arena *arena, size_t size) { |
||||
size = ROUND_UP_TO_ALIGNMENT_SIZE(size); |
||||
size_t start = |
||||
(size_t)gpr_atm_no_barrier_fetch_add(&arena->size_so_far, size); |
||||
zone *z = &arena->initial_zone; |
||||
while (start > z->size_end) { |
||||
zone *next_z = (zone *)gpr_atm_acq_load(&z->next_atm); |
||||
if (next_z == NULL) { |
||||
size_t next_z_size = (size_t)gpr_atm_no_barrier_load(&arena->size_so_far); |
||||
next_z = gpr_zalloc(sizeof(zone) + next_z_size); |
||||
next_z->size_begin = z->size_end; |
||||
next_z->size_end = z->size_end + next_z_size; |
||||
if (!gpr_atm_rel_cas(&z->next_atm, (gpr_atm)NULL, (gpr_atm)next_z)) { |
||||
gpr_free(next_z); |
||||
next_z = (zone *)gpr_atm_acq_load(&z->next_atm); |
||||
} |
||||
} |
||||
z = next_z; |
||||
} |
||||
if (start + size > z->size_end) { |
||||
return gpr_arena_alloc(arena, size); |
||||
} |
||||
GPR_ASSERT(start >= z->size_begin); |
||||
GPR_ASSERT(start + size <= z->size_end); |
||||
return ((char *)(z + 1)) + start - z->size_begin; |
||||
} |
@ -0,0 +1,54 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017, 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. |
||||
* |
||||
*/ |
||||
|
||||
// \file Arena based allocator
|
||||
// Allows very fast allocation of memory, but that memory cannot be freed until
|
||||
// the arena as a whole is freed
|
||||
// Tracks the total memory allocated against it, so that future arenas can
|
||||
// pre-allocate the right amount of memory
|
||||
|
||||
#ifndef GRPC_CORE_LIB_SUPPORT_ARENA_H |
||||
#define GRPC_CORE_LIB_SUPPORT_ARENA_H |
||||
|
||||
#include <stddef.h> |
||||
|
||||
typedef struct gpr_arena gpr_arena; |
||||
|
||||
// Create an arena, with \a initial_size bytes in the first allocated buffer
|
||||
gpr_arena *gpr_arena_create(size_t initial_size); |
||||
// Allocate \a size bytes from the arena
|
||||
void *gpr_arena_alloc(gpr_arena *arena, size_t size); |
||||
// Destroy an arena, returning the total number of bytes allocated
|
||||
size_t gpr_arena_destroy(gpr_arena *arena); |
||||
|
||||
#endif /* GRPC_CORE_LIB_SUPPORT_ARENA_H */ |
@ -0,0 +1,139 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017, 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. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/lib/support/arena.h" |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/string_util.h> |
||||
#include <grpc/support/sync.h> |
||||
#include <grpc/support/thd.h> |
||||
#include <grpc/support/useful.h> |
||||
#include <inttypes.h> |
||||
#include <string.h> |
||||
|
||||
#include "src/core/lib/support/string.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static void test_noop(void) { gpr_arena_destroy(gpr_arena_create(1)); } |
||||
|
||||
static void test(const char *name, size_t init_size, const size_t *allocs, |
||||
size_t nallocs) { |
||||
gpr_strvec v; |
||||
char *s; |
||||
gpr_strvec_init(&v); |
||||
gpr_asprintf(&s, "test '%s': %" PRIdPTR " <- {", name, init_size); |
||||
gpr_strvec_add(&v, s); |
||||
for (size_t i = 0; i < nallocs; i++) { |
||||
gpr_asprintf(&s, "%" PRIdPTR ",", allocs[i]); |
||||
gpr_strvec_add(&v, s); |
||||
} |
||||
gpr_strvec_add(&v, gpr_strdup("}")); |
||||
s = gpr_strvec_flatten(&v, NULL); |
||||
gpr_strvec_destroy(&v); |
||||
gpr_log(GPR_INFO, "%s", s); |
||||
gpr_free(s); |
||||
|
||||
gpr_arena *a = gpr_arena_create(init_size); |
||||
void **ps = gpr_zalloc(sizeof(*ps) * nallocs); |
||||
for (size_t i = 0; i < nallocs; i++) { |
||||
ps[i] = gpr_arena_alloc(a, allocs[i]); |
||||
// ensure no duplicate results
|
||||
for (size_t j = 0; j < i; j++) { |
||||
GPR_ASSERT(ps[i] != ps[j]); |
||||
} |
||||
// ensure writable
|
||||
memset(ps[i], 1, allocs[i]); |
||||
} |
||||
gpr_arena_destroy(a); |
||||
gpr_free(ps); |
||||
} |
||||
|
||||
#define TEST(name, init_size, ...) \ |
||||
static const size_t allocs_##name[] = {__VA_ARGS__}; \
|
||||
test(#name, init_size, allocs_##name, GPR_ARRAY_SIZE(allocs_##name)) |
||||
|
||||
#define CONCURRENT_TEST_ITERATIONS 100000 |
||||
#define CONCURRENT_TEST_THREADS 100 |
||||
|
||||
typedef struct { |
||||
gpr_event ev_start; |
||||
gpr_arena *arena; |
||||
} concurrent_test_args; |
||||
|
||||
static void concurrent_test_body(void *arg) { |
||||
concurrent_test_args *a = arg; |
||||
gpr_event_wait(&a->ev_start, gpr_inf_future(GPR_CLOCK_REALTIME)); |
||||
for (size_t i = 0; i < CONCURRENT_TEST_ITERATIONS; i++) { |
||||
*(char *)gpr_arena_alloc(a->arena, 1) = (char)i; |
||||
} |
||||
} |
||||
|
||||
static void concurrent_test(void) { |
||||
gpr_log(GPR_DEBUG, "concurrent_test"); |
||||
|
||||
concurrent_test_args args; |
||||
gpr_event_init(&args.ev_start); |
||||
args.arena = gpr_arena_create(1024); |
||||
|
||||
gpr_thd_id thds[CONCURRENT_TEST_THREADS]; |
||||
|
||||
for (int i = 0; i < CONCURRENT_TEST_THREADS; i++) { |
||||
gpr_thd_options opt = gpr_thd_options_default(); |
||||
gpr_thd_options_set_joinable(&opt); |
||||
gpr_thd_new(&thds[i], concurrent_test_body, &args, &opt); |
||||
} |
||||
|
||||
gpr_event_set(&args.ev_start, (void *)1); |
||||
|
||||
for (int i = 0; i < CONCURRENT_TEST_THREADS; i++) { |
||||
gpr_thd_join(thds[i]); |
||||
} |
||||
|
||||
gpr_arena_destroy(args.arena); |
||||
} |
||||
|
||||
int main(int argc, char *argv[]) { |
||||
grpc_test_init(argc, argv); |
||||
|
||||
test_noop(); |
||||
TEST(0_1, 0, 1); |
||||
TEST(1_1, 1, 1); |
||||
TEST(1_2, 1, 2); |
||||
TEST(1_3, 1, 3); |
||||
TEST(1_inc, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); |
||||
TEST(6_123, 6, 1, 2, 3); |
||||
concurrent_test(); |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,76 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017, 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. |
||||
* |
||||
*/ |
||||
|
||||
/* Benchmark arenas */ |
||||
|
||||
extern "C" { |
||||
#include "src/core/lib/support/arena.h" |
||||
} |
||||
#include "test/cpp/microbenchmarks/helpers.h" |
||||
#include "third_party/benchmark/include/benchmark/benchmark.h" |
||||
|
||||
static void BM_Arena_NoOp(benchmark::State& state) { |
||||
while (state.KeepRunning()) { |
||||
gpr_arena_destroy(gpr_arena_create(state.range(0))); |
||||
} |
||||
} |
||||
BENCHMARK(BM_Arena_NoOp)->Range(1, 1024 * 1024); |
||||
|
||||
static void BM_Arena_ManyAlloc(benchmark::State& state) { |
||||
gpr_arena* a = gpr_arena_create(state.range(0)); |
||||
const size_t realloc_after = |
||||
1024 * 1024 * 1024 / ((state.range(1) + 15) & 0xffffff0u); |
||||
while (state.KeepRunning()) { |
||||
gpr_arena_alloc(a, state.range(1)); |
||||
// periodically recreate arena to avoid OOM
|
||||
if (state.iterations() % realloc_after == 0) { |
||||
gpr_arena_destroy(a); |
||||
a = gpr_arena_create(state.range(0)); |
||||
} |
||||
} |
||||
gpr_arena_destroy(a); |
||||
} |
||||
BENCHMARK(BM_Arena_ManyAlloc)->Ranges({{1, 1024 * 1024}, {1, 32 * 1024}}); |
||||
|
||||
static void BM_Arena_Batch(benchmark::State& state) { |
||||
while (state.KeepRunning()) { |
||||
gpr_arena* a = gpr_arena_create(state.range(0)); |
||||
for (int i = 0; i < state.range(1); i++) { |
||||
gpr_arena_alloc(a, state.range(2)); |
||||
} |
||||
gpr_arena_destroy(a); |
||||
} |
||||
} |
||||
BENCHMARK(BM_Arena_Batch)->Ranges({{1, 64 * 1024}, {1, 64}, {1, 1024}}); |
||||
|
||||
BENCHMARK_MAIN(); |
@ -0,0 +1,49 @@ |
||||
# Copyright 2017, 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. |
||||
|
||||
import argparse |
||||
import hyper |
||||
import sys |
||||
|
||||
# Utility to healthcheck the http2 server. Used when starting the server to |
||||
# verify that the server is live before tests begin. |
||||
if __name__ == '__main__': |
||||
parser = argparse.ArgumentParser() |
||||
parser.add_argument('--server_host', type=str, default='localhost') |
||||
parser.add_argument('--server_port', type=int, default=8080) |
||||
args = parser.parse_args() |
||||
server_host = args.server_host |
||||
server_port = args.server_port |
||||
conn = hyper.HTTP20Connection('%s:%d' % (server_host, server_port)) |
||||
conn.request('POST', '/grpc.testing.TestService/UnaryCall') |
||||
resp = conn.get_response() |
||||
if resp.headers.get('grpc-encoding') is None: |
||||
sys.exit(1) |
||||
else: |
||||
sys.exit(0) |
@ -0,0 +1,3 @@ |
||||
[libfuzzer] |
||||
max_len = 2048 |
||||
dict = api_fuzzer.dictionary |
@ -0,0 +1,3 @@ |
||||
[libfuzzer] |
||||
max_len = 2048 |
||||
dict = hpack.dictionary |
@ -0,0 +1,2 @@ |
||||
[libfuzzer] |
||||
max_len = 512 |
@ -0,0 +1,2 @@ |
||||
[libfuzzer] |
||||
max_len = 128 |
@ -0,0 +1,2 @@ |
||||
[libfuzzer] |
||||
max_len = 128 |
@ -0,0 +1,3 @@ |
||||
[libfuzzer] |
||||
max_len = 512 |
||||
dict = hpack.dictionary |
@ -0,0 +1,2 @@ |
||||
[libfuzzer] |
||||
max_len = 32 |
@ -0,0 +1,2 @@ |
||||
[libfuzzer] |
||||
max_len = 32 |
@ -0,0 +1,3 @@ |
||||
[libfuzzer] |
||||
max_len = 2048 |
||||
|
@ -0,0 +1,3 @@ |
||||
[libfuzzer] |
||||
max_len = 2048 |
||||
|
@ -0,0 +1,3 @@ |
||||
[libfuzzer] |
||||
max_len = 2048 |
||||
dict = hpack.dictionary |
@ -0,0 +1,2 @@ |
||||
[libfuzzer] |
||||
max_len = 2048 |
@ -0,0 +1,2 @@ |
||||
[libfuzzer] |
||||
max_len = 128 |
@ -0,0 +1,119 @@ |
||||
#!/usr/bin/env python2.7 |
||||
# Copyright 2017, 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. |
||||
|
||||
"""Upload docker images to Google Container Registry.""" |
||||
|
||||
from __future__ import print_function |
||||
|
||||
import argparse |
||||
import atexit |
||||
import os |
||||
import shutil |
||||
import subprocess |
||||
import tempfile |
||||
|
||||
argp = argparse.ArgumentParser(description='Run interop tests.') |
||||
argp.add_argument('--gcr_path', |
||||
default='gcr.io/grpc-testing', |
||||
help='Path of docker images in Google Container Registry') |
||||
|
||||
argp.add_argument('--gcr_tag', |
||||
default='latest', |
||||
help='the tag string for the images to upload') |
||||
|
||||
argp.add_argument('--with_files', |
||||
default=[], |
||||
nargs='+', |
||||
help='additional files to include in the docker image') |
||||
|
||||
argp.add_argument('--with_file_dest', |
||||
default='/var/local/image_info', |
||||
help='Destination directory for with_files inside docker image') |
||||
|
||||
argp.add_argument('--images', |
||||
default=[], |
||||
nargs='+', |
||||
help='local docker images in the form of repo:tag ' + |
||||
'(i.e. grpc_interop_java:26328ad8) to upload') |
||||
|
||||
argp.add_argument('--keep', |
||||
action='store_true', |
||||
help='keep the created local images after uploading to GCR') |
||||
|
||||
|
||||
args = argp.parse_args() |
||||
|
||||
def upload_to_gcr(image): |
||||
"""Tags and Pushes a docker image in Google Containger Registry. |
||||
|
||||
image: docker image name, i.e. grpc_interop_java:26328ad8 |
||||
|
||||
A docker image image_foo:tag_old will be uploaded as |
||||
<gcr_path>/image_foo:<gcr_tag> |
||||
after inserting extra with_files under with_file_dest in the image. The |
||||
original image name will be stored as label original_name:"image_foo:tag_old". |
||||
""" |
||||
tag_idx = image.find(':') |
||||
if tag_idx == -1: |
||||
print('Failed to parse docker image name %s' % image) |
||||
return False |
||||
new_tag = '%s/%s:%s' % (args.gcr_path, image[:tag_idx], args.gcr_tag) |
||||
|
||||
lines = ['FROM ' + image] |
||||
lines.append('LABEL original_name="%s"' % image) |
||||
|
||||
temp_dir = tempfile.mkdtemp() |
||||
atexit.register(lambda: subprocess.call(['rm', '-rf', temp_dir])) |
||||
|
||||
# Copy with_files inside the tmp directory, which will be the docker build |
||||
# context. |
||||
for f in args.with_files: |
||||
shutil.copy(f, temp_dir) |
||||
lines.append('COPY %s %s/' % (os.path.basename(f), args.with_file_dest)) |
||||
|
||||
# Create a Dockerfile. |
||||
with open(os.path.join(temp_dir, 'Dockerfile'), 'w') as f: |
||||
f.write('\n'.join(lines)) |
||||
|
||||
build_cmd = ['docker', 'build', '--rm', '--tag', new_tag, temp_dir] |
||||
subprocess.check_output(build_cmd) |
||||
|
||||
if not args.keep: |
||||
atexit.register(lambda: subprocess.call(['docker', 'rmi', new_tag])) |
||||
|
||||
# Upload to GCR. |
||||
if args.gcr_path: |
||||
subprocess.call(['gcloud', 'docker', '--', 'push', new_tag]) |
||||
|
||||
return True |
||||
|
||||
|
||||
for image in args.images: |
||||
upload_to_gcr(image) |
@ -0,0 +1,7 @@ |
||||
# boringssl stuff |
||||
nonnull-attribute:bn_wexpand |
||||
nonnull-attribute:CBB_add_bytes |
||||
nonnull-attribute:rsa_blinding_get |
||||
nonnull-attribute:ssl_copy_key_material |
||||
alignment:CRYPTO_cbc128_encrypt |
||||
|
@ -0,0 +1,193 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\1.0.204.1.props')" /> |
||||
<ItemGroup Label="ProjectConfigurations"> |
||||
<ProjectConfiguration Include="Debug|Win32"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Debug|x64"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>x64</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|Win32"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|x64"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>x64</Platform> |
||||
</ProjectConfiguration> |
||||
</ItemGroup> |
||||
<PropertyGroup Label="Globals"> |
||||
<ProjectGuid>{D85AC722-A88F-4280-F62E-672F571787FF}</ProjectGuid> |
||||
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected> |
||||
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration"> |
||||
<PlatformToolset>v100</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration"> |
||||
<PlatformToolset>v110</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration"> |
||||
<PlatformToolset>v120</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '14.0'" Label="Configuration"> |
||||
<PlatformToolset>v140</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> |
||||
<ConfigurationType>Application</ConfigurationType> |
||||
<UseDebugLibraries>true</UseDebugLibraries> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> |
||||
<ConfigurationType>Application</ConfigurationType> |
||||
<UseDebugLibraries>false</UseDebugLibraries> |
||||
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||
<ImportGroup Label="ExtensionSettings"> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\global.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\openssl.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\winsock.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\zlib.props" /> |
||||
</ImportGroup> |
||||
<PropertyGroup Label="UserMacros" /> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> |
||||
<TargetName>arena_test</TargetName> |
||||
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||
<Configuration-grpc_dependencies_zlib>Debug</Configuration-grpc_dependencies_zlib> |
||||
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||
<Configuration-grpc_dependencies_openssl>Debug</Configuration-grpc_dependencies_openssl> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'"> |
||||
<TargetName>arena_test</TargetName> |
||||
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||
<Configuration-grpc_dependencies_zlib>Release</Configuration-grpc_dependencies_zlib> |
||||
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||
<Configuration-grpc_dependencies_openssl>Release</Configuration-grpc_dependencies_openssl> |
||||
</PropertyGroup> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>Disabled</Optimization> |
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>Disabled</Optimization> |
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>MaxSpeed</Optimization> |
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>MaxSpeed</Optimization> |
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemGroup> |
||||
<ClCompile Include="$(SolutionDir)\..\test\core\support\arena_test.c"> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr_test_util\gpr_test_util.vcxproj"> |
||||
<Project>{EAB0A629-17A9-44DB-B5FF-E91A721FE037}</Project> |
||||
</ProjectReference> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr\gpr.vcxproj"> |
||||
<Project>{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}</Project> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="packages.config" /> |
||||
</ItemGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||
<ImportGroup Label="ExtensionTargets"> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||
</ImportGroup> |
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
||||
<PropertyGroup> |
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
||||
</PropertyGroup> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" /> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" /> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" /> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" /> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" /> |
||||
</Target> |
||||
</Project> |
||||
|
@ -0,0 +1,21 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
||||
<ClCompile Include="$(SolutionDir)\..\test\core\support\arena_test.c"> |
||||
<Filter>test\core\support</Filter> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
|
||||
<ItemGroup> |
||||
<Filter Include="test"> |
||||
<UniqueIdentifier>{130788b2-eacc-90df-a4f6-f5102a7d3370}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="test\core"> |
||||
<UniqueIdentifier>{5c3e1753-6fdb-9476-f98c-a3a394fac54a}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="test\core\support"> |
||||
<UniqueIdentifier>{1d3d2cc8-4e69-8b2e-6ceb-6569fcb19a86}</UniqueIdentifier> |
||||
</Filter> |
||||
</ItemGroup> |
||||
</Project> |
||||
|
Loading…
Reference in new issue