mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Increased testing to include geometries that can't be fully tested
This is primarily to get better test coverage over devices with very large erase/prog/read sizes. The unfortunate state of the tests is that most of them rely on a specific block device size, so that ENOSPC and ECORRUPT errors occur in specific situations. This should be improved in the future, but at least for now we can open up some of the simpler tests to run on these different configurations. Also added testing over both 0x00 and 0xff erase values in emubd. Also added a number of small file tests that expose issues prevalent on NAND devices.
This commit is contained in:
		
							
								
								
									
										12
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -23,8 +23,20 @@ script: | ||||
|   - make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD_SIZE=256" | ||||
|  | ||||
|   - make clean test QUIET=1 CFLAGS+="-DLFS_INLINE_MAX=0" | ||||
|   - make clean test QUIET=1 CFLAGS+="-DLFS_EMUBD_ERASE_VALUE=0xff" | ||||
|   - make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS" | ||||
|  | ||||
|   # additional configurations that don't support all tests (this should be | ||||
|   # fixed but at the moment it is what it is) | ||||
|   - make test_files QUIET=1 | ||||
|         CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_BLOCK_SIZE=4096" | ||||
|   - make test_files QUIET=1 | ||||
|         CFLAGS+="-DLFS_READ_SIZE=\(2*1024\) -DLFS_BLOCK_SIZE=\(64*1024\)" | ||||
|   - make test_files QUIET=1 | ||||
|         CFLAGS+="-DLFS_READ_SIZE=\(8*1024\) -DLFS_BLOCK_SIZE=\(64*1024\)" | ||||
|   - make test_files QUIET=1 | ||||
|         CFLAGS+="-DLFS_READ_SIZE=11 -DLFS_BLOCK_SIZE=704" | ||||
|  | ||||
|   # compile and find the code size with the smallest configuration | ||||
|   - make clean size | ||||
|         OBJ="$(ls lfs*.o | tr '\n' ' ')" | ||||
|   | ||||
| @@ -83,7 +83,7 @@ int lfs_emubd_create(const struct lfs_config *cfg, const char *path) { | ||||
|     snprintf(emu->child, LFS_NAME_MAX, ".stats"); | ||||
|     FILE *f = fopen(emu->path, "r"); | ||||
|     if (!f) { | ||||
|         memset(&emu->stats, 0, sizeof(emu->stats)); | ||||
|         memset(&emu->stats, LFS_EMUBD_ERASE_VALUE, sizeof(emu->stats)); | ||||
|     } else { | ||||
|         size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f); | ||||
|         lfs_emubd_fromle32(emu); | ||||
|   | ||||
| @@ -17,20 +17,8 @@ extern "C" | ||||
|  | ||||
|  | ||||
| // Config options | ||||
| #ifndef LFS_EMUBD_READ_SIZE | ||||
| #define LFS_EMUBD_READ_SIZE 1 | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_EMUBD_PROG_SIZE | ||||
| #define LFS_EMUBD_PROG_SIZE 1 | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_EMUBD_ERASE_SIZE | ||||
| #define LFS_EMUBD_ERASE_SIZE 512 | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_EMUBD_TOTAL_SIZE | ||||
| #define LFS_EMUBD_TOTAL_SIZE 524288 | ||||
| #ifndef LFS_EMUBD_ERASE_VALUE | ||||
| #define LFS_EMUBD_ERASE_VALUE 0x00 | ||||
| #endif | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -82,7 +82,7 @@ uintmax_t test; | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_CACHE_SIZE | ||||
| #define LFS_CACHE_SIZE 64 | ||||
| #define LFS_CACHE_SIZE (64 % LFS_PROG_SIZE == 0 ? 64 : LFS_PROG_SIZE) | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_LOOKAHEAD_SIZE | ||||
|   | ||||
| @@ -135,20 +135,79 @@ tests/test.py << TEST | ||||
|     lfs_unmount(&lfs) => 0; | ||||
| TEST | ||||
|  | ||||
| echo "--- Many file test ---" | ||||
| echo "--- Many files test ---" | ||||
| tests/test.py << TEST | ||||
|     lfs_format(&lfs, &cfg) => 0; | ||||
| TEST | ||||
| tests/test.py << TEST | ||||
|     // Create 300 files of 6 bytes | ||||
|     // Create 300 files of 7 bytes | ||||
|     lfs_mount(&lfs, &cfg) => 0; | ||||
|     lfs_mkdir(&lfs, "directory") => 0; | ||||
|     for (unsigned i = 0; i < 300; i++) { | ||||
|         snprintf((char*)buffer, sizeof(buffer), "file_%03d", i); | ||||
|         lfs_file_open(&lfs, &file[0], (char*)buffer, LFS_O_WRONLY | LFS_O_CREAT) => 0; | ||||
|         size = 6; | ||||
|         memcpy(wbuffer, "Hello", size); | ||||
|         lfs_file_open(&lfs, &file[0], (char*)buffer, | ||||
|                 LFS_O_RDWR | LFS_O_CREAT | LFS_O_EXCL) => 0; | ||||
|         size = 7; | ||||
|         snprintf((char*)wbuffer, size, "Hi %03d", i); | ||||
|         lfs_file_write(&lfs, &file[0], wbuffer, size) => size; | ||||
|         lfs_file_rewind(&lfs, &file[0]) => 0; | ||||
|         lfs_file_read(&lfs, &file[0], rbuffer, size) => size; | ||||
|         memcmp(wbuffer, rbuffer, size) => 0; | ||||
|         lfs_file_close(&lfs, &file[0]) => 0; | ||||
|     } | ||||
|     lfs_unmount(&lfs) => 0; | ||||
| TEST | ||||
|  | ||||
| echo "--- Many files with flush test ---" | ||||
| tests/test.py << TEST | ||||
|     lfs_format(&lfs, &cfg) => 0; | ||||
| TEST | ||||
| tests/test.py << TEST | ||||
|     // Create 300 files of 7 bytes | ||||
|     lfs_mount(&lfs, &cfg) => 0; | ||||
|     for (unsigned i = 0; i < 300; i++) { | ||||
|         snprintf((char*)buffer, sizeof(buffer), "file_%03d", i); | ||||
|         lfs_file_open(&lfs, &file[0], (char*)buffer, | ||||
|                 LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; | ||||
|         size = 7; | ||||
|         snprintf((char*)wbuffer, size, "Hi %03d", i); | ||||
|         lfs_file_write(&lfs, &file[0], wbuffer, size) => size; | ||||
|         lfs_file_close(&lfs, &file[0]) => 0; | ||||
|  | ||||
|         snprintf((char*)buffer, sizeof(buffer), "file_%03d", i); | ||||
|         lfs_file_open(&lfs, &file[0], (char*)buffer, LFS_O_RDONLY) => 0; | ||||
|         size = 7; | ||||
|         snprintf((char*)wbuffer, size, "Hi %03d", i); | ||||
|         lfs_file_read(&lfs, &file[0], rbuffer, size) => size; | ||||
|         memcmp(wbuffer, rbuffer, size) => 0; | ||||
|         lfs_file_close(&lfs, &file[0]) => 0; | ||||
|     } | ||||
|     lfs_unmount(&lfs) => 0; | ||||
| TEST | ||||
|  | ||||
| echo "--- Many files with power cycle test ---" | ||||
| tests/test.py << TEST | ||||
|     lfs_format(&lfs, &cfg) => 0; | ||||
| TEST | ||||
| tests/test.py << TEST | ||||
|     // Create 300 files of 7 bytes | ||||
|     lfs_mount(&lfs, &cfg) => 0; | ||||
|     for (unsigned i = 0; i < 300; i++) { | ||||
|         snprintf((char*)buffer, sizeof(buffer), "file_%03d", i); | ||||
|         lfs_file_open(&lfs, &file[0], (char*)buffer, | ||||
|                 LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; | ||||
|         size = 7; | ||||
|         snprintf((char*)wbuffer, size, "Hi %03d", i); | ||||
|         lfs_file_write(&lfs, &file[0], wbuffer, size) => size; | ||||
|         lfs_file_close(&lfs, &file[0]) => 0; | ||||
|         lfs_unmount(&lfs) => 0; | ||||
|  | ||||
|         lfs_mount(&lfs, &cfg) => 0; | ||||
|         snprintf((char*)buffer, sizeof(buffer), "file_%03d", i); | ||||
|         lfs_file_open(&lfs, &file[0], (char*)buffer, LFS_O_RDONLY) => 0; | ||||
|         size = 7; | ||||
|         snprintf((char*)wbuffer, size, "Hi %03d", i); | ||||
|         lfs_file_read(&lfs, &file[0], rbuffer, size) => size; | ||||
|         memcmp(wbuffer, rbuffer, size) => 0; | ||||
|         lfs_file_close(&lfs, &file[0]) => 0; | ||||
|     } | ||||
|     lfs_unmount(&lfs) => 0; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user