Skip to content

Commit e9d569b

Browse files
updating test case for TLS use and macro guards in posix client example
1 parent 9302eb4 commit e9d569b

File tree

7 files changed

+33
-23
lines changed

7 files changed

+33
-23
lines changed

.github/workflows/build-and-run-examples.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,29 @@ jobs:
2626
repository: wolfssl/wolfssl
2727
path: wolfssl
2828

29+
- name: Set TLS Environment Variable
30+
run: |
31+
if [ "${{ matrix.transport }}" = "tls" ] || [ "${{ matrix.transport }}" = "psk" ]; then
32+
echo "TLS=1" >> $GITHUB_ENV
33+
else
34+
echo "TLS=0" >> $GITHUB_ENV
35+
fi
36+
2937
# Build examples
3038
- name: Build POSIX server
3139
run: |
3240
if [ "${{ matrix.transport }}" = "dma" ]; then
3341
cd examples/posix/wh_posix_server && ${{ matrix.asan }} ${{ matrix.debug }} DMA=1 make -j WOLFSSL_DIR=../../../wolfssl
34-
elif [ "${{ matrix.transport }}" = "tls" ]; then
35-
cd examples/posix/wh_posix_server && ${{ matrix.asan }} ${{ matrix.debug }} TLS=1 make -j WOLFSSL_DIR=../../../wolfssl
3642
else
37-
cd examples/posix/wh_posix_server && ${{ matrix.asan }} ${{ matrix.debug }} make -j WOLFSSL_DIR=../../../wolfssl
43+
cd examples/posix/wh_posix_server && ${{ matrix.asan }} ${{ matrix.debug }} TLS=${{ env.TLS }} make -j WOLFSSL_DIR=../../../wolfssl
3844
fi
45+
3946
- name: Build POSIX client
4047
run: |
4148
if [ "${{ matrix.transport }}" = "dma" ]; then
4249
cd examples/posix/wh_posix_client && ${{ matrix.asan }} ${{ matrix.debug }} DMA=1 make -j WOLFSSL_DIR=../../../wolfssl
4350
else
44-
cd examples/posix/wh_posix_client && ${{ matrix.asan }} ${{ matrix.debug }} make -j WOLFSSL_DIR=../../../wolfssl
51+
cd examples/posix/wh_posix_client && ${{ matrix.asan }} ${{ matrix.debug }} TLS=${{ env.TLS }} make -j WOLFSSL_DIR=../../../wolfssl
4552
fi
4653
4754
# Start the server in the background

examples/posix/wh_posix_client/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ DEF += -DWC_USE_DEVID=0x57444D41 -DWC_NO_DEFAULT_DEVID
112112
CFLAGS += -DWOLFHSM_CFG_DMA
113113
else
114114
DEF += -DWC_USE_DEVID=0x5748534D
115+
endif
115116

117+
ifeq ($(TLS),1)
118+
CFLAGS += -DWOLFHSM_CFG_TLS
116119
endif
117120

118121
#wolfCrypt test/benchmark source files

examples/posix/wh_posix_client/wh_posix_client.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,18 @@ int main(int argc, char** argv)
214214
WOLFHSM_CFG_PRINTF("Using shared memory transport\n");
215215
wh_PosixClient_ExampleShmConfig(c_conf);
216216
}
217-
#ifndef WOLFHSM_CFG_NO_CRYPTO
217+
#ifdef WOLFHSM_CFG_TLS
218218
else if (strcmp(type, "tls") == 0) {
219219
WOLFHSM_CFG_PRINTF("Using TLS transport\n");
220220
wh_PosixClient_ExampleTlsConfig(c_conf);
221221
}
222-
#endif
223-
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_PSK)
222+
#if !defined(NO_PSK)
224223
else if (strcmp(type, "psk") == 0) {
225224
WOLFHSM_CFG_PRINTF("Using TLS PSK transport\n");
226225
wh_PosixClient_ExamplePskConfig(c_conf);
227226
}
228-
#endif
227+
#endif /* !NO_PSK */
228+
#endif /* WOLFHSM_CFG_TLS */
229229
#ifdef WOLFSSL_STATIC_MEMORY
230230
else if (strcmp(type, "dma") == 0) {
231231
WOLFHSM_CFG_PRINTF("Using DMA with shared memory transport\n");

examples/posix/wh_posix_client/wh_posix_client_cfg.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@
1010

1111
#include "port/posix/posix_transport_shm.h"
1212
#include "port/posix/posix_transport_tcp.h"
13-
#ifndef WOLFHSM_CFG_NO_CRYPTO
13+
#ifdef WOLFHSM_CFG_TLS
1414
#include "port/posix/posix_transport_tls.h"
1515
#endif
1616

1717
#include <string.h>
1818

1919
posixTransportShmClientContext tccShm;
2020
posixTransportTcpClientContext tccTcp;
21-
#ifndef WOLFHSM_CFG_NO_CRYPTO
21+
#ifdef WOLFHSM_CFG_TLS
2222
posixTransportTlsClientContext tccTls;
2323
#endif
2424

2525
posixTransportShmConfig shmConfig;
2626
posixTransportTcpConfig tcpConfig;
27-
#ifndef WOLFHSM_CFG_NO_CRYPTO
27+
#ifdef WOLFHSM_CFG_TLS
2828
posixTransportTlsConfig tlsConfig;
2929
#endif
3030

3131
whCommClientConfig c_comm;
3232

3333
whTransportClientCb shmCb = POSIX_TRANSPORT_SHM_CLIENT_CB;
3434
whTransportClientCb tcpCb = PTT_CLIENT_CB;
35-
#ifndef WOLFHSM_CFG_NO_CRYPTO
35+
#ifdef WOLFHSM_CFG_TLS
3636
whTransportClientCb tlsCb = PTTLS_CLIENT_CB;
3737
#endif
3838

@@ -135,7 +135,7 @@ int wh_PosixClient_ExampleTcpConfig(void* conf)
135135
return WH_ERROR_OK;
136136
}
137137

