Seed random numbers in each process based on pid.

This causes get_unused_port_or_die to try different port numbers in each
concurrently running tests, and consequently enables some parallelism of test
processes.
	Change on 2015/01/05 by ctiller <ctiller@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83289374
pull/1/merge
ctiller 10 years ago committed by Craig Tiller
parent 156e67d417
commit b3e3317ae8
  1. 4
      test/core/echo/echo_test.c
  2. 4
      test/core/fling/fling_stream_test.c
  3. 4
      test/core/fling/fling_test.c
  4. 9
      test/core/util/test_config.c

@ -37,6 +37,7 @@
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
@ -80,6 +81,9 @@ int main(int argc, char **argv) {
pid_t svr;
int ret;
int do_ipv6 = 1;
/* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */
srand(getpid());
if (!grpc_ipv6_loopback_available()) {
gpr_log(GPR_INFO, "Can't bind to ::1. Skipping IPv6 tests.");
do_ipv6 = 0;

@ -37,6 +37,7 @@
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
@ -53,6 +54,9 @@ int main(int argc, char **argv) {
char *args[10];
int status;
pid_t svr, cli;
/* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */
srand(getpid());
/* figure out where we are */
if (lslash) {
memcpy(root, me, lslash - me);

@ -37,6 +37,7 @@
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
@ -53,6 +54,9 @@ int main(int argc, char **argv) {
char *args[10];
int status;
pid_t svr, cli;
/* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */
srand(getpid());
/* figure out where we are */
if (lslash) {
memcpy(root, me, lslash - me);

@ -33,4 +33,11 @@
#include "test/core/util/test_config.h"
void grpc_test_init(int argc, char **argv) {}
#include <stdlib.h>
#include <unistd.h>
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());
}

Loading…
Cancel
Save