Migrated the first of the tests with internal knowledge
Both test_move and test_orphan needed internal knowledge which comes with the addition of the "in" attribute. This was in the plan for the test-revamp from the beginning as it really opens up the ability to write more unit-style-tests using internal knowledge of how littlefs works. More unit-style-tests should help _fix_ bugs by limiting the scope of the test and where the bug could be hiding. The "in" attribute effectively runs tests _inside_ the .c file specified, giving the test access to all static members without needed to change their visibility.
This commit is contained in:
@@ -11,6 +11,7 @@ code = '''
|
||||
'''
|
||||
|
||||
[[case]] # reentrant format
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
if (err) {
|
||||
@@ -19,7 +20,6 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
'''
|
||||
reentrant = true
|
||||
|
||||
[[case]] # invalid mount
|
||||
code = '''
|
||||
@@ -29,6 +29,8 @@ code = '''
|
||||
# TODO invalid superblock? (corrupt 1, 0)
|
||||
|
||||
[[case]] # expanding superblock
|
||||
define.BLOCK_CYCLES = [32, 33, 1]
|
||||
define.N = [10, 100, 1000]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
@@ -47,10 +49,10 @@ code = '''
|
||||
assert(strcmp(info.name, "dummy") == 0);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
'''
|
||||
define.BLOCK_CYCLES = [32, 33, 1]
|
||||
define.N = [10, 100, 1000]
|
||||
|
||||
[[case]] # expanding superblock with power cycle
|
||||
define.BLOCK_CYCLES = [32, 33, 1]
|
||||
define.N = [10, 100, 1000]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -71,10 +73,11 @@ code = '''
|
||||
assert(strcmp(info.name, "dummy") == 0);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
'''
|
||||
define.BLOCK_CYCLES = [32, 33, 1]
|
||||
define.N = [10, 100, 1000]
|
||||
|
||||
[[case]] # reentrant expanding superblock
|
||||
define.BLOCK_CYCLES = [2, 1]
|
||||
define.N = 24
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
if (err) {
|
||||
@@ -100,6 +103,3 @@ code = '''
|
||||
assert(strcmp(info.name, "dummy") == 0);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
'''
|
||||
define.BLOCK_CYCLES = [2, 1]
|
||||
define.N = 24
|
||||
reentrant = true
|
||||
|
||||
Reference in New Issue
Block a user