Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_orphan.sh « tests - github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9c2cb7b62f71a8d95818184aa6a152892b2ce0c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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
tests/corrupt.py
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 => 8;

    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 => 8;

    lfs_mkdir(&lfs, "parent/otherchild") => 0;

    lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
    lfs_ssize_t deorphaned = lfs_fs_size(&lfs);
    deorphaned => 8;

    lfs_unmount(&lfs) => 0;
TEST

echo "--- Results ---"
tests/stats.py