1 /*
2  * Copyright (c) 2018 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /*
8  * @filesystem
9  * @brief test_filesystem
10  * Demonstrates the ZEPHYR File System APIs
11  */
12 
13 #include "test_fat.h"
14 #include <ff.h>
15 
16 /* FatFs work area */
17 static FATFS fat_fs;
18 static FATFS fat_fs1;
19 
20 /* mounting info */
21 static struct fs_mount_t fatfs_mnt = {
22 	.type = FS_FATFS,
23 	.mnt_point = FATFS_MNTP,
24 	.fs_data = &fat_fs,
25 };
26 
27 /* mounting info */
28 static struct fs_mount_t fatfs_mnt1 = {
29 	.type = FS_FATFS,
30 	.mnt_point = FATFS_MNTP1,
31 	.fs_data = &fat_fs1,
32 };
33 
test_mount(struct fs_mount_t * mnt)34 static int test_mount(struct fs_mount_t *mnt)
35 {
36 	int res;
37 
38 	res = fs_mount(mnt);
39 	if (res < 0) {
40 		TC_PRINT("Error mounting fs [%d]\n", res);
41 		return TC_FAIL;
42 	}
43 
44 	return TC_PASS;
45 }
46 
test_fat_mount(void)47 void test_fat_mount(void)
48 {
49 	TC_PRINT("Mounting %s\n", FATFS_MNTP);
50 	zassert_true(test_mount(&fatfs_mnt) == TC_PASS);
51 
52 	TC_PRINT("Mounting %s\n", FATFS_MNTP1);
53 	zassert_true(test_mount(&fatfs_mnt1) == TC_PASS);
54 }
55