mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			65 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| /// AUTOGENERATED TEST ///
 | |
| #include "lfs.h"
 | |
| #include "emubd/lfs_emubd.h"
 | |
| #include <stdio.h>
 | |
| #include <string.h>
 | |
| #include <stdlib.h>
 | |
| 
 | |
| 
 | |
| // test stuff
 | |
| void test_log(const char *s, uintmax_t v) {{
 | |
|     printf("%s: %jd\n", s, v);
 | |
| }}
 | |
| 
 | |
| void test_assert(const char *file, unsigned line,
 | |
|         const char *s, uintmax_t v, uintmax_t e) {{
 | |
|     static const char *last[2] = {{0, 0}};
 | |
|     if (v != e || !(last[0] == s || last[1] == s)) {{
 | |
|         test_log(s, v);
 | |
|         last[0] = last[1];
 | |
|         last[1] = s;
 | |
|     }}
 | |
| 
 | |
|     if (v != e) {{
 | |
|         printf("\033[31m%s:%u: assert %s failed, expected %jd\033[0m\n",
 | |
|                 file, line, s, e);
 | |
|         exit(-2);
 | |
|     }}
 | |
| }}
 | |
| 
 | |
| #define test_assert(s, v, e) test_assert(__FILE__, __LINE__, s, v, e)
 | |
| 
 | |
| 
 | |
| // lfs declarations
 | |
| lfs_t lfs;
 | |
| lfs_emubd_t bd;
 | |
| lfs_file_t file[4];
 | |
| lfs_dir_t dir[4];
 | |
| struct lfs_bd_info bd_info;
 | |
| struct lfs_bd_stats bd_stats;
 | |
| struct lfs_info info;
 | |
| 
 | |
| uint8_t buffer[1024];
 | |
| uint8_t wbuffer[1024];
 | |
| uint8_t rbuffer[1024];
 | |
| lfs_size_t size;
 | |
| lfs_size_t wsize;
 | |
| lfs_size_t rsize;
 | |
| 
 | |
| uintmax_t res;
 | |
| 
 | |
| const struct lfs_config config = {{
 | |
|     .bd = &bd,
 | |
|     .bd_ops = &lfs_emubd_ops,
 | |
| }};
 | |
| 
 | |
| 
 | |
| // Entry point
 | |
| int main() {{
 | |
|     lfs_emubd_create(&bd, "blocks");
 | |
| 
 | |
| {tests}
 | |
| 
 | |
|     lfs_emubd_destroy(&bd);
 | |
| }}
 |