From 97fb3f6481cc79ed9409320fcb274b9ea7442aaf Mon Sep 17 00:00:00 2001 From: jtattermusch Date: Mon, 8 Dec 2014 15:13:41 -0800 Subject: [PATCH] Add mako templates to generate MS Visual Studio projects. Current state for Windows platform: -- gpr and grpc_test_util can be compiled -- gpr_log_test and gpr_cmdline_test pass Change on 2014/12/08 by jtattermusch ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81615574 --- Makefile | 14 +- build.json | 12 +- include/grpc/support/port_platform.h | 3 + .../vsprojects/vs2013/gpr.vcxproj.template | 2 + .../gpr_cancellable_test.vcxproj.template | 2 + .../vs2013/gpr_cmdline_test.vcxproj.template | 2 + .../vs2013/gpr_log_test.vcxproj.template | 2 + templates/vsprojects/vs2013/grpc.sln.template | 58 ++++ .../vsprojects/vs2013/grpc.vcxproj.template | 2 + .../vs2013/grpc_test_util.vcxproj.template | 2 + .../vsprojects/vs2013/vcxproj_defs.include | 138 ++++++++ test/core/end2end/cq_verifier.c | 7 + test/core/end2end/end2end_tests.c | 8 +- test/core/endpoint/endpoint_tests.c | 35 +- test/core/endpoint/endpoint_tests.h | 2 +- test/core/endpoint/secure_endpoint_test.c | 11 +- test/core/endpoint/tcp_test.c | 2 +- test/core/transport/transport_end2end_tests.c | 7 +- test/core/util/{port.c => port_posix.c} | 5 + vsprojects/README | 1 + vsprojects/vs2013/gpr.vcxproj | 161 +++++++++ .../vs2013/gpr_cancellable_test.vcxproj | 91 +++++ vsprojects/vs2013/gpr_cmdline_test.vcxproj | 91 +++++ vsprojects/vs2013/gpr_log_test.vcxproj | 91 +++++ vsprojects/vs2013/grpc.sln | 64 ++++ vsprojects/vs2013/grpc.vcxproj | 322 ++++++++++++++++++ vsprojects/vs2013/grpc_test_util.vcxproj | 100 ++++++ 27 files changed, 1193 insertions(+), 42 deletions(-) create mode 100644 templates/vsprojects/vs2013/gpr.vcxproj.template create mode 100644 templates/vsprojects/vs2013/gpr_cancellable_test.vcxproj.template create mode 100644 templates/vsprojects/vs2013/gpr_cmdline_test.vcxproj.template create mode 100644 templates/vsprojects/vs2013/gpr_log_test.vcxproj.template create mode 100644 templates/vsprojects/vs2013/grpc.sln.template create mode 100644 templates/vsprojects/vs2013/grpc.vcxproj.template create mode 100644 templates/vsprojects/vs2013/grpc_test_util.vcxproj.template create mode 100644 templates/vsprojects/vs2013/vcxproj_defs.include rename test/core/util/{port.c => port_posix.c} (98%) create mode 100644 vsprojects/README create mode 100644 vsprojects/vs2013/gpr.vcxproj create mode 100644 vsprojects/vs2013/gpr_cancellable_test.vcxproj create mode 100644 vsprojects/vs2013/gpr_cmdline_test.vcxproj create mode 100644 vsprojects/vs2013/gpr_log_test.vcxproj create mode 100644 vsprojects/vs2013/grpc.sln create mode 100644 vsprojects/vs2013/grpc.vcxproj create mode 100644 vsprojects/vs2013/grpc_test_util.vcxproj diff --git a/Makefile b/Makefile index 84ddb5449bd..28993e04d12 100644 --- a/Makefile +++ b/Makefile @@ -712,7 +712,7 @@ clean_libgrpc: LIBGRPC_TEST_UTIL_SRC = \ test/core/util/grpc_profiler.c \ test/core/util/parse_hexstring.c \ - test/core/util/port.c \ + test/core/util/port_posix.c \ test/core/util/slice_splitter.c \ test/core/util/test_config.c \ test/core/end2end/end2end_tests.c \ @@ -1645,9 +1645,9 @@ GPR_CANCELLABLE_TEST_SRC = \ GPR_CANCELLABLE_TEST_OBJS = $(addprefix objs/, $(addsuffix .o, $(basename $(GPR_CANCELLABLE_TEST_SRC)))) GPR_CANCELLABLE_TEST_DEPS = $(addprefix deps/, $(addsuffix .dep, $(basename $(GPR_CANCELLABLE_TEST_SRC)))) -bins/gpr_cancellable_test: $(GPR_CANCELLABLE_TEST_OBJS) libs/libgrpc_test_util.a libs/libgrpc.a libs/libgpr.a +bins/gpr_cancellable_test: $(GPR_CANCELLABLE_TEST_OBJS) libs/libgrpc_test_util.a libs/libgpr.a $(E) "[LD] Linking $@" - $(Q) $(LD) $(LDFLAGS) $(GPR_CANCELLABLE_TEST_OBJS) -Llibs -lgrpc_test_util -lgrpc -lgpr $(LDLIBS) $(LDLIBS_SECURE) -o bins/gpr_cancellable_test + $(Q) $(LD) $(LDFLAGS) $(GPR_CANCELLABLE_TEST_OBJS) -Llibs -lgrpc_test_util -lgpr $(LDLIBS) $(LDLIBS_SECURE) -o bins/gpr_cancellable_test deps_gpr_cancellable_test: $(GPR_CANCELLABLE_TEST_DEPS) @@ -1668,9 +1668,9 @@ GPR_LOG_TEST_SRC = \ GPR_LOG_TEST_OBJS = $(addprefix objs/, $(addsuffix .o, $(basename $(GPR_LOG_TEST_SRC)))) GPR_LOG_TEST_DEPS = $(addprefix deps/, $(addsuffix .dep, $(basename $(GPR_LOG_TEST_SRC)))) -bins/gpr_log_test: $(GPR_LOG_TEST_OBJS) libs/libgrpc_test_util.a libs/libgrpc.a libs/libgpr.a +bins/gpr_log_test: $(GPR_LOG_TEST_OBJS) libs/libgrpc_test_util.a libs/libgpr.a $(E) "[LD] Linking $@" - $(Q) $(LD) $(LDFLAGS) $(GPR_LOG_TEST_OBJS) -Llibs -lgrpc_test_util -lgrpc -lgpr $(LDLIBS) $(LDLIBS_SECURE) -o bins/gpr_log_test + $(Q) $(LD) $(LDFLAGS) $(GPR_LOG_TEST_OBJS) -Llibs -lgrpc_test_util -lgpr $(LDLIBS) $(LDLIBS_SECURE) -o bins/gpr_log_test deps_gpr_log_test: $(GPR_LOG_TEST_DEPS) @@ -1691,9 +1691,9 @@ GPR_CMDLINE_TEST_SRC = \ GPR_CMDLINE_TEST_OBJS = $(addprefix objs/, $(addsuffix .o, $(basename $(GPR_CMDLINE_TEST_SRC)))) GPR_CMDLINE_TEST_DEPS = $(addprefix deps/, $(addsuffix .dep, $(basename $(GPR_CMDLINE_TEST_SRC)))) -bins/gpr_cmdline_test: $(GPR_CMDLINE_TEST_OBJS) libs/libgrpc_test_util.a libs/libgrpc.a libs/libgpr.a +bins/gpr_cmdline_test: $(GPR_CMDLINE_TEST_OBJS) libs/libgrpc_test_util.a libs/libgpr.a $(E) "[LD] Linking $@" - $(Q) $(LD) $(LDFLAGS) $(GPR_CMDLINE_TEST_OBJS) -Llibs -lgrpc_test_util -lgrpc -lgpr $(LDLIBS) $(LDLIBS_SECURE) -o bins/gpr_cmdline_test + $(Q) $(LD) $(LDFLAGS) $(GPR_CMDLINE_TEST_OBJS) -Llibs -lgrpc_test_util -lgpr $(LDLIBS) $(LDLIBS_SECURE) -o bins/gpr_cmdline_test deps_gpr_cmdline_test: $(GPR_CMDLINE_TEST_DEPS) diff --git a/build.json b/build.json index 7f896526faa..3769fe991a7 100644 --- a/build.json +++ b/build.json @@ -13,6 +13,7 @@ "name": "gpr", "build": "all", "secure": false, + "vs_project_guid": "{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}", "src": [ "src/core/support/alloc.c", "src/core/support/cancellable.c", @@ -76,6 +77,7 @@ "name": "grpc", "build": "all", "secure": true, + "vs_project_guid": "{29D16885-7228-4C31-81ED-5F9187C7F2A9}", "alternates": [ { "name": "grpc_unsecure", @@ -258,10 +260,11 @@ { "name": "grpc_test_util", "build": "private", + "vs_project_guid": "{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}", "src": [ "test/core/util/grpc_profiler.c", "test/core/util/parse_hexstring.c", - "test/core/util/port.c", + "test/core/util/port_posix.c", "test/core/util/slice_splitter.c", "test/core/util/test_config.c", "test/core/end2end/end2end_tests.c", @@ -276,6 +279,7 @@ "build": "all", "c++": true, "secure": true, + "vs_project_guid": "{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}", "src": [ "src/cpp/server/server.cc", "src/cpp/server/server_rpc_handler.cc", @@ -361,36 +365,36 @@ { "name": "gpr_cancellable_test", "build": "test", + "vs_project_guid": "{19730BF6-7F8C-44EF-ACDC-2CA50C0403E7}", "src": [ "test/core/support/cancellable_test.c" ], "deps": [ "grpc_test_util", - "grpc", "gpr" ] }, { "name": "gpr_log_test", "build": "test", + "vs_project_guid": "{42B70122-188F-4535-AB74-F061C77068B4}", "src": [ "test/core/support/log_test.c" ], "deps": [ "grpc_test_util", - "grpc", "gpr" ] }, { "name": "gpr_cmdline_test", "build": "test", + "vs_project_guid": "{8F260F48-3C22-48A8-9928-A152ABB2EDF2}", "src": [ "test/core/support/cmdline_test.c" ], "deps": [ "grpc_test_util", - "grpc", "gpr" ] }, diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 404543d67b3..13ce4744dab 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -54,6 +54,7 @@ #define GPR_POSIX_TIME 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_STRING 1 +#define GPR_POSIX_SOCKET 1 #define GPR_POSIX_SOCKETUTILS 1 #define GPR_ANDROID 1 #define GPR_GCC_SYNC 1 @@ -62,6 +63,7 @@ #define GPR_POSIX_TIME 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_STRING 1 +#define GPR_POSIX_SOCKET 1 #define GPR_LINUX 1 #define GPR_GCC_ATOMIC 1 #ifdef _LP64 @@ -74,6 +76,7 @@ #define GPR_POSIX_SYNC 1 #define GPR_POSIX_STRING 1 #define GPR_POSIX_LOG 1 +#define GPR_POSIX_SOCKET 1 #define GPR_POSIX_SOCKETUTILS 1 #define GPR_GCC_ATOMIC 1 #ifdef _LP64 diff --git a/templates/vsprojects/vs2013/gpr.vcxproj.template b/templates/vsprojects/vs2013/gpr.vcxproj.template new file mode 100644 index 00000000000..c478aadcddf --- /dev/null +++ b/templates/vsprojects/vs2013/gpr.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj_defs.include" import="gen_project"/>\ +${gen_project('gpr', libs, targets)} diff --git a/templates/vsprojects/vs2013/gpr_cancellable_test.vcxproj.template b/templates/vsprojects/vs2013/gpr_cancellable_test.vcxproj.template new file mode 100644 index 00000000000..e20be83a787 --- /dev/null +++ b/templates/vsprojects/vs2013/gpr_cancellable_test.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj_defs.include" import="gen_project"/>\ +${gen_project('gpr_cancellable_test', libs, targets)} diff --git a/templates/vsprojects/vs2013/gpr_cmdline_test.vcxproj.template b/templates/vsprojects/vs2013/gpr_cmdline_test.vcxproj.template new file mode 100644 index 00000000000..3be9fb3a9c2 --- /dev/null +++ b/templates/vsprojects/vs2013/gpr_cmdline_test.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj_defs.include" import="gen_project"/>\ +${gen_project('gpr_cmdline_test', libs, targets)} diff --git a/templates/vsprojects/vs2013/gpr_log_test.vcxproj.template b/templates/vsprojects/vs2013/gpr_log_test.vcxproj.template new file mode 100644 index 00000000000..07cfb5d3386 --- /dev/null +++ b/templates/vsprojects/vs2013/gpr_log_test.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj_defs.include" import="gen_project"/>\ +${gen_project('gpr_log_test', libs, targets)} diff --git a/templates/vsprojects/vs2013/grpc.sln.template b/templates/vsprojects/vs2013/grpc.sln.template new file mode 100644 index 00000000000..2eba4cbe03f --- /dev/null +++ b/templates/vsprojects/vs2013/grpc.sln.template @@ -0,0 +1,58 @@ +## Template for Visual Studio solution +## based on http://msdn.microsoft.com/en-us/library/bb165951(v=vs.90).aspx + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +<% +## Visual Studio uses GUIDs for project types +## http://msdn.microsoft.com/en-us/library/hb23x61k%28v=vs.80%29.aspx +cpp_proj_type = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" + +for lib in libs: + lib.is_library = True +for target in targets: + target.is_library = False + +projects = [] +projects.extend(libs) +projects.extend(targets) +projects = [project for project in projects if project.get('vs_project_guid', None)] + +## Exclude C++ projects for now +projects = [project for project in projects if not project.get('c++', False)] + +for p in projects: + p.deps = p.get('deps',[]) + +project_dict = dict([(p.name, p) for p in projects]) +%>\ +% for project in projects: +Project("${cpp_proj_type}") = "${project.name}", "${project.name}.vcxproj", "${project.vs_project_guid}" + % if project.deps: + ProjectSection(ProjectDependencies) = postProject + % for dep in project.deps: + ${project_dict[dep].vs_project_guid} = ${project_dict[dep].vs_project_guid} + % endfor + EndProjectSection + % endif +EndProject +% endfor +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +% for project in projects: + ${project.vs_project_guid}.Debug|Win32.ActiveCfg = Debug|Win32 + ${project.vs_project_guid}.Debug|Win32.Build.0 = Debug|Win32 + ${project.vs_project_guid}.Release|Win32.ActiveCfg = Release|Win32 + ${project.vs_project_guid}.Release|Win32.Build.0 = Release|Win32 +% endfor + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/templates/vsprojects/vs2013/grpc.vcxproj.template b/templates/vsprojects/vs2013/grpc.vcxproj.template new file mode 100644 index 00000000000..3de6453f520 --- /dev/null +++ b/templates/vsprojects/vs2013/grpc.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj_defs.include" import="gen_project"/>\ +${gen_project('grpc', libs, targets)} \ No newline at end of file diff --git a/templates/vsprojects/vs2013/grpc_test_util.vcxproj.template b/templates/vsprojects/vs2013/grpc_test_util.vcxproj.template new file mode 100644 index 00000000000..72e625d9b97 --- /dev/null +++ b/templates/vsprojects/vs2013/grpc_test_util.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj_defs.include" import="gen_project"/>\ +${gen_project('grpc_test_util', libs, targets)} \ No newline at end of file diff --git a/templates/vsprojects/vs2013/vcxproj_defs.include b/templates/vsprojects/vs2013/vcxproj_defs.include new file mode 100644 index 00000000000..37fe97d4eaa --- /dev/null +++ b/templates/vsprojects/vs2013/vcxproj_defs.include @@ -0,0 +1,138 @@ +<%def name="to_windows_path(path)">${path.replace('/','\\')}\ +<%def name="get_configuration_type(is_library)">${'StaticLibrary' if is_library else 'Application'}\ +<%def name="get_subsystem(is_library)">${'Windows' if is_library else 'Console'}\ +<%def name="gen_project(name, libs, targets)">\ +<% +## TODO(jtattermusch): this code is c&p from the solution template +for lib in libs: + lib.is_library = True +for target in targets: + target.is_library = False + +projects = [] +projects.extend(libs) +projects.extend(targets) +projects = [project for project in projects if project.get('vs_project_guid', None)] + +## Exclude C++ projects for now +projects = [project for project in projects if not project.get('c++', False)] + +for p in projects: + p.deps = p.get('deps',[]) + +project_dict = dict([(p.name, p) for p in projects]) +%>\ +% for project in projects: + % if project.name == name: + + + + + Debug + Win32 + + + Release + Win32 + + + + ${project.vs_project_guid} + Win32Proj + + + + + ${get_configuration_type(project.is_library)} + true + v120 + Unicode + + + ${get_configuration_type(project.is_library)} + false + v120 + true + Unicode + + + + + + + + + + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + ${get_subsystem(project.is_library)} + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + ${get_subsystem(project.is_library)} + true + true + true + + + % if project.get('public_headers',[]): + + % for public_header in project.public_headers: + + % endfor + + % endif + % if project.get('headers',[]): + + % for header in project.headers: + + % endfor + + % endif + % if project.get('src',[]): + + % for src_name in project.src: + + + % endfor + + % endif + % if project.get('deps',[]): + + % for dep in project.deps: + + ${project_dict[dep].vs_project_guid} + + % endfor + + % endif + + + + + % endif +% endfor +\ \ No newline at end of file diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index aebb8b4c412..d0427da47e1 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -31,6 +31,13 @@ * */ +/* Disable sprintf warnings on Windows (it's fine to do that for test code). + Also, cases where sprintf is called are crash sites anyway. + TODO(jtattermusch): b/18636890 */ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "test/core/end2end/cq_verifier.h" #include diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index 7174d098664..45d55e94bcc 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -35,12 +35,12 @@ #include #include -#include #include #include #include #include +#include #include #include "test/core/end2end/cq_verifier.h" @@ -206,15 +206,15 @@ static void simple_request_body2(grpc_end2end_test_fixture f) { static void test_invoke_simple_request( grpc_end2end_test_config config, const char *name, void (*body)(grpc_end2end_test_fixture f)) { - char fullname[64]; + char *fullname; grpc_end2end_test_fixture f; - sprintf(fullname, "%s/%s", __FUNCTION__, name); - + gpr_asprintf(&fullname, "%s/%s", __FUNCTION__, name); f = begin_test(config, fullname, NULL, NULL); body(f); end_test(&f); config.tear_down_data(&f); + gpr_free(fullname); } static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { diff --git a/test/core/endpoint/endpoint_tests.c b/test/core/endpoint/endpoint_tests.c index 9cc0eaa9594..50919fc45ef 100644 --- a/test/core/endpoint/endpoint_tests.c +++ b/test/core/endpoint/endpoint_tests.c @@ -56,9 +56,9 @@ */ -ssize_t count_and_unref_slices(gpr_slice *slices, size_t nslices, - int *current_data) { - ssize_t num_bytes = 0; +size_t count_and_unref_slices(gpr_slice *slices, size_t nslices, + int *current_data) { + size_t num_bytes = 0; int i; int j; unsigned char *buf; @@ -76,18 +76,18 @@ ssize_t count_and_unref_slices(gpr_slice *slices, size_t nslices, static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config, const char *test_name, - ssize_t slice_size) { + size_t slice_size) { gpr_log(GPR_INFO, "%s/%s", test_name, config.name); return config.create_fixture(slice_size); } static void end_test(grpc_endpoint_test_config config) { config.clean_up(); } -static gpr_slice *allocate_blocks(ssize_t num_bytes, ssize_t slice_size, +static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size, size_t *num_blocks, int *current_data) { - ssize_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0); + size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0); gpr_slice *slices = malloc(sizeof(gpr_slice) * nslices); - ssize_t num_bytes_left = num_bytes; + size_t num_bytes_left = num_bytes; int i; int j; unsigned char *buf; @@ -112,10 +112,10 @@ struct read_and_write_test_state { grpc_endpoint *write_ep; gpr_mu mu; gpr_cv cv; - ssize_t target_bytes; - ssize_t bytes_read; - ssize_t current_write_size; - ssize_t bytes_written; + size_t target_bytes; + size_t bytes_read; + size_t current_write_size; + size_t bytes_written; int current_read_data; int current_write_data; int read_done; @@ -205,8 +205,8 @@ static void read_and_write_test_write_handler(void *data, This also includes a test of the shutdown behavior. */ static void read_and_write_test(grpc_endpoint_test_config config, - ssize_t num_bytes, ssize_t write_size, - ssize_t slice_size, int shutdown) { + size_t num_bytes, size_t write_size, + size_t slice_size, int shutdown) { struct read_and_write_test_state state; gpr_timespec rel_deadline = {20, 0}; gpr_timespec deadline = gpr_time_add(gpr_now(), rel_deadline); @@ -234,6 +234,9 @@ static void read_and_write_test(grpc_endpoint_test_config config, state.current_write_data = 0; /* Get started by pretending an initial write completed */ + /* NOTE: Sets up initial conditions so we can have the same write handler + for the first iteration as for later iterations. It does the right thing + even when bytes_written is unsigned. */ state.bytes_written -= state.current_write_size; read_and_write_test_write_handler(&state, GRPC_ENDPOINT_CB_OK); @@ -271,7 +274,7 @@ static void read_timeout_test_read_handler(void *data, gpr_slice *slices, } static void read_timeout_test(grpc_endpoint_test_config config, - ssize_t slice_size) { + size_t slice_size) { gpr_timespec timeout = gpr_time_from_micros(10000); gpr_timespec read_deadline = gpr_time_add(gpr_now(), timeout); gpr_timespec test_deadline = @@ -297,7 +300,7 @@ static void write_timeout_test_write_handler(void *data, } static void write_timeout_test(grpc_endpoint_test_config config, - ssize_t slice_size) { + size_t slice_size) { gpr_timespec timeout = gpr_time_from_micros(10000); gpr_timespec write_deadline = gpr_time_add(gpr_now(), timeout); gpr_timespec test_deadline = @@ -370,7 +373,7 @@ static void shutdown_during_write_test_write_handler( } static void shutdown_during_write_test(grpc_endpoint_test_config config, - ssize_t slice_size) { + size_t slice_size) { /* test that shutdown with a pending write creates no leaks */ gpr_timespec deadline; size_t size; diff --git a/test/core/endpoint/endpoint_tests.h b/test/core/endpoint/endpoint_tests.h index 79ee759b453..d5f34374da4 100644 --- a/test/core/endpoint/endpoint_tests.h +++ b/test/core/endpoint/endpoint_tests.h @@ -48,7 +48,7 @@ struct grpc_endpoint_test_fixture { struct grpc_endpoint_test_config { const char *name; - grpc_endpoint_test_fixture (*create_fixture)(ssize_t slice_size); + grpc_endpoint_test_fixture (*create_fixture)(size_t slice_size); void (*clean_up)(); }; diff --git a/test/core/endpoint/secure_endpoint_test.c b/test/core/endpoint/secure_endpoint_test.c index 9fc2511763d..4fd5dee6779 100644 --- a/test/core/endpoint/secure_endpoint_test.c +++ b/test/core/endpoint/secure_endpoint_test.c @@ -58,7 +58,7 @@ static void create_sockets(int sv[2]) { } static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( - ssize_t slice_size, gpr_slice *leftover_slices, size_t leftover_nslices) { + size_t slice_size, gpr_slice *leftover_slices, size_t leftover_nslices) { int sv[2]; tsi_frame_protector *fake_read_protector = tsi_create_fake_protector(NULL); tsi_frame_protector *fake_write_protector = tsi_create_fake_protector(NULL); @@ -127,12 +127,12 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( } static grpc_endpoint_test_fixture -secure_endpoint_create_fixture_tcp_socketpair_noleftover(ssize_t slice_size) { +secure_endpoint_create_fixture_tcp_socketpair_noleftover(size_t slice_size) { return secure_endpoint_create_fixture_tcp_socketpair(slice_size, NULL, 0); } static grpc_endpoint_test_fixture -secure_endpoint_create_fixture_tcp_socketpair_leftover(ssize_t slice_size) { +secure_endpoint_create_fixture_tcp_socketpair_leftover(size_t slice_size) { gpr_slice s = gpr_slice_from_copied_string("hello world 12345678900987654321"); grpc_endpoint_test_fixture f; @@ -164,8 +164,7 @@ static void verify_leftover(void *user_data, gpr_slice *slices, size_t nslices, *(int *)user_data = 1; } -static void test_leftover(grpc_endpoint_test_config config, - ssize_t slice_size) { +static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) { grpc_endpoint_test_fixture f = config.create_fixture(slice_size); int verified = 0; gpr_log(GPR_INFO, "Start test left over"); @@ -200,7 +199,7 @@ static void destroy_early(void *user_data, gpr_slice *slices, size_t nslices, /* test which destroys the ep before finishing reading */ static void test_destroy_ep_early(grpc_endpoint_test_config config, - ssize_t slice_size) { + size_t slice_size) { grpc_endpoint_test_fixture f = config.create_fixture(slice_size); gpr_log(GPR_INFO, "Start test destroy early"); diff --git a/test/core/endpoint/tcp_test.c b/test/core/endpoint/tcp_test.c index 7dbc2783e95..c703f92f68b 100644 --- a/test/core/endpoint/tcp_test.c +++ b/test/core/endpoint/tcp_test.c @@ -490,7 +490,7 @@ void run_tests() { static void clean_up() { grpc_em_destroy(&g_em); } static grpc_endpoint_test_fixture create_fixture_tcp_socketpair( - ssize_t slice_size) { + size_t slice_size) { int sv[2]; grpc_endpoint_test_fixture f; diff --git a/test/core/transport/transport_end2end_tests.c b/test/core/transport/transport_end2end_tests.c index 49ce645a64a..e35df3acb4c 100644 --- a/test/core/transport/transport_end2end_tests.c +++ b/test/core/transport/transport_end2end_tests.c @@ -652,12 +652,13 @@ static int count_expectations(test_fixture *f) { /* Callback for enumerate_expectations that adds an expectation to the log */ static void dump_expectation(void *p, const char *fmt, ...) { - char buffer[256]; + char *str; va_list args; va_start(args, fmt); - vsprintf(buffer, fmt, args); - gpr_log(GPR_INFO, "EXPECTED: %s", buffer); + gpr_asprintf(&str, fmt, args); + gpr_log(GPR_INFO, "EXPECTED: %s", str); + gpr_free(str); va_end(args); } diff --git a/test/core/util/port.c b/test/core/util/port_posix.c similarity index 98% rename from test/core/util/port.c rename to test/core/util/port_posix.c index 133b53fd2b8..ab0dcf7d11b 100644 --- a/test/core/util/port.c +++ b/test/core/util/port_posix.c @@ -31,6 +31,9 @@ * */ +#include +#ifdef GPR_POSIX_SOCKET + #include "test/core/util/port.h" #include @@ -143,3 +146,5 @@ int grpc_pick_unused_port_or_die() { GPR_ASSERT(port > 0); return port; } + +#endif /* GPR_POSIX_SOCKET */ diff --git a/vsprojects/README b/vsprojects/README new file mode 100644 index 00000000000..369f2a4f3ad --- /dev/null +++ b/vsprojects/README @@ -0,0 +1 @@ +This directory contains MS Visual Studio project & solution files. diff --git a/vsprojects/vs2013/gpr.vcxproj b/vsprojects/vs2013/gpr.vcxproj new file mode 100644 index 00000000000..f4b30534a64 --- /dev/null +++ b/vsprojects/vs2013/gpr.vcxproj @@ -0,0 +1,161 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + Win32Proj + + + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Windows + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vsprojects/vs2013/gpr_cancellable_test.vcxproj b/vsprojects/vs2013/gpr_cancellable_test.vcxproj new file mode 100644 index 00000000000..447d3b78022 --- /dev/null +++ b/vsprojects/vs2013/gpr_cancellable_test.vcxproj @@ -0,0 +1,91 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {19730BF6-7F8C-44EF-ACDC-2CA50C0403E7} + Win32Proj + + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + + + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + + + + + + + diff --git a/vsprojects/vs2013/gpr_cmdline_test.vcxproj b/vsprojects/vs2013/gpr_cmdline_test.vcxproj new file mode 100644 index 00000000000..0ff731c2935 --- /dev/null +++ b/vsprojects/vs2013/gpr_cmdline_test.vcxproj @@ -0,0 +1,91 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {8F260F48-3C22-48A8-9928-A152ABB2EDF2} + Win32Proj + + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + + + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + + + + + + + diff --git a/vsprojects/vs2013/gpr_log_test.vcxproj b/vsprojects/vs2013/gpr_log_test.vcxproj new file mode 100644 index 00000000000..9354773be44 --- /dev/null +++ b/vsprojects/vs2013/gpr_log_test.vcxproj @@ -0,0 +1,91 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {42B70122-188F-4535-AB74-F061C77068B4} + Win32Proj + + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + + + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + + + + + + + diff --git a/vsprojects/vs2013/grpc.sln b/vsprojects/vs2013/grpc.sln new file mode 100644 index 00000000000..2b39c07c6cf --- /dev/null +++ b/vsprojects/vs2013/grpc.sln @@ -0,0 +1,64 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr", "gpr.vcxproj", "{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc", "grpc.vcxproj", "{29D16885-7228-4C31-81ED-5F9187C7F2A9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_test_util", "grpc_test_util.vcxproj", "{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_cancellable_test", "gpr_cancellable_test.vcxproj", "{19730BF6-7F8C-44EF-ACDC-2CA50C0403E7}" + ProjectSection(ProjectDependencies) = postProject + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_log_test", "gpr_log_test.vcxproj", "{42B70122-188F-4535-AB74-F061C77068B4}" + ProjectSection(ProjectDependencies) = postProject + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_cmdline_test", "gpr_cmdline_test.vcxproj", "{8F260F48-3C22-48A8-9928-A152ABB2EDF2}" + ProjectSection(ProjectDependencies) = postProject + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Debug|Win32.ActiveCfg = Debug|Win32 + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Debug|Win32.Build.0 = Debug|Win32 + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Release|Win32.ActiveCfg = Release|Win32 + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}.Release|Win32.Build.0 = Release|Win32 + {29D16885-7228-4C31-81ED-5F9187C7F2A9}.Debug|Win32.ActiveCfg = Debug|Win32 + {29D16885-7228-4C31-81ED-5F9187C7F2A9}.Debug|Win32.Build.0 = Debug|Win32 + {29D16885-7228-4C31-81ED-5F9187C7F2A9}.Release|Win32.ActiveCfg = Release|Win32 + {29D16885-7228-4C31-81ED-5F9187C7F2A9}.Release|Win32.Build.0 = Release|Win32 + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}.Debug|Win32.ActiveCfg = Debug|Win32 + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}.Debug|Win32.Build.0 = Debug|Win32 + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}.Release|Win32.ActiveCfg = Release|Win32 + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}.Release|Win32.Build.0 = Release|Win32 + {19730BF6-7F8C-44EF-ACDC-2CA50C0403E7}.Debug|Win32.ActiveCfg = Debug|Win32 + {19730BF6-7F8C-44EF-ACDC-2CA50C0403E7}.Debug|Win32.Build.0 = Debug|Win32 + {19730BF6-7F8C-44EF-ACDC-2CA50C0403E7}.Release|Win32.ActiveCfg = Release|Win32 + {19730BF6-7F8C-44EF-ACDC-2CA50C0403E7}.Release|Win32.Build.0 = Release|Win32 + {42B70122-188F-4535-AB74-F061C77068B4}.Debug|Win32.ActiveCfg = Debug|Win32 + {42B70122-188F-4535-AB74-F061C77068B4}.Debug|Win32.Build.0 = Debug|Win32 + {42B70122-188F-4535-AB74-F061C77068B4}.Release|Win32.ActiveCfg = Release|Win32 + {42B70122-188F-4535-AB74-F061C77068B4}.Release|Win32.Build.0 = Release|Win32 + {8F260F48-3C22-48A8-9928-A152ABB2EDF2}.Debug|Win32.ActiveCfg = Debug|Win32 + {8F260F48-3C22-48A8-9928-A152ABB2EDF2}.Debug|Win32.Build.0 = Debug|Win32 + {8F260F48-3C22-48A8-9928-A152ABB2EDF2}.Release|Win32.ActiveCfg = Release|Win32 + {8F260F48-3C22-48A8-9928-A152ABB2EDF2}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/vsprojects/vs2013/grpc.vcxproj b/vsprojects/vs2013/grpc.vcxproj new file mode 100644 index 00000000000..85c36be9ca2 --- /dev/null +++ b/vsprojects/vs2013/grpc.vcxproj @@ -0,0 +1,322 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {29D16885-7228-4C31-81ED-5F9187C7F2A9} + Win32Proj + + + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Windows + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vsprojects/vs2013/grpc_test_util.vcxproj b/vsprojects/vs2013/grpc_test_util.vcxproj new file mode 100644 index 00000000000..8fee039bb7c --- /dev/null +++ b/vsprojects/vs2013/grpc_test_util.vcxproj @@ -0,0 +1,100 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + Win32Proj + + + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Windows + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + +