[ovs-dev] [PATCH v2 2/7] tests: Port test-sflow and test-netflow to windows.
Gurucharan Shetty
shettyg at nicira.com
Fri Jun 13 14:40:01 UTC 2014
After the change, both of them compile. test-netflow related
unit tests pass.
test-sflow related tests do not pass because
of LOOPBACK_INTERFACE constraints for 'agent'.
(It should be revisited later.)
Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
v1-v2:
Remove the call to winsock_start() as WSAStartup is now called
through OVS_CONSTRUCTOR.
---
tests/test-netflow.c | 10 ++++++++--
tests/test-sflow.c | 10 ++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/tests/test-netflow.c b/tests/test-netflow.c
index 1243f83..ab9088f 100644
--- a/tests/test-netflow.c
+++ b/tests/test-netflow.c
@@ -178,9 +178,11 @@ test_netflow_main(int argc, char *argv[])
int error;
int sock;
int n;
+ HANDLE wevent = 0;
proctitle_init(argc, argv);
set_program_name(argv[0]);
+ service_start(&argc, &argv);
parse_options(argc, argv);
if (argc - optind != 1) {
@@ -189,6 +191,10 @@ test_netflow_main(int argc, char *argv[])
}
target = argv[optind];
+#ifdef _WIN32
+ wevent = CreateEvent(NULL, FALSE, FALSE, NULL);
+#endif
+
sock = inet_open_passive(SOCK_DGRAM, target, 0, NULL, 0, true);
if (sock < 0) {
ovs_fatal(0, "%s: failed to open (%s)", argv[1], ovs_strerror(-sock));
@@ -214,7 +220,7 @@ test_netflow_main(int argc, char *argv[])
ofpbuf_clear(&buf);
do {
- retval = read(sock, ofpbuf_data(&buf), buf.allocated);
+ retval = recv(sock, ofpbuf_data(&buf), buf.allocated, 0);
} while (retval < 0 && errno == EINTR);
if (retval > 0) {
ofpbuf_put_uninit(&buf, retval);
@@ -229,7 +235,7 @@ test_netflow_main(int argc, char *argv[])
break;
}
- poll_fd_wait(sock, POLLIN);
+ poll_fd_wait_event(sock, wevent, POLLIN);
unixctl_server_wait(server);
poll_block();
}
diff --git a/tests/test-sflow.c b/tests/test-sflow.c
index fa8b5c5..64f6984 100644
--- a/tests/test-sflow.c
+++ b/tests/test-sflow.c
@@ -496,9 +496,11 @@ test_sflow_main(int argc, char *argv[])
bool exiting = false;
int error;
int sock;
+ HANDLE wevent = 0;
proctitle_init(argc, argv);
set_program_name(argv[0]);
+ service_start(&argc, &argv);
parse_options(argc, argv);
if (argc - optind != 1) {
@@ -507,6 +509,10 @@ test_sflow_main(int argc, char *argv[])
}
target = argv[optind];
+#ifdef _WIN32
+ wevent = CreateEvent(NULL, FALSE, FALSE, NULL);
+#endif
+
sock = inet_open_passive(SOCK_DGRAM, target, 0, NULL, 0, true);
if (sock < 0) {
ovs_fatal(0, "%s: failed to open (%s)", argv[1], ovs_strerror(-sock));
@@ -531,7 +537,7 @@ test_sflow_main(int argc, char *argv[])
ofpbuf_clear(&buf);
do {
- retval = read(sock, ofpbuf_data(&buf), buf.allocated);
+ retval = recv(sock, ofpbuf_data(&buf), buf.allocated, 0);
} while (retval < 0 && errno == EINTR);
if (retval > 0) {
ofpbuf_put_uninit(&buf, retval);
@@ -543,7 +549,7 @@ test_sflow_main(int argc, char *argv[])
break;
}
- poll_fd_wait(sock, POLLIN);
+ poll_fd_wait_event(sock, wevent, POLLIN);
unixctl_server_wait(server);
poll_block();
}
--
1.7.9.5
More information about the dev
mailing list