diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 126c7f31f..3350e84ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/tests/unit-test-client.c b/tests/unit-test-client.c index c1542e971..cca61a3a6 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, ""); } @@ -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); 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++) {