1 /*
2  * Copyright (c) 2018 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/fs/fs.h>
8 #include <ff.h>
9 #include "test_fs.h"
10 
11 /* FatFs work area */
12 static FATFS fat_fs;
13 
14 /* mounting info */
15 static struct fs_mount_t fatfs_mnt = {
16 	.type = FS_FATFS,
17 	.mnt_point = FATFS_MNTP,
18 	.fs_data = &fat_fs,
19 };
20 
test_mount(void)21 void *test_mount(void)
22 {
23 	int res;
24 
25 	res = fs_mount(&fatfs_mnt);
26 	if (res < 0) {
27 		TC_ERROR("Error mounting fs [%d]\n", res);
28 		/* FIXME: restructure tests as per #46897 */
29 		__ASSERT_NO_MSG(res == 0);
30 	}
31 
32 	return NULL;
33 }
34 
test_unmount(void * unused)35 void test_unmount(void *unused)
36 {
37 	int res;
38 
39 	ARG_UNUSED(unused);
40 	res = fs_unmount(&fatfs_mnt);
41 	if (res < 0) {
42 		TC_ERROR("Error unmounting fs [%d]\n", res);
43 		/* FIXME: restructure tests as per #46897 */
44 		__ASSERT_NO_MSG(res == 0);
45 	}
46 }
47 
48 /**
49  * @brief Test for File System mount operation
50  *
51  * @details Test initializes the fs_mount_t data structure with FatFs
52  * related info and calls the fs_mount API for mount the file system.
53  */
ZTEST(posix_fs_test,test_fs_mount)54 ZTEST(posix_fs_test, test_fs_mount)
55 {
56 	/* FIXME: restructure tests as per #46897 */
57 	zassert_equal(fatfs_mnt.flags, FS_MOUNT_FLAG_USE_DISK_ACCESS);
58 }
59