1 /*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/ztest.h>
8 #include <zephyr/fs/littlefs.h>
9 #include "testfs_tests.h"
10 #include "testfs_lfs.h"
11
12 void test_fs_open_flags(void);
13 /* Expected by test_fs_open_flags() */
14 const char *test_fs_open_flags_file_path = TESTFS_MNT_POINT_SMALL"/the_file";
15
mount(struct fs_mount_t * mp)16 static void mount(struct fs_mount_t *mp)
17 {
18 TC_PRINT("Mount %s\n", mp->mnt_point);
19
20 zassert_equal(fs_mount(mp), 0, "Failed to mount partition");
21 }
22
unmount(struct fs_mount_t * mp)23 static void unmount(struct fs_mount_t *mp)
24 {
25 TC_PRINT("Unmounting %s\n", mp->mnt_point);
26
27 zassert_equal(fs_unmount(mp), 0,
28 "Failed to unmount partition");
29 }
30
cleanup(struct fs_mount_t * mp)31 static void cleanup(struct fs_mount_t *mp)
32 {
33 TC_PRINT("Clean %s\n", mp->mnt_point);
34
35 zassert_equal(testfs_lfs_wipe_partition(mp), TC_PASS,
36 "Failed to clean partition");
37 }
38
ZTEST(littlefs,test_fs_open_flags_lfs)39 ZTEST(littlefs, test_fs_open_flags_lfs)
40
41 {
42 /* Using smallest partition for this tests as they do not write
43 * a lot of data, basically they just check flags.
44 */
45 struct fs_mount_t *mp = &testfs_small_mnt;
46
47 cleanup(mp);
48 mp->flags = 0;
49 mount(mp);
50
51 test_fs_open_flags();
52
53 unmount(mp);
54
55 }
56