Skip to content

Commit 2b23370

Browse files
committed
Add NO_FILESYSTEM to Zephyr port
1 parent 892c26d commit 2b23370

9 files changed

Lines changed: 299 additions & 11 deletions

File tree

.github/workflows/zephyr.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
zephyr-sdk: 0.16.1
1717
runs-on: ubuntu-latest
1818
# This should be a safe limit for the tests to run.
19-
timeout-minutes: 15
19+
timeout-minutes: 20
2020
steps:
2121
- name: Install dependencies
2222
run: |
@@ -77,6 +77,8 @@ jobs:
7777
run: |
7878
./zephyr/scripts/twister --testsuite-root modules/lib/wolfssh --test zephyr/samples/tests/sample.lib.wolfssh_tests -vvv
7979
rm -rf zephyr/twister-out
80+
./zephyr/scripts/twister --testsuite-root modules/lib/wolfssh --test zephyr/samples/tests/sample.lib.wolfssh_nofs_tests -vvv
81+
rm -rf zephyr/twister-out
8082
8183
- name: Zip failure logs
8284
if: ${{ failure() && steps.wolfssh-test.outcome == 'failure' }}

src/port.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ int WS_DeleteFileA(const char* fileName, void* heap)
476476

477477
#endif /* USE_WINDOWS_API WOLFSSH_SFTP WOLFSSH_SCP */
478478

479-
#if defined(WOLFSSH_ZEPHYR) && (defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP))
479+
#if !defined(NO_FILESYSTEM) && \
480+
defined(WOLFSSH_ZEPHYR) && (defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP))
480481

481482
int wssh_z_fstat(const char *p, struct fs_dirent *b)
482483
{

src/ssh.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ int wolfSSH_Init(void)
7575
#ifdef WC_RNG_SEED_CB
7676
wc_SetSeed_Cb(wc_GenerateSeed);
7777
#endif
78-
#if defined(WOLFSSH_ZEPHYR) && (defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP))
78+
#if !defined(NO_FILESYSTEM) && defined(WOLFSSH_ZEPHYR) && \
79+
(defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP))
7980
if (wssh_z_fds_init() != 0)
8081
ret = WS_CRYPTO_FAILED;
8182
#endif
@@ -93,7 +94,8 @@ int wolfSSH_Cleanup(void)
9394

9495
if (wolfCrypt_Cleanup() != 0)
9596
ret = WS_CRYPTO_FAILED;
96-
#if defined(WOLFSSH_ZEPHYR) && (defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP))
97+
#if !defined(NO_FILESYSTEM) && defined(WOLFSSH_ZEPHYR) && \
98+
(defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP))
9799
if (wssh_z_fds_cleanup() != 0)
98100
ret = WS_CRYPTO_FAILED;
99101
#endif

src/wolfscp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,9 +2845,10 @@ int wsScpRecvCallback(WOLFSSH* ssh, int state, const char* basePath,
28452845
recvBuffer->mode = fileMode;
28462846
if (recvBuffer->status) {
28472847
if (recvBuffer->status(ssh, fileName, WOLFSSH_SCP_NEW_FILE,
2848-
recvBuffer) != WS_SUCCESS)
2848+
recvBuffer) != WS_SUCCESS) {
28492849
WLOG(WS_LOG_ERROR, "scp: status of new file failed, abort");
28502850
ret = WS_SCP_ABORT;
2851+
}
28512852
}
28522853
break;
28532854

@@ -2869,9 +2870,10 @@ int wsScpRecvCallback(WOLFSSH* ssh, int state, const char* basePath,
28692870
recvBuffer->fileSz += sz;
28702871
if (recvBuffer->status) {
28712872
if (recvBuffer->status(ssh, recvBuffer->name,
2872-
WOLFSSH_SCP_FILE_PART, recvBuffer) != WS_SUCCESS)
2873+
WOLFSSH_SCP_FILE_PART, recvBuffer) != WS_SUCCESS) {
28732874
WLOG(WS_LOG_ERROR, "scp: bad status, abort");
28742875
ret = WS_SCP_ABORT;
2876+
}
28752877
}
28762878
break;
28772879

