Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac test hang #151

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a12ca51
Use serial tests to investigate test stdout.
daisys-steve Mar 16, 2023
508ac4f
Print progress in test_bidirectional_tcp
daisys-steve Mar 16, 2023
7120149
Echo name of test.
daisys-steve Mar 16, 2023
e94d9d6
Run tests explicitly.
daisys-steve Mar 16, 2023
c7ca499
For the mac job.
daisys-steve Mar 17, 2023
8dc5055
sudo killall -HUP mDNSResponder
JohannesLorenz Dec 2, 2023
8068fa0
Windows
JohannesLorenz Dec 3, 2023
4899168
Windows
JohannesLorenz Dec 3, 2023
f2eb298
Windows
JohannesLorenz Dec 3, 2023
aa089b0
Windows
JohannesLorenz Dec 3, 2023
de85f00
Windows
JohannesLorenz Dec 3, 2023
d4ec67e
Windows
JohannesLorenz Dec 3, 2023
c8cc2ca
Windows
JohannesLorenz Dec 3, 2023
fd56fbd
Windows
JohannesLorenz Dec 3, 2023
e02feda
Windows
JohannesLorenz Dec 3, 2023
d75b586
Fix run part
JohannesLorenz Dec 4, 2023
62a6800
Fix run part
JohannesLorenz Dec 4, 2023
c2b6e40
Fix run part
JohannesLorenz Dec 4, 2023
4696363
Fix run part
JohannesLorenz Dec 4, 2023
5105ed9
Fix run part
JohannesLorenz Dec 4, 2023
2322f07
Fix run part
JohannesLorenz Dec 4, 2023
f6736be
Fix run part
JohannesLorenz Dec 4, 2023
486bb38
...
JohannesLorenz Dec 4, 2023
c11dc73
???
JohannesLorenz Dec 4, 2023
f4fb6b5
...
JohannesLorenz Dec 4, 2023
397d1e3
Tmp
JohannesLorenz Dec 5, 2023
8fd1399
Tmp
JohannesLorenz Dec 5, 2023
4828e1b
Tmp
JohannesLorenz Dec 5, 2023
04bef59
Add console output, thanks to tresf
JohannesLorenz Dec 5, 2023
07a3d38
Windows: Link statically
JohannesLorenz Dec 5, 2023
9fd8740
tmp
JohannesLorenz Dec 9, 2023
fd86a6f
Fix Windows. Thanks to tresf
JohannesLorenz Dec 10, 2023
bbe816a
Windows: Minor improvements
JohannesLorenz Dec 10, 2023
aeb8664
Improve Working directory
JohannesLorenz Dec 11, 2023
e3bdc7b
Do not use WORKING_DIRECTORY on Windows
JohannesLorenz Dec 11, 2023
84a0f48
Fixup
JohannesLorenz Dec 11, 2023
00b5246
debug
JohannesLorenz Dec 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: C/C++ CI

on: [push, pull_request]
on: [push]