138-
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_TLS)
138+
#if defined(WOLFHSM_CFG_TLS)
139139
/* client configuration setup example for TLS transport */
140140
#undef USE_CERT_BUFFERS_2048
141141
#define USE_CERT_BUFFERS_2048
@@ -212,7 +212,7 @@ int wh_PosixClient_ExamplePskConfig(void* conf)
212212
return WH_ERROR_OK;
213213
}
214214
#endif /* NO_PSK */
215-
#endif /* WOLFHSM_CFG_NO_CRYPTO */
215+
#endif /* WOLFHSM_CFG_TLS */
216216

217217

218218
/* client configuration setup example for transport */

examples/posix/wh_posix_client/wh_posix_client_cfg.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
int wh_PosixClient_ExampleShmDmaConfig(void* c_conf);
55
int wh_PosixClient_ExampleShmConfig(void* c_conf);
66
int wh_PosixClient_ExampleTcpConfig(void* c_conf);
7-
#ifndef WOLFHSM_CFG_NO_CRYPTO
7+
#ifdef WOLFHSM_CFG_TLS
88
int wh_PosixClient_ExampleTlsConfig(void* c_conf);
9-
#endif
10-
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_PSK)
9+
#if !defined(NO_PSK)
1110
int wh_PosixClient_ExamplePskConfig(void* c_conf);
12-
#endif
11+
#endif /* !NO_PSK */
12+
#endif /* WOLFHSM_CFG_TLS */
1313
int wh_PosixClient_ExampleSetupDmaMemory(void* ctx, void* c_conf);
14-
#endif /* WH_POSIX_CLIENT_CFG_H */
14+
#endif /* WH_POSIX_CLIENT_CFG_H */

examples/posix/wh_posix_server/wh_posix_server.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static void Usage(const char* exeName)
283283
WOLFHSM_CFG_PRINTF(", psk");
284284
#endif
285285
#endif /* !defined(WOLFHSM_CFG_NO_CRYPTO) && defined(WOLFHSM_CFG_TLS) */
286-
#ifdef WOLFSSL_CFG_DMA
286+
#ifdef WOLFHSM_CFG_DMA
287287
WOLFHSM_CFG_PRINTF(", dma");
288288
#endif
289289
WOLFHSM_CFG_PRINTF("\n");
@@ -384,7 +384,7 @@ int main(int argc, char** argv)
384384
}
385385
#endif /* !defined(NO_PSK) */
386386
#endif /* !defined(WOLFHSM_CFG_NO_CRYPTO) && defined(WOLFHSM_CFG_TLS) */
387-
#ifdef WOLFSSL_CFG_DMA
387+
#ifdef WOLFHSM_CFG_DMA
388388
else if (strcmp(type, "dma") == 0) {
389389
WOLFHSM_CFG_PRINTF("Using DMA with shared memory transport\n");
390390
rc = wh_PosixServer_ExampleShmDmaConfig(s_conf);
@@ -393,7 +393,7 @@ int main(int argc, char** argv)
393393
return -1;
394394
}
395395
}
396-
#endif /* WOLFSSL_CFG_DMA */
396+
#endif /* WOLFHSM_CFG_DMA */
397397
else {
398398
WOLFHSM_CFG_PRINTF("Invalid server type: %s\n", type);
399399
return -1;

examples/posix/wh_posix_server/wh_posix_server_cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ whTransportServerCb tlsCb = PTTLS_SERVER_CB;
3636
posixTransportTlsServerContext tscTls;
3737
#endif
3838

39-
#ifdef WOLFSSL_CFG_DMA
39+
#ifdef WOLFHSM_CFG_DMA
4040
whTransportServerCb dmaCb = POSIX_TRANSPORT_SHM_SERVER_CB;
4141
posixTransportShmServerContext tscDma;
4242
whServerDmaConfig dmaConfig;

0 commit comments

Comments
 (0)