From c7be8e95a2781d91bb2bd3c2ec1d2a8acb4703bd Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Sat, 21 Dec 2024 23:59:22 +0000 Subject: [PATCH] test log --- src/router.c | 4 ++++ tests/40-ip-spx.t | 22 ++++++++++++++++++++++ tools/spx-client.c | 8 ++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/router.c b/src/router.c index 8feb86d..0ec3a0d 100644 --- a/src/router.c +++ b/src/router.c @@ -867,9 +867,13 @@ static DWORD router_main(void *arg) } } + wait_ms = 50; + WaitForMultipleObjects(n_events, wait_events, FALSE, wait_ms); WSAResetEvent(router_event); + log_printf(LOG_INFO, "router tick"); + if(!router_running) { break; diff --git a/tests/40-ip-spx.t b/tests/40-ip-spx.t index 7c51866..33eac71 100644 --- a/tests/40-ip-spx.t +++ b/tests/40-ip-spx.t @@ -23,6 +23,7 @@ use FindBin; use lib "$FindBin::Bin/lib/"; use IPXWrapper::Capture::IPXOverUDP; +use IPXWrapper::LogServer; use IPXWrapper::SPX; use IPXWrapper::Tool::Generic; use IPXWrapper::Util; @@ -50,6 +51,27 @@ describe "IPXWrapper using IP encapsulation" => sub reg_set_addr( $remote_ip_a, "HKCU\\Software\\IPXWrapper\\$remote_mac_b", "net", "00:00:00:02"); }; + my $log = undef; + + before each => sub + { + $log = IPXWrapper::LogServer->new(); + + reg_set_string($remote_ip_a, "HKCU\\Software\\IPXWrapper", "log_server_addr", $local_ip_a); + reg_set_dword( $remote_ip_a, "HKCU\\Software\\IPXWrapper", "log_server_port", $log->port()); + }; + + after each => sub + { + # TODO: Call this if the test succeeded. + # + # If a test fails due to an exception, the after blocks won't be called, however a + # test failing due to an assertion still calls the after blocks. I haven't found + # any way to actually determine if the test passed from code. + + # $log->discard(); + }; + it "responds to SPX lookups" => sub { my $listener = IPXWrapper::Tool::Generic->new( diff --git a/tools/spx-client.c b/tools/spx-client.c index 93f7d37..45417b5 100644 --- a/tools/spx-client.c +++ b/tools/spx-client.c @@ -1,5 +1,5 @@ /* IPXWrapper test tools - * Copyright (C) 2014 Daniel Collins + * Copyright (C) 2014-2024 Daniel Collins * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by @@ -113,7 +113,11 @@ int main(int argc, char **argv) for(int i = 0; i < sizeof(data);) { int r = recv(sock, buf + i, sizeof(data) - i, 0); - assert(r != -1); + if(r < 0) + { + printf("recv: %u\n", (unsigned int)(WSAGetLastError())); + return 1; + } printf("Read %d bytes from socket\n", r); i += r;