@@ -2880,9 +2882,10 @@ int wsScpRecvCallback(WOLFSSH* ssh, int state, const char* basePath,
28802882
recvBuffer->mTime = 0; /* @TODO set time if wanted */
28812883
if (recvBuffer->status) {
28822884
if (recvBuffer->status(ssh, recvBuffer->name,
2883-
WOLFSSH_SCP_FILE_DONE, recvBuffer) != WS_SUCCESS)
2885+
WOLFSSH_SCP_FILE_DONE, recvBuffer) != WS_SUCCESS) {
28842886
WLOG(WS_LOG_ERROR, "scp: bad status, abort");
28852887
ret = WS_SCP_ABORT;
2888+
}
28862889
}
28872890
break;
28882891

zephyr/samples/tests/prj_nofs.conf

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Kernel options
2+
CONFIG_MAIN_STACK_SIZE=32768
3+
CONFIG_ENTROPY_GENERATOR=y
4+
CONFIG_INIT_STACKS=y
5+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072
6+
7+
# Enable wolfSSH
8+
CONFIG_WOLFSSH=y
9+
CONFIG_WOLFSSH_SETTINGS_FILE="samples/tests/wolfssh_user_settings_nofs.h"
10+
11+
# Pthreads
12+
CONFIG_PTHREAD_IPC=y
13+
14+
# Clock for time()
15+
CONFIG_POSIX_CLOCK=y
16+
17+
# Networking
18+
CONFIG_NETWORKING=y
19+
CONFIG_NET_TEST=y
20+
CONFIG_NET_IPV4=y
21+
CONFIG_NET_IPV6=n
22+
CONFIG_NET_TCP=y
23+
CONFIG_NET_SOCKETS=y
24+
CONFIG_NET_SOCKETS_POSIX_NAMES=y
25+
26+
CONFIG_NET_TEST=y
27+
CONFIG_NET_LOOPBACK=y
28+
29+
# Network driver config
30+
CONFIG_TEST_RANDOM_GENERATOR=y
31+
32+
# Network address config
33+
CONFIG_NET_CONFIG_SETTINGS=y
34+
CONFIG_NET_CONFIG_NEED_IPV4=y
35+
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
36+
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
37+
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
38+
39+
CONFIG_NET_PKT_TX_COUNT=10
40+
41+
# Logging
42+
CONFIG_PRINTK=y
43+
CONFIG_LOG=y
44+
CONFIG_LOG_MODE_IMMEDIATE=y
45+
#CONFIG_WOLFSSH_DEBUG=y
46+
#CONFIG_WOLFSSL_DEBUG=y
47+
#CONFIG_DEBUG=y
48+
49+
# Enable logging using RTT and UART
50+
#CONFIG_CBPRINTF_LIBC_SUBSTS=y
51+
#CONFIG_CBPRINTF_FP_SUPPORT=y
52+
#CONFIG_CONSOLE=y
53+
#CONFIG_LOG_BACKEND_UART=y
54+
#CONFIG_LOG_BUFFER_SIZE=15360
55+
56+
# TLS configuration
57+
CONFIG_WOLFSSL=y
58+
CONFIG_WOLFSSL_BUILTIN=y
59+
CONFIG_WOLFSSL_SETTINGS_FILE="samples/tests/wolfssl_user_settings_nofs.h"
60+
61+
CONFIG_WOLFSSL_TLS_VERSION_1_2=y
62+
CONFIG_WOLFSSL_KEY_EXCHANGE_ALL_ENABLED=y
63+
CONFIG_WOLFSSL_CIPHER_ALL_ENABLED=y
64+
CONFIG_WOLFSSL_MAC_ALL_ENABLED=y
65+
CONFIG_WOLFSSL_HMAC_DRBG_ENABLED=y
66+

