Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,45 @@ jobs:
run: make
- name: make distcheck
run: make distcheck

build-macos:
runs-on: macos-latest

steps:
- uses: actions/checkout@v6.0.1
- name: install dependencies
run: brew install autoconf automake libtool
- name: configure
# Homebrew installs libtoolize as glibtoolize
run: LIBTOOLIZE=glibtoolize ./autogen.sh && ./configure
- name: make
run: make
- name: make check
run: make check || { cat tests/test-suite.log tests/unit-test-*.log; exit 1; }

build-windows:
runs-on: windows-latest

defaults:
run:
shell: msys2 {0}

steps:
# Keep LF line endings, autotools fail on CRLF
- name: disable autocrlf
shell: pwsh
run: git config --global core.autocrlf false
- uses: actions/checkout@v6.0.1
- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: >-
mingw-w64-ucrt-x86_64-autotools
mingw-w64-ucrt-x86_64-gcc
- name: configure
run: ./autogen.sh && ./configure
# Tests are only built: unit-tests.sh relies on killall which
# isn't available under MSYS2
- name: make
run: make
12 changes: 7 additions & 5 deletions tests/unit-test-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,12 @@ int main(int argc, char *argv[])
usleep(11 * 5000);
modbus_flush(ctx);

/* Timeout of 7ms between bytes */
modbus_set_byte_timeout(ctx, 0, 7000);
/* Timeout of 50ms between bytes, the margin absorbs the server
* oversleeping on loaded (eg. virtualized CI) machines */
modbus_set_byte_timeout(ctx, 0, 50000);
rc = modbus_read_registers(
ctx, UT_REGISTERS_ADDRESS_BYTE_SLEEP_5_MS, 1, tab_rp_registers);
printf("2/2 Adapted byte timeout (7ms > 5ms): ");
printf("2/2 Adapted byte timeout (50ms > 5ms): ");
ASSERT_TRUE(rc == 1, "");
}

Expand Down Expand Up @@ -897,11 +898,12 @@ int test_server(modbus_t *ctx, int use_backend)

/* This requests can generate flushes server side so we need a higher
* response timeout than the server. The server uses the defined response
* timeout to sleep before flushing.
* timeout (0.5s) to sleep before flushing, so keep a wide margin for
* loaded (eg. virtualized CI) machines.
* The old timeouts are restored at the end.
*/
modbus_get_response_timeout(ctx, &old_response_to_sec, &old_response_to_usec);
modbus_set_response_timeout(ctx, 0, 600000);
modbus_set_response_timeout(ctx, 2, 0);

int old_s = modbus_get_socket(ctx);
modbus_set_socket(ctx, -1);
Expand Down
9 changes: 9 additions & 0 deletions tests/unit-test-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# include <winsock2.h>
#else
# include <sys/socket.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
#endif

/* For MinGW */
Expand Down Expand Up @@ -198,6 +200,13 @@ int main(int argc, char *argv[])
continue;
}

/* Disable Nagle's algorithm, otherwise the bytes after the
* first one can be held back until the client ACKs it, which
* is delayed on some systems (eg. macOS) far beyond 5 ms */
int nodelay = 1;
setsockopt(w_s, IPPROTO_TCP, TCP_NODELAY, (const char *) &nodelay,
sizeof(nodelay));

/* Copy TID */
req[1] = query[1];
for (i = 0; i < req_length; i++) {
Expand Down
Loading