mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	The main issue here was that the old orphan test relied on deleting the block that contained the most recent update. In the new design this doesn't really work since updates get appended to metadata-pairs incrementally. This is fixed by instead using the truncate command on the appropriate block. We're now passing orphan tests.
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| set -eu
 | |
| 
 | |
| echo "=== Orphan tests ==="
 | |
| rm -rf blocks
 | |
| tests/test.py << TEST
 | |
|     lfs_format(&lfs, &cfg) => 0;
 | |
| TEST
 | |
| 
 | |
| echo "--- Orphan test ---"
 | |
| tests/test.py << TEST
 | |
|     lfs_mount(&lfs, &cfg) => 0;
 | |
|     lfs_mkdir(&lfs, "parent") => 0;
 | |
|     lfs_mkdir(&lfs, "parent/orphan") => 0;
 | |
|     lfs_mkdir(&lfs, "parent/child") => 0;
 | |
|     lfs_remove(&lfs, "parent/orphan") => 0;
 | |
| TEST
 | |
| # corrupt most recent commit, this should be the update to the previous
 | |
| # linked-list entry and should orphan the child
 | |
| truncate -s-14 blocks/8
 | |
| tests/test.py  << TEST
 | |
|     lfs_mount(&lfs, &cfg) => 0;
 | |
| 
 | |
|     lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
 | |
|     lfs_ssize_t before = lfs_fs_size(&lfs);
 | |
|     before => 10;
 | |
| 
 | |
|     lfs_unmount(&lfs) => 0;
 | |
|     lfs_mount(&lfs, &cfg) => 0;
 | |
| 
 | |
|     lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
 | |
|     lfs_ssize_t orphaned = lfs_fs_size(&lfs);
 | |
|     orphaned => 10;
 | |
| 
 | |
|     lfs_mkdir(&lfs, "parent/otherchild") => 0;
 | |
| 
 | |
|     lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
 | |
|     lfs_ssize_t deorphaned = lfs_fs_size(&lfs);
 | |
|     deorphaned => 10;
 | |
| 
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| TEST
 | |
| 
 | |
| echo "--- Results ---"
 | |
| tests/stats.py
 |