zephyr/samples/tests/sample.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ tests:
1313
platform_allow: qemu_x86
1414
integration_platforms:
1515
- qemu_x86
16+
sample.lib.wolfssh_nofs_tests:
17+
timeout: 200
18+
platform_allow: qemu_x86
19+
extra_args: CONF_FILE="prj_nofs.conf"
20+
integration_platforms:
21+
- qemu_x86

zephyr/samples/tests/tests.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@
3737
#include <stdio.h>
3838
#include <wolfssh/settings.h>
3939
#include <wolfssh/ssh.h>
40-
#include <zephyr/fs/fs.h>
41-
#include <zephyr/storage/disk_access.h>
42-
#include <ff.h>
43-
4440

41+
#ifndef NO_FILESYSTEM
4542
#ifndef CONFIG_FAT_FILESYSTEM_ELM
4643
#error "This test is designed for FAT FS"
4744
#endif
45+
#include <zephyr/fs/fs.h>
46+
#include <zephyr/storage/disk_access.h>
47+
#include <ff.h>
48+
#endif
4849

4950
#define CHECK_TEST_RETURN(func) do { \
5051
printf("\tRunning %s... ", #func); \
@@ -60,6 +61,7 @@
6061
int main(void)
6162
{
6263
int ret = 0;
64+
#ifndef NO_FILESYSTEM
6365
static FATFS fat_fs;
6466
static struct fs_mount_t mnt_point = {
6567
.type = FS_FATFS,
@@ -89,6 +91,7 @@ int main(void)
8991
< 0);
9092

9193
CHECK_TEST_RETURN(fs_close(&zfp));
94+
#endif
9295

9396
CHECK_TEST_RETURN(wolfSSH_UnitTest(0, NULL));
9497
CHECK_TEST_RETURN(wolfSSH_TestsuiteTest(0, NULL));
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* user_settings.h
2+
*
3+
* Copyright (C) 2014-2024 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSH.
6+
*
7+
* wolfSSH is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSH is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#ifndef WOLFSSH_USER_SETTINGS_H
22+
#define WOLFSSH_USER_SETTINGS_H
23+
24+
25+
#ifdef __cplusplus
26+
extern "C" {
27+
#endif
28+
29+
#include <wolfssl/wolfcrypt/types.h>
30+
31+
#undef WOLFSSH_SCP
32+
#define WOLFSSH_SCP
33+
34+
#undef NO_APITEST_MAIN_DRIVER
35+
#define NO_APITEST_MAIN_DRIVER
36+
37+
#undef NO_TESTSUITE_MAIN_DRIVER
38+
#define NO_TESTSUITE_MAIN_DRIVER
39+
40+
#undef NO_UNITTEST_MAIN_DRIVER
41+
#define NO_UNITTEST_MAIN_DRIVER
42+
43+
#undef NO_MAIN_DRIVER
44+
#define NO_MAIN_DRIVER
45+
46+
#undef WS_NO_SIGNAL
47+
#define WS_NO_SIGNAL
48+
49+
#undef WS_USE_TEST_BUFFERS
50+
#define WS_USE_TEST_BUFFERS
51+
52+
#undef NO_WOLFSSL_DIR
53+
#define NO_WOLFSSL_DIR
54+
55+
#undef WOLFSSH_NO_NONBLOCKING
56+
#define WOLFSSH_NO_NONBLOCKING
57+
58+
#define DEFAULT_WINDOW_SZ (128 * 128)
59+
#define WOLFSSH_MAX_SFTP_RW 8192
60+
61+
#undef NO_FILESYSTEM
62+
#define NO_FILESYSTEM
63+
64+
#ifdef __cplusplus
65+
}
66+
#endif
67+
68+
#endif

0 commit comments

Comments
 (0)