diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 9c999b9c811e97b3908a02b305ef563f6482477a..9100f6e513cf86159acea4a483e811cc7517443e 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -45,9 +45,11 @@ #if defined(_WIN64) || defined(WIN64) #define GPR_WIN32 1 #define GPR_ARCH_64 1 +#define GPR_GETPID_IN_PROCESS_H 1 #elif defined(_WIN32) || defined(WIN32) #define GPR_ARCH_32 1 #define GPR_WIN32 1 +#define GPR_GETPID_IN_PROCESS_H 1 #elif defined(ANDROID) || defined(__ANDROID__) #define GPR_ANDROID 1 #define GPR_ARCH_32 1 @@ -61,6 +63,7 @@ #define GPR_POSIX_STRING 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 +#define GPR_GETPID_IN_UNISTD_H 1 #elif defined(__linux__) #define GPR_CPU_LINUX 1 #define GPR_GCC_ATOMIC 1 @@ -72,6 +75,7 @@ #define GPR_POSIX_STRING 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 +#define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 #else /* _LP64 */ @@ -89,6 +93,7 @@ #define GPR_POSIX_STRING 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 +#define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 #else /* _LP64 */ diff --git a/templates/vsprojects/vs2013/build_and_run_tests.bat.template b/templates/vsprojects/vs2013/build_and_run_tests.bat.template index 8679bee3fc3966d89c8ecae747463042cc3e5549..4a15e01c522225fa2a0b71be68a953feb97d74ed 100644 --- a/templates/vsprojects/vs2013/build_and_run_tests.bat.template +++ b/templates/vsprojects/vs2013/build_and_run_tests.bat.template @@ -13,7 +13,7 @@ @rem Build the library dependencies first MSBuild.exe gpr.vcxproj /p:Configuration=Debug -MSBuild.exe grpc_test_util.vcxproj /p:Configuration=Debug +MSBuild.exe gpr_test_util.vcxproj /p:Configuration=Debug mkdir ${test_bin_dir} diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index fc5de9bbefba5a43c1fbe7705251889e25a9a295..ab2c0d80a992ab1fa617b5d278acc7134479a8e4 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -33,11 +33,25 @@ #include "test/core/util/test_config.h" +#include <grpc/support/port_platform.h> #include <stdlib.h> + +#if GPR_GETPID_IN_UNISTD_H #include <unistd.h> +static int seed() { + return getpid(); +} +#endif + +#if GPR_GETPID_IN_PROCESS_H +#include <process.h> +static int seed(void) { + return _getpid(); +} +#endif void grpc_test_init(int argc, char **argv) { /* seed rng with pid, so we don't end up with the same random numbers as a concurrently running test binary */ - srand(getpid()); + srand(seed()); } diff --git a/vsprojects/vs2013/build_and_run_tests.bat b/vsprojects/vs2013/build_and_run_tests.bat index 06e9776d862c77f79068b37cdbd509a68b22ad64..3e36dcf6002060f35747d06e050f707d57d0db6a 100644 --- a/vsprojects/vs2013/build_and_run_tests.bat +++ b/vsprojects/vs2013/build_and_run_tests.bat @@ -5,7 +5,7 @@ @rem Build the library dependencies first MSBuild.exe gpr.vcxproj /p:Configuration=Debug -MSBuild.exe grpc_test_util.vcxproj /p:Configuration=Debug +MSBuild.exe gpr_test_util.vcxproj /p:Configuration=Debug mkdir test_bin