From: Sean Hefty Date: Tue, 17 Jul 2012 22:32:54 +0000 (-0700) Subject: rstream: Add option to test fork support X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=ecd866920791883b70e9ed0f963bda63336664bc;p=~shefty%2Flibrdmacm.git rstream: Add option to test fork support Signed-off-by: Sean Hefty --- diff --git a/examples/rstream.c b/examples/rstream.c index 48e2771e..85956572 100644 --- a/examples/rstream.c +++ b/examples/rstream.c @@ -84,6 +84,8 @@ static int verify; static int flags = MSG_DONTWAIT; static int poll_timeout = 0; static int custom; +static int use_fork; +static pid_t fork_pid; static enum rs_optimization optimization; static int size_option; static int iterations = 1; @@ -463,7 +465,10 @@ static int server_connect(void) perror("raccept"); } - set_options(rs); + if (use_fork) + fork_pid = fork(); + if (!fork_pid) + set_options(rs); return ret; } @@ -546,20 +551,24 @@ static int run(void) if (ret) goto free; - for (i = 0; i < TEST_CNT; i++) { + for (i = 0; i < TEST_CNT && !fork_pid; i++) { if (test_size[i].option > size_option) continue; init_latency_test(test_size[i].size); run_test(); } - rs_shutdown(rs, SHUT_RDWR); + if (!fork_pid) + rs_shutdown(rs, SHUT_RDWR); rs_close(rs); + if (!dst_addr && use_fork && !fork_pid) + goto free; + optimization = opt_bandwidth; ret = dst_addr ? client_connect() : server_connect(); if (ret) goto free; - for (i = 0; i < TEST_CNT; i++) { + for (i = 0; i < TEST_CNT && !fork_pid; i++) { if (test_size[i].option > size_option) continue; init_bandwidth_test(test_size[i].size); @@ -570,10 +579,12 @@ static int run(void) if (ret) goto free; - ret = run_test(); + if (!fork_pid) + ret = run_test(); } - rs_shutdown(rs, SHUT_RDWR); + if (!fork_pid) + rs_shutdown(rs, SHUT_RDWR); rs_close(rs); free: free(buf); @@ -593,6 +604,10 @@ static int set_test_opt(char *optarg) case 'b': flags &= ~MSG_DONTWAIT; break; + case 'f': + use_fork = 1; + use_rs = 0; + break; case 'n': flags |= MSG_DONTWAIT; break; @@ -613,6 +628,9 @@ static int set_test_opt(char *optarg) flags |= MSG_DONTWAIT; } else if (!strncasecmp("verify", optarg, 6)) { verify = 1; + } else if (!strncasecmp("fork", optarg, 4)) { + use_fork = 1; + use_rs = 0; } else { return -1; } @@ -671,6 +689,7 @@ int main(int argc, char **argv) printf("\t s|sockets - use standard tcp/ip sockets\n"); printf("\t a|async - asynchronous operation (use poll)\n"); printf("\t b|blocking - use blocking calls\n"); + printf("\t f|fork - fork server processing\n"); printf("\t n|nonblocking - use nonblocking calls\n"); printf("\t v|verify - verify data\n"); exit(1); diff --git a/man/rstream.1 b/man/rstream.1 index ea87b951..29aa66bd 100644 --- a/man/rstream.1 +++ b/man/rstream.1 @@ -48,6 +48,8 @@ a | async - uses asynchronous operation (e.g. select / poll) .P b | blocking - uses blocking calls .P +f | fork - fork server processing (forces -T s option) +.P n | nonblocking - uses non-blocking calls .P v | verify - verifies data transfers