From 7843bb52a6948f63b9a5f57ac38e3f9362907065 Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Sun, 18 Oct 2026 08:45:09 +0200 Subject: [PATCH 1/5] ci: build on macOS and Windows Add macOS (Homebrew autotools, make check) and Windows (MSYS2 UCRT64 MinGW, build only) jobs to the autotools workflow. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 126c7f31f..9035e1dc8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,3 +18,41 @@ 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 + + build-windows: + runs-on: windows-latest + + defaults: + run: + shell: msys2 {0} + + steps: + - 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 From 2fbe31c72c8daa2e1e42a7f031cd8414b119053b Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Sun, 18 Oct 2026 08:49:55 +0200 Subject: [PATCH 2/5] ci: fix Windows checkout line endings, show macOS test logs Windows runners check out with core.autocrlf=true, and autoreconf fails on the resulting CRLF files. Disable the conversion before checkout. Print the unit test logs when make check fails on macOS. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9035e1dc8..3350e84ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: - name: make run: make - name: make check - run: make check + run: make check || { cat tests/test-suite.log tests/unit-test-*.log; exit 1; } build-windows: runs-on: windows-latest @@ -42,6 +42,10 @@ jobs: 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: From 17149d53742b58744ce948dd3b3802b62f7db1fb Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Sun, 18 Oct 2026 11:34:16 +0200 Subject: [PATCH 3/5] tests: disable Nagle on the byte-by-byte reply socket The 'Adapted byte timeout (7ms > 5ms)' test failed on macOS: the unit test server sends its reply one byte every 5 ms, but sockets returned by modbus_tcp_accept() don't have TCP_NODELAY set, so after the first byte the remaining ones were held back by Nagle's algorithm until the client's delayed ACK, far longer than the 7 ms byte timeout. Set TCP_NODELAY on the socket before sending the reply byte by byte. Co-Authored-By: Claude Opus 5.5 --- tests/unit-test-server.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unit-test-server.c b/tests/unit-test-server.c index b1e364837..6825f128a 100644 --- a/tests/unit-test-server.c +++ b/tests/unit-test-server.c @@ -16,6 +16,8 @@ # include #else # include +# include +# include #endif /* For MinGW */ @@ -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++) { From 30c4f11704a603841105555fd77b0d4cdd9fa945 Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Sun, 18 Oct 2026 15:33:45 +0200 Subject: [PATCH 4/5] tests: widen the adapted byte timeout to 50 ms On the macOS CI runner the server's usleep(5000) between reply bytes sometimes oversleeps by more than 2 ms, so the 7 ms byte timeout fired mid-reply. Use 50 ms, still checking that a byte timeout larger than the inter-byte delay succeeds. Co-Authored-By: Claude Opus 5.5 --- tests/unit-test-client.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit-test-client.c b/tests/unit-test-client.c index c1542e971..6c0eb28d7 100644 --- a/tests/unit-test-client.c +++ b/tests/unit-test-client.c @@ -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, ""); } From edcb5ac6c981c715f8ed59b26111455c33e9c3ab Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Sun, 18 Oct 2026 15:38:05 +0200 Subject: [PATCH 5/5] tests: widen the client response timeout in test_server() Invalid requests make the server sleep its 0.5 s response timeout before flushing and replying with an exception. The client waited only 0.6 s, and on the macOS CI runner the reply sometimes arrived later than that. Use 2 s; no check in test_server() expects a timeout so passing runs don't get slower. Co-Authored-By: Claude Opus 5.5 --- tests/unit-test-client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit-test-client.c b/tests/unit-test-client.c index 6c0eb28d7..cca61a3a6 100644 --- a/tests/unit-test-client.c +++ b/tests/unit-test-client.c @@ -898,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);