jobs:
Linux:
Expand Down Expand Up @@ -66,6 +66,8 @@ jobs:
- name: liblo make x86_64
run:
make
&& echo -e "\n127.0.0.1 $(hostname)\n" | sudo tee -a /etc/hosts
&& (cd src && ls testlo && ./testlo && ls test_bidirectional_tcp && ./test_bidirectional_tcp && ls cpp_test && ./cpp_test)
&& (make check || (for i in src/*.log; do echo === $i ===; cat $i; done; false))
&& make install
&& mv ./inst/lib/liblo.7.dylib ./inst/lib/liblo.7.dylib.x86_64
Expand Down Expand Up @@ -106,3 +108,11 @@ jobs:
cd bld\
cmake ..\cmake -DCMAKE_BUILD_TYPE=Release
cmake --build . --target all_build --config Release
- name: Run testlo
run: >
cd bld/;
"$env:GITHUB_ACTION_PATH\tests\Release\testlo.exe"
- name: Run tests
run: |
cd bld\
ctest -V
37 changes: 33 additions & 4 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)

option(WITH_TOOLS "Enable building tools." ON)
option(WITH_TESTS "Enable building tests." ON)
Expand All @@ -7,6 +7,10 @@ option(WITH_CPP_TESTS "Enable building C++ wrapper tests." ON)
option(WITH_STATIC "Enable building static library." OFF)
option(THREADING "Build with threading support." ON)

#if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(WITH_STATIC 1)
#endif()

if (WITH_STATIC)
message(STATUS "If you are using the static library build, please keep in mind (and inform yourself of the implications) that liblo is licensed with LGPL v2.1+.")
endif()
Expand Down Expand Up @@ -79,6 +83,7 @@ if (WITH_TOOLS)
endif()
if (WITH_TESTS)
set(TESTLO testlo)
set(TESTTCP test_bidirectional_tcp)
set(SUBTEST subtest)
if (WITH_CPP_TESTS)
set(CPPTEST cpp_test)
Expand All @@ -94,7 +99,7 @@ if (WITH_EXAMPLES)
endif()

set(TOOLS ${OSCDUMP} ${OSCSEND} ${OSCSENDFILE})
set(TESTS ${TESTLO} ${SUBTEST})
set(TESTS ${TESTLO} ${TESTTCP} ${SUBTEST})
list(APPEND TESTS ${CPPTEST})
set(EXAMPLES ${EXAMPLE_CLIENT} ${EXAMPLE_SERVER}
${EXAMPLE_TCP_ECHO_SERVER} ${NONBLOCKING_SERVER_EXAMPLE})
Expand Down Expand Up @@ -130,6 +135,7 @@ set(OSCDUMP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/tools/oscdump.c)
set(OSCSEND_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/tools/oscsend.c)
set(OSCSENDFILE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/tools/oscsendfile.c)
set(TESTLO_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/testlo.c)
set(TESTTCP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/test_bidirectional_tcp.c)
set(SUBTEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/subtest.c)
if (WITH_CPP_TESTS)
set(CPPTEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/cpp_test.cpp)
Expand Down Expand Up @@ -174,7 +180,7 @@ set(BUILD_LANGUAGE C CACHE STRING "Build language (C or CXX)")
mark_as_advanced(BUILD_LANGUAGE)
set_source_files_properties(
${LIBRARY_SOURCES} ${OSCDUMP_SOURCES} ${OSCSEND_SOURCES} ${OSCSENDFILE_SOURCES}
${TESTLO_SOURCES} ${EXAMPLE_CLIENT_SOURCES}
${TESTLO_SOURCES} ${TESTTCP_SOURCES} ${EXAMPLE_CLIENT_SOURCES}
${EXAMPLE_SERVER_SOURCES} ${EXAMPLE_TCP_ECHO_SERVER_SOURCES}
${NONBLOCKING_SERVER_EXAMPLE_SOURCES}
PROPERTIES LANGUAGE ${BUILD_LANGUAGE})
Expand All @@ -201,10 +207,27 @@ endif()
if (WITH_TESTS)
add_executable(${TESTLO} ${TESTLO_SOURCES})
add_executable(${SUBTEST} ${SUBTEST_SOURCES})
add_executable(${TESTTCP} ${TESTTCP_SOURCES})
target_link_libraries(${TESTLO} PRIVATE Threads::Threads)
target_link_libraries(${TESTTCP} PRIVATE Threads::Threads)
if (WIN32)
# If you use the new suntax, on Windows, you need to run `cmake -C Release` instead of `cmake`.
# We do not want that, so we use the old Syntax for Windows...
add_test(${TESTLO} "tests/${TESTLO}")
add_test("test-bidirectional-tcp" "tests/${TESTTCP}")
else()
add_test(NAME ${TESTLO} COMMAND ${TESTLO} WORKING_DIRECTORY $<TARGET_FILE_DIR:${TESTLO}>)
add_test(NAME "test-bidirectional-tcp" COMMAND ${TESTTCP} WORKING_DIRECTORY $<TARGET_FILE_DIR:${TESTTCP}>)
endif()
enable_testing()
endif()
if (WITH_CPP_TESTS)
add_executable(${CPPTEST} ${CPPTEST_SOURCES})
if (WIN32)
add_test(${CPPTEST} "tests/${CPPTEST}")
else()
add_test(NAME ${CPPTEST} COMMAND ${CPPTEST} WORKING_DIRECTORY $<TARGET_FILE_DIR:${CPPTEST}>)
endif()
endif()

# Examples
Expand Down Expand Up @@ -237,6 +260,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
endif()
target_link_libraries(${NONBLOCKING_SERVER_EXAMPLE} PRIVATE "wsock32")
target_link_libraries(${TESTLO} PRIVATE "wsock32")
target_link_libraries(${TESTTCP} PRIVATE "wsock32")

set_target_properties(${LIBRARY_SHARED} PROPERTIES
COMPILE_DEFINITIONS "LIBLO_DLL")
Expand Down Expand Up @@ -274,7 +298,12 @@ foreach(PROG ${PROGRAMS})
target_include_directories(${PROG} PUBLIC
"$<BUILD_INTERFACE:${LO_BUILD_INCLUDE_DIRS}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(${PROG} PUBLIC ${LIBRARY_SHARED})
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
# For some yet unknown reasons, Windows has trouble finding the DLL
target_link_libraries(${PROG} PUBLIC ${LIBRARY_STATIC})
else()
target_link_libraries(${PROG} PUBLIC ${LIBRARY_SHARED})
endif()
endforeach(PROG)

foreach(PROG ${TOOLS})
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
AUTOMAKE_OPTIONS = serial-tests

SUBDIRS = .
if COMPILE_TOOLS
SUBDIRS += tools
Expand Down
25 changes: 17 additions & 8 deletions src/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,15 +602,24 @@ int lo_address_resolve(lo_address a)
#endif
hints.ai_socktype =
a->protocol == LO_UDP ? SOCK_DGRAM : SOCK_STREAM;

if ((ret = getaddrinfo(host, lo_address_get_port(a), &hints, &ai))) {
a->errnum = ret;
a->errstr = gai_strerror(ret);
a->ai = NULL;
a->ai_first = NULL;
return -1;
}

/*if (getaddrinfo(host, lo_address_get_port(a), &hints, &ai)) {
usleep(100000);
if (getaddrinfo(host, lo_address_get_port(a), &hints, &ai)) {
usleep(200000);
if (getaddrinfo(host, lo_address_get_port(a), &hints, &ai)) {
usleep(400000);*/
if ((ret = getaddrinfo(host, lo_address_get_port(a), &hints, &ai))) {
puts("MAC ERROR!");
a->errnum = ret;
a->errstr = gai_strerror(ret);
a->ai = NULL;
a->ai_first = NULL;
return -1;
}
/* }
}
}*/
a->ai = ai;
a->ai_first = ai;
}
Expand Down
46 changes: 32 additions & 14 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ lo_server lo_server_new_multicast_iface(const char *group, const char *port,
lo_server lo_server_new_with_proto(const char *port, int proto,
lo_err_handler err_h)
{
fprintf(stderr, "-4");
return lo_server_new_with_proto_internal(NULL, port, 0, 0, proto, err_h, 0);
}

Expand Down Expand Up @@ -452,14 +453,14 @@ lo_server lo_server_new_with_proto_internal(const char *group,
char pnum[16];
const char *service;
int err = 0;

fprintf(stderr, "-4\n");
#if defined(WIN32) || defined(_MSC_VER)
/* Windows Server 2003 or later (Vista, 7, etc.) must join the
* multicast group before bind(), but Windows XP must join
* after bind(). */
int wins2003_or_later = detect_windows_server_2003_or_later();
#endif

fprintf(stderr, "-3\n");
// Set real protocol, if Default is requested
if (proto == LO_DEFAULT) {
#if !defined(WIN32) && !defined(_MSC_VER)
Expand All @@ -469,11 +470,12 @@ lo_server lo_server_new_with_proto_internal(const char *group,
#endif
proto = LO_UDP;
}
fprintf(stderr, "-2\n");
#if defined(WIN32) || defined(_MSC_VER)
if (!initWSock())
return NULL;
#endif

fprintf(stderr, "-1\n");
s = (lo_server) calloc(1, sizeof(struct _lo_server));
if (!s)
return 0;
Expand All @@ -499,15 +501,15 @@ lo_server lo_server_new_with_proto_internal(const char *group,
s->bundle_handler_user_data = NULL;
s->addr_if.iface = 0;
s->addr_if.size = 0;

fprintf(stderr, "0\n");
if (!(s->sockets && s->contexts && s->sources)) {
free(s->sockets);
free(s->contexts);
free(s->sources);
free(s);
return 0;
}

fprintf(stderr, "1\n");
s->sockets[0].fd = -1;
s->max_msg_size = LO_DEFAULT_MAX_MSG_SIZE;

Expand Down Expand Up @@ -556,7 +558,7 @@ lo_server lo_server_new_with_proto_internal(const char *group,

return NULL;
}

fprintf(stderr, "2\n");
#ifdef ENABLE_IPV6
/* Determine the address family based on provided IP string or
multicast group, if available, otherwise let the operating
Expand All @@ -577,6 +579,7 @@ lo_server lo_server_new_with_proto_internal(const char *group,
service = port;
}
do {
fprintf(stderr, "3\n");
int ret;
if (!port) {
/* not a good way to get random numbers, but its not critical */
Expand Down Expand Up @@ -604,7 +607,7 @@ lo_server lo_server_new_with_proto_internal(const char *group,
for (it = ai; it && s->sockets[0].fd == -1; it = it->ai_next) {
used = it;
s->sockets[0].fd = socket(it->ai_family, hints.ai_socktype, 0);

fprintf(stderr, "4\n");
if (s->sockets[0].fd != -1
&& it->ai_family == AF_INET
&& hints.ai_socktype == SOCK_DGRAM)
Expand All @@ -624,7 +627,7 @@ lo_server lo_server_new_with_proto_internal(const char *group,
lo_server_free(s);
return NULL;
}

fprintf(stderr, "5\n");
#ifdef ENABLE_IPV6
unsigned int v6only_off = 0;
if (setsockopt(s->sockets[0].fd, IPPROTO_IPV6, IPV6_V6ONLY,
Expand Down Expand Up @@ -675,7 +678,7 @@ lo_server lo_server_new_with_proto_internal(const char *group,
}
#endif
}}

fprintf(stderr, "6\n");
if ((used != NULL) &&
(bind(s->sockets[0].fd, used->ai_addr, used->ai_addrlen) <
0)) {
Expand All @@ -695,7 +698,7 @@ lo_server lo_server_new_with_proto_internal(const char *group,
return NULL;
}
} while (!used && tries++ < 16);

fprintf(stderr, "7\n");
if (!used) {
lo_throw(s, LO_NOPORT, "cannot find free port", NULL);

Expand Down Expand Up @@ -732,7 +735,7 @@ lo_server lo_server_new_with_proto_internal(const char *group,
lo_throw(s, LO_UNKNOWNPROTO, "unknown protocol family", NULL);
s->port = atoi(port);
}

fprintf(stderr, "8\n");
return s;
}

Expand Down Expand Up @@ -1645,10 +1648,13 @@ int lo_server_recv(lo_server s)

again:
if (sched_time > 0.01) {
fprintf(stderr, "r1\n");
if (sched_time > 10.0) {
fprintf(stderr, "r2\n");
sched_time = 10.0;
}
#ifdef HAVE_POLL
fprintf(stderr, "r3\n");
for (i = 0; i < s->sockets_len; i++) {
s->sockets[i].events = POLLIN | POLLPRI | POLLERR | POLLHUP;
s->sockets[i].revents = 0;
Expand All @@ -1660,9 +1666,12 @@ int lo_server_recv(lo_server s)
goto got_data;
}
}
fprintf(stderr, "r4\n");

poll(s->sockets, s->sockets_len, (int) (sched_time * 1000.0));

fprintf(stderr, "r5\n");

for (i = 0; i < s->sockets_len; i++) {
if (!s->sockets[i].revents)
continue;
Expand All @@ -1676,6 +1685,8 @@ int lo_server_recv(lo_server s)
}
break;
}

fprintf(stderr, "r6\n");

if (i >= s->sockets_len) {
sched_time = lo_server_next_event_delay(s);
Expand All @@ -1685,13 +1696,14 @@ int lo_server_recv(lo_server s)

return dispatch_queued(s, 0);
}
fprintf(stderr, "r7\n");
#else
#ifdef HAVE_SELECT
#if defined(WIN32) || defined(_MSC_VER)
if (!initWSock())
return 0;
#endif

fprintf(stderr, "r8\n");
FD_ZERO(&ps);
for (i = 0; i < s->sockets_len; i++) {
FD_SET(s->sockets[i].fd, &ps);
Expand All @@ -1706,14 +1718,14 @@ int lo_server_recv(lo_server s)
goto got_data;
}
}

fprintf(stderr, "r9\n");
stimeout.tv_sec = sched_time;
stimeout.tv_usec = (sched_time - stimeout.tv_sec) * 1.e6;
res = select(nfds + 1, &ps, NULL, NULL, &stimeout);
if (res == SOCKET_ERROR) {
return 0;
}

fprintf(stderr, "r10\n");
if (!res) {
sched_time = lo_server_next_event_delay(s);

Expand All @@ -1722,25 +1734,31 @@ int lo_server_recv(lo_server s)

return dispatch_queued(s, 0);
}
fprintf(stderr, "r11\n");
#endif
#endif
} else {
fprintf(stderr, "r12\n");
return dispatch_queued(s, 0);
}
if (s->protocol == LO_TCP) {
fprintf(stderr, "r13\n");
data = lo_server_recv_raw_stream(s, &size, &sock);
} else {
data = lo_server_recv_raw(s, &size);
}
fprintf(stderr, "r14\n");

if (!data) {
return 0;
}
got_data:
fprintf(stderr, "r15\n");
if (dispatch_data(s, data, size, sock) < 0) {
free(data);
return -1;
}
fprintf(stderr, "r16\n");
free(data);
return (int) size;
}
Expand Down
Loading