summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-02-17 14:26:57 -0700
committerJens Axboe <axboe@kernel.dk>2021-02-17 14:32:27 -0700
commitd0984a9677c129fda406d749001d9be0d8f45c2f (patch)
treee6193c9202ebac799f184af1b81809ef375c34ba
parentcce606671f5b51ab460f8f21f9cd2c43a1104c4a (diff)
downloadliburing-d0984a9677c129fda406d749001d9be0d8f45c2f.tar.gz
liburing-d0984a9677c129fda406d749001d9be0d8f45c2f.tar.bz2
test: use random port in range for socket tests
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/shutdown.c4
-rw-r--r--test/socket-rw-eagain.c4
-rw-r--r--test/socket-rw.c4
3 files changed, 9 insertions, 3 deletions
diff --git a/test/shutdown.c b/test/shutdown.c
index 5f4e9cc..5aa1371 100644
--- a/test/shutdown.c
+++ b/test/shutdown.c
@@ -32,6 +32,8 @@ int main(int argc, char *argv[])
if (argc > 1)
return 0;
+ srand(getpid());
+
recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
@@ -40,7 +42,7 @@ int main(int argc, char *argv[])
assert(ret != -1);
addr.sin_family = AF_INET;
- addr.sin_port = 0x1235;
+ addr.sin_port = (rand() % 61440) + 4096;
addr.sin_addr.s_addr = 0x0100007fU;
ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
diff --git a/test/socket-rw-eagain.c b/test/socket-rw-eagain.c
index e08f984..b6406d8 100644
--- a/test/socket-rw-eagain.c
+++ b/test/socket-rw-eagain.c
@@ -28,6 +28,8 @@ int main(int argc, char *argv[])
if (argc > 1)
return 0;
+ srand(getpid());
+
recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
@@ -36,7 +38,7 @@ int main(int argc, char *argv[])
assert(ret != -1);
addr.sin_family = AF_INET;
- addr.sin_port = 0x1235;
+ addr.sin_port = (rand() % 61440) + 4096;
addr.sin_addr.s_addr = 0x0100007fU;
ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
diff --git a/test/socket-rw.c b/test/socket-rw.c
index 77fae59..47ae25c 100644
--- a/test/socket-rw.c
+++ b/test/socket-rw.c
@@ -30,6 +30,8 @@ int main(int argc, char *argv[])
if (argc > 1)
return 0;
+ srand(getpid());
+
recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
@@ -38,7 +40,7 @@ int main(int argc, char *argv[])
assert(ret != -1);
addr.sin_family = AF_INET;
- addr.sin_port = 0x1235;
+ addr.sin_port = (rand() % 61440) + 4096;
addr.sin_addr.s_addr = 0x0100007fU;
ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));