From 42db640d3256ecb8a2158419dee982d9b5fb779f Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Wed, 15 May 2024 15:40:00 -0600 Subject: [PATCH 1/4] Add MSYS2 build CI test --- .github/workflows/msys2.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/msys2.yml diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml new file mode 100644 index 0000000000..a02151f956 --- /dev/null +++ b/.github/workflows/msys2.yml @@ -0,0 +1,34 @@ +name: MSYS2 Build Test + +# START OF COMMON SECTION +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +# END OF COMMON SECTION + +jobs: + msys2-ucrt64: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + path: wolfssl + msystem: UCRT64 + update: true + install: git mingw-w64-ucrt-x86_64-gcc autotools base-devel autoconf + - name: configure wolfSSL + run: ./autogen.sh && ./configure --enable-all --disable-crl-monitor + - name: build wolfSSL + run: make check + - name: Display log + run: cat test-suite.log From 367f3d0fa0158aa58e7be777cfa4a154ab268dd2 Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Thu, 16 May 2024 09:17:49 -0600 Subject: [PATCH 2/4] Get MSYS2 tests passing --- examples/benchmark/tls_bench.c | 4 ++-- tests/api.c | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/examples/benchmark/tls_bench.c b/examples/benchmark/tls_bench.c index cd672911fc..6259acfb54 100644 --- a/examples/benchmark/tls_bench.c +++ b/examples/benchmark/tls_bench.c @@ -813,7 +813,7 @@ static int SetupSocketAndConnect(info_t* info, const char* host, /* Setup server address */ XMEMSET(&servAddr, 0, sizeof(servAddr)); servAddr.sin_family = AF_INET; - servAddr.sin_port = htons((u_int16_t)port); + servAddr.sin_port = htons((word16)port); /* Resolve host */ entry = gethostbyname(host); @@ -1224,7 +1224,7 @@ static int SetupSocketAndListen(int* listenFd, word32 port, int doDTLS) /* Setup server address */ XMEMSET(&servAddr, 0, sizeof(servAddr)); servAddr.sin_family = AF_INET; - servAddr.sin_port = htons((u_int16_t)port); + servAddr.sin_port = htons((word16)port); servAddr.sin_addr.s_addr = INADDR_ANY; #ifdef WOLFSSL_DTLS diff --git a/tests/api.c b/tests/api.c index d72b23a6ed..39796e9313 100644 --- a/tests/api.c +++ b/tests/api.c @@ -581,6 +581,12 @@ static int testDevId = INVALID_DEVID; #define HAVE_SSL_MEMIO_TESTS_DEPENDENCIES #endif +#ifdef USE_WINDOWS_API + #define MESSAGE_TYPE_CAST char* +#else + #define MESSAGE_TYPE_CAST void* +#endif + /*----------------------------------------------------------------------------* | BIO with fixed read/write size *----------------------------------------------------------------------------*/ @@ -7457,7 +7463,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args) static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) { SOCKET_T sockfd; - SOCKET_T clientfd = -1; + SOCKET_T clientfd; word16 port; callback_functions* cbf; @@ -7579,6 +7585,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) /* do it here to detect failure */ tcp_accept(&sockfd, &clientfd, (func_args*)args, port, 0, 0, 0, 0, 1, 0, 0); + freeClientfd = 1; CloseSocket(sockfd); if (wolfSSL_set_fd(ssl, clientfd) != WOLFSSL_SUCCESS) { /*err_sys("SSL_set_fd failed");*/ @@ -7620,7 +7627,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) wolfSSL_shutdown(ssl); wolfSSL_free(ssl); ssl = NULL; CloseSocket(clientfd); - clientfd = -1; + freeClientfd = 0; count++; } @@ -7638,7 +7645,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) if (!sharedCtx) wolfSSL_CTX_free(ctx); - if (clientfd >= 0) + if (freeClientfd) CloseSocket(clientfd); #ifdef WOLFSSL_TIRTOS @@ -63335,10 +63342,10 @@ static void test_wolfSSL_dtls_plaintext_client(WOLFSSL* ssl) generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 0); /* Server should ignore this datagram */ - AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch)); + AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch)); generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 10000); /* Server should ignore this datagram */ - AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch)); + AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch)); AssertIntEQ(wolfSSL_write(ssl, msg, sizeof(msg)), sizeof(msg)); AssertIntGT(wolfSSL_read(ssl, reply, sizeof(reply)),0); @@ -63448,7 +63455,7 @@ static void test_wolfSSL_dtls12_fragments_spammer(WOLFSSL* ssl) delay.tv_nsec = 10000000; /* wait 0.01 seconds */ c32toa(seq_number, b + seq_offset); c16toa(msg_number, b + msg_offset); - ret = (int)send(fd, b, 55, 0); + ret = (int)send(fd, (MESSAGE_TYPE_CAST)b, 55, 0); nanosleep(&delay, NULL); } } @@ -63566,7 +63573,7 @@ static void test_wolfSSL_dtls_send_alert(WOLFSSL* ssl) }; fd = wolfSSL_get_fd(ssl); - ret = (int)send(fd, alert_msg, sizeof(alert_msg), 0); + ret = (int)send(fd, (MESSAGE_TYPE_CAST)alert_msg, sizeof(alert_msg), 0); AssertIntGT(ret, 0); } @@ -63637,7 +63644,7 @@ static void test_wolfSSL_send_bad_record(WOLFSSL* ssl) fd = wolfSSL_get_fd(ssl); AssertIntGE(fd, 0); - ret = (int)send(fd, bad_msg, sizeof(bad_msg), 0); + ret = (int)send(fd, (MESSAGE_TYPE_CAST)bad_msg, sizeof(bad_msg), 0); AssertIntEQ(ret, sizeof(bad_msg)); ret = wolfSSL_write(ssl, "badrecordtest", sizeof("badrecordtest")); AssertIntEQ(ret, sizeof("badrecordtest")); @@ -63959,10 +63966,10 @@ static void test_wolfSSL_dtls_send_ch(WOLFSSL* ssl) }; fd = wolfSSL_get_fd(ssl); - ret = (int)send(fd, ch_msg, sizeof(ch_msg), 0); + ret = (int)send(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0); AssertIntGT(ret, 0); /* consume the HRR otherwise handshake will fail */ - ret = (int)recv(fd, ch_msg, sizeof(ch_msg), 0); + ret = (int)recv(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0); AssertIntGT(ret, 0); } @@ -69529,7 +69536,8 @@ static int test_dtls_msg_from_other_peer(void) * !defined(SINGLE_THREADED) && !defined(NO_RSA) */ #if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_IPV6) && \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && \ - defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(WOLFSSL_NO_TLS12) + defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(WOLFSSL_NO_TLS12) \ + && !defined(USE_WINDOWS_API) static int test_dtls_ipv6_check(void) { EXPECT_DECLS; From 321611b817886f7434540e32b4ecd2cbb22ac127 Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Thu, 16 May 2024 09:22:12 -0600 Subject: [PATCH 3/4] Undeclared var --- tests/api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/api.c b/tests/api.c index 39796e9313..2031c8371c 100644 --- a/tests/api.c +++ b/tests/api.c @@ -7478,6 +7478,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) func_args* opts = (func_args*)args; int loop_count = opts->argc; int count = 0; + int freeClientfd = 0; #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); From 88640df39f3497ad98c0fb665c6be1b8df740bd5 Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Thu, 16 May 2024 09:31:20 -0600 Subject: [PATCH 4/4] Show failure log --- .github/workflows/msys2.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml index a02151f956..5f38bbc001 100644 --- a/.github/workflows/msys2.yml +++ b/.github/workflows/msys2.yml @@ -31,4 +31,5 @@ jobs: - name: build wolfSSL run: make check - name: Display log + if: always() run: cat test-suite.log