mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-01 00:38:29 +01:00
While ECORRUPT is not a wrong error code, it doesn't match other instances of hitting a corrupt block during write. During writes, if blocks are detected as corrupt their data is evicted and moved to a new clean block. This means that at the end of a disk's lifetime, exhaustion errors will be reported as ENOSPC when littlefs can't find any new block to store the data. This has the benefit of matching behaviour when a new file is written and no more blocks can be found, due to either a small disk or corrupted blocks on disk. To littlefs it's like the disk shrinks in size over time.
52 lines
1.0 KiB
Bash
Executable File
52 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eu
|
|
|
|
echo "=== Formatting tests ==="
|
|
rm -rf blocks
|
|
|
|
echo "--- Basic formatting ---"
|
|
tests/test.py << TEST
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
TEST
|
|
|
|
echo "--- Basic mounting ---"
|
|
tests/test.py << TEST
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
TEST
|
|
tests/test.py << TEST
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
TEST
|
|
|
|
echo "--- Invalid superblocks ---"
|
|
ln -f -s /dev/zero blocks/0
|
|
ln -f -s /dev/zero blocks/1
|
|
tests/test.py << TEST
|
|
lfs_format(&lfs, &cfg) => LFS_ERR_NOSPC;
|
|
TEST
|
|
rm blocks/0 blocks/1
|
|
|
|
echo "--- Invalid mount ---"
|
|
tests/test.py << TEST
|
|
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
|
TEST
|
|
|
|
echo "--- Expanding superblock ---"
|
|
tests/test.py << TEST
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
for (int i = 0; i < 100; i++) {
|
|
lfs_mkdir(&lfs, "dummy") => 0;
|
|
lfs_remove(&lfs, "dummy") => 0;
|
|
}
|
|
lfs_unmount(&lfs) => 0;
|
|
TEST
|
|
tests/test.py << TEST
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_mkdir(&lfs, "dummy") => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
TEST
|
|
|
|
echo "--- Results ---"
|
|
tests/stats.py
|