1 // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 /**
18  * @file test_fatfs_common.h
19  * @brief Common routines for FAT-on-SDMMC and FAT-on-WL tests
20  */
21 
22 #define HEAP_SIZE_CAPTURE(heap_size)  \
23      heap_size = esp_get_free_heap_size();
24 
25 #define HEAP_SIZE_CHECK(heap_size, tolerance) \
26     do {\
27         size_t final_heap_size = esp_get_free_heap_size(); \
28         if (final_heap_size < heap_size - tolerance) { \
29             printf("Initial heap size: %d, final: %d, diff=%d\n", heap_size, final_heap_size, heap_size - final_heap_size); \
30         } \
31     } while(0)
32 
33 const char* fatfs_test_hello_str;
34 const char* fatfs_test_hello_str_utf;
35 
36 void test_fatfs_create_file_with_text(const char* name, const char* text);
37 
38 void test_fatfs_overwrite_append(const char* filename);
39 
40 void test_fatfs_read_file(const char* filename);
41 
42 void test_fatfs_read_file_utf_8(const char* filename);
43 
44 void test_fatfs_pread_file(const char* filename);
45 
46 void test_fatfs_pwrite_file(const char* filename);
47 
48 void test_fatfs_open_max_files(const char* filename_prefix, size_t files_count);
49 
50 void test_fatfs_lseek(const char* filename);
51 
52 void test_fatfs_truncate_file(const char* path);
53 
54 void test_fatfs_stat(const char* filename, const char* root_dir);
55 
56 void test_fatfs_utime(const char* filename, const char* root_dir);
57 
58 void test_fatfs_unlink(const char* filename);
59 
60 void test_fatfs_link_rename(const char* filename_prefix);
61 
62 void test_fatfs_concurrent(const char* filename_prefix);
63 
64 void test_fatfs_mkdir_rmdir(const char* filename_prefix);
65 
66 void test_fatfs_can_opendir(const char* path);
67 
68 void test_fatfs_opendir_readdir_rewinddir(const char* dir_prefix);
69 
70 void test_fatfs_opendir_readdir_rewinddir_utf_8(const char* dir_prefix);
71 
72 void test_fatfs_rw_speed(const char* filename, void* buf, size_t buf_size, size_t file_size, bool write);
73