1 /* 2 * Copyright (c) 2020 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <stdint.h> 8 #include <stdio.h> 9 #include <zephyr/device.h> 10 #include <zephyr/fs/fs.h> 11 #include <zephyr/ztest.h> 12 #include <zephyr/fs/littlefs.h> 13 #include "test_fs_shell.h" 14 15 #if !defined(CONFIG_FILE_SYSTEM_SHELL) 16 FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); 17 18 #define TEST_PARTITION storage_partition 19 #define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) 20 21 struct fs_mount_t littlefs_mnt = { 22 .type = FS_LITTLEFS, 23 .fs_data = &storage, 24 .storage_dev = (void *)TEST_PARTITION_ID, 25 .mnt_point = "/littlefs" 26 }; 27 test_mount(void)28static int test_mount(void) 29 { 30 int res; 31 32 res = fs_mount(&littlefs_mnt); 33 if (res < 0) { 34 TC_PRINT("Error mounting littlefs [%d]\n", res); 35 return TC_FAIL; 36 } 37 38 return TC_PASS; 39 } 40 #endif 41 test_littlefs_mount(void)42void test_littlefs_mount(void) 43 { 44 #ifdef CONFIG_FILE_SYSTEM_SHELL 45 test_fs_littlefs_mount(); 46 #else 47 zassert_true(test_mount() == TC_PASS); 48 #endif 49 } 50