diff --git a/.github/workflows/singlethread-check.yml b/.github/workflows/singlethread-check.yml new file mode 100644 index 000000000..af56fe7e9 --- /dev/null +++ b/.github/workflows/singlethread-check.yml @@ -0,0 +1,75 @@ +name: Single-thread Check Test + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + WOLFSSL_REF: v5.7.0-stable + +jobs: + build_wolfssl: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest ] + name: Build wolfssl + runs-on: ${{ matrix.os }} + timeout-minutes: 4 + steps: + - name: Checking cache for wolfssl + uses: actions/cache@v4 + id: cache-wolfssl + with: + path: build-dir/ + key: wolfssh-singlethread-check-wolfssl-${{ env.WOLFSSL_REF }}-${{ matrix.os }} + lookup-only: true + + - name: Checkout, build, and install wolfssl + if: steps.cache-wolfssl.outputs.cache-hit != 'true' + uses: wolfSSL/actions-build-autotools-project@v1 + with: + repository: wolfssl/wolfssl + ref: ${{ env.WOLFSSL_REF }} + path: wolfssl + configure: --enable-wolfssh --enable-singlethreaded --enable-keygen + check: false + install: true + + build_wolfssh: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest ] + config: [ + '', + '--enable-all', + '--enable-sftp', + '--enable-scp', + '--enable-shell', + ] + name: Build wolfssh + runs-on: ${{ matrix.os }} + timeout-minutes: 4 + needs: build_wolfssl + steps: + - name: Checking cache for wolfssl + uses: actions/cache@v4 + with: + path: build-dir/ + key: wolfssh-singlethread-check-wolfssl-${{ env.WOLFSSL_REF }}-${{ matrix.os }} + fail-on-cache-miss: true + + - name: Checkout, build, and test wolfssh + uses: wolfSSL/actions-build-autotools-project@v1 + with: + repository: wolfssl/wolfssh + path: wolfssh + configure: ${{ matrix.config }} LDFLAGS="-L${{ github.workspace }}/build-dir/lib" CPPFLAGS="-I${{ github.workspace }}/build-dir/include" + check: true diff --git a/apps/wolfssh/wolfssh.c b/apps/wolfssh/wolfssh.c index 1bc34b39e..c22f5046b 100644 --- a/apps/wolfssh/wolfssh.c +++ b/apps/wolfssh/wolfssh.c @@ -106,14 +106,6 @@ static const char* caCert = NULL; #endif -#if defined(WOLFSSH_AGENT) -static inline void ato32(const byte* c, word32* u32) -{ - *u32 = (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3]; -} -#endif - - static int NonBlockSSH_connect(WOLFSSH* ssh) { int ret; @@ -215,6 +207,13 @@ static void modes_reset(void) #if !defined(SINGLE_THREADED) && !defined(WOLFSSL_NUCLEUS) +#if defined(WOLFSSH_AGENT) +static inline void ato32(const byte* c, word32* u32) +{ + *u32 = (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3]; +} +#endif + typedef struct thread_args { WOLFSSH* ssh; wolfSSL_Mutex lock; @@ -1023,14 +1022,14 @@ static THREAD_RETURN WOLFSSH_THREAD wolfSSH_Client(void* args) if (ret != WS_SUCCESS) err_sys("Couldn't connect SSH stream."); + MODES_CLEAR(); + #if !defined(SINGLE_THREADED) && !defined(WOLFSSL_NUCLEUS) #if 0 if (keepOpen) /* set up for psuedo-terminal */ ClientSetEcho(2); #endif - MODES_CLEAR(); - if (config.command != NULL || keepOpen == 1) { #if defined(_POSIX_THREADS) thread_args arg; diff --git a/tests/api.c b/tests/api.c index e5600a389..69ce7b87b 100644 --- a/tests/api.c +++ b/tests/api.c @@ -38,8 +38,9 @@ #ifdef WOLFSSH_SFTP #define WOLFSSH_TEST_LOCKING - #define WOLFSSH_TEST_THREADING - + #ifndef SINGLE_THREADED + #define WOLFSSH_TEST_THREADING + #endif #define WOLFSSH_TEST_SERVER #define WOLFSSH_TEST_ECHOSERVER #endif diff --git a/tests/sftp.c b/tests/sftp.c index 75ab904ea..d292bd9bd 100644 --- a/tests/sftp.c +++ b/tests/sftp.c @@ -23,6 +23,11 @@ #endif #include +#ifdef WOLFSSL_USER_SETTINGS + #include +#else + #include +#endif #include #if defined(WOLFSSH_SFTP) && !defined(SINGLE_THREADED) diff --git a/tests/testsuite.c b/tests/testsuite.c index 4914cc29c..6ab4a8507 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -22,12 +22,6 @@ #include #endif -#define WOLFSSH_TEST_CLIENT -#define WOLFSSH_TEST_SERVER -#define WOLFSSH_TEST_THREADING -#define WOLFSSH_TEST_LOCKING - - #include #ifdef WOLFSSL_USER_SETTINGS @@ -36,6 +30,13 @@ #include #endif +#define WOLFSSH_TEST_CLIENT +#define WOLFSSH_TEST_SERVER +#ifndef SINGLE_THREADED + #define WOLFSSH_TEST_THREADING +#endif +#define WOLFSSH_TEST_LOCKING + #include #include #include