1 /*
2  * Copyright (c) 2016 Intel Corporation.
3  * Copyright (c) 2023 Husqvarna AB
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <time.h>
9 
10 #include "test_fat.h"
11 void test_fs_open_flags(void);
12 const char *test_fs_open_flags_file_path =  FATFS_MNTP"/the_file.txt";
13 
14 /* Time integration for filesystem */
get_fattime(void)15 DWORD get_fattime(void)
16 {
17 	time_t unix_time = time(NULL);
18 	struct tm *cal;
19 
20 	/* Convert to calendar time */
21 	cal = localtime(&unix_time);
22 
23 	/* From http://elm-chan.org/fsw/ff/doc/fattime.html */
24 	return (DWORD)(cal->tm_year - 80) << 25 | (DWORD)(cal->tm_mon + 1) << 21 |
25 	       (DWORD)cal->tm_mday << 16 | (DWORD)cal->tm_hour << 11 | (DWORD)cal->tm_min << 5 |
26 	       (DWORD)cal->tm_sec >> 1;
27 }
28 
fat_fs_basic_setup(void)29 static void *fat_fs_basic_setup(void)
30 {
31 	fs_file_t_init(&filep);
32 	test_fat_mount();
33 	test_fat_file();
34 	test_fat_dir();
35 	test_fat_fs();
36 	test_fat_rename();
37 	test_fs_open_flags();
38 #ifdef CONFIG_FS_FATFS_REENTRANT
39 	test_fat_file_reentrant();
40 #endif /* CONFIG_FS_FATFS_REENTRANT */
41 	test_fat_unmount();
42 
43 	return NULL;
44 }
45 ZTEST_SUITE(fat_fs_basic, NULL, fat_fs_basic_setup, NULL, NULL, NULL);
46