Adopted compile-time LFS_MIN/LFS_MAX in test defines
These seem fitting here, even if the test defines aren't "real defines". The duplicate expressions should still be side-effect free and easy to optimize out. This should also avoid future lfs_min32 vs intmax_t issues.
This commit is contained in:
+5
-5
@@ -10,7 +10,7 @@
|
||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||
code = '''
|
||||
uint8_t buffer[lfs_max(READ, PROG)];
|
||||
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||
|
||||
// write data
|
||||
CFG->erase(CFG, 0) => 0;
|
||||
@@ -35,7 +35,7 @@ code = '''
|
||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||
code = '''
|
||||
uint8_t buffer[lfs_max(READ, PROG)];
|
||||
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||
lfs_block_t block;
|
||||
|
||||
// write block 0
|
||||
@@ -93,7 +93,7 @@ code = '''
|
||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||
code = '''
|
||||
uint8_t buffer[lfs_max(READ, PROG)];
|
||||
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||
lfs_block_t block;
|
||||
|
||||
// write block 0
|
||||
@@ -151,7 +151,7 @@ code = '''
|
||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||
code = '''
|
||||
uint8_t buffer[lfs_max(READ, PROG)];
|
||||
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||
|
||||
// write/read every power of 2
|
||||
lfs_block_t block = 1;
|
||||
@@ -197,7 +197,7 @@ code = '''
|
||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||
code = '''
|
||||
uint8_t buffer[lfs_max(READ, PROG)];
|
||||
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||
|
||||
// write/read every fibonacci number on our device
|
||||
lfs_block_t block = 1;
|
||||
|
||||
+18
-18
@@ -12,7 +12,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
@@ -212,7 +212,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
reentrant = true
|
||||
code = '''
|
||||
// format once per test
|
||||
@@ -376,7 +376,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
@@ -566,7 +566,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
@@ -755,7 +755,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
@@ -1073,7 +1073,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
@@ -1182,7 +1182,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
# SYNC=0x1 => sync before orphaning
|
||||
# SYNC=0x2 => sync after orphaning
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
@@ -1461,7 +1461,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
@@ -2143,7 +2143,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
@@ -2270,7 +2270,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
@@ -2397,7 +2397,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
@@ -2623,7 +2623,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
@@ -2849,7 +2849,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
@@ -3110,7 +3110,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
@@ -4403,7 +4403,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.EXISTS = [false, true]
|
||||
defines.INTERDIR = [false, true]
|
||||
defines.DISTANCE = [0, 1, 100]
|
||||
@@ -4639,7 +4639,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.EXISTS = [false, true]
|
||||
defines.INTERDIR = [false, true]
|
||||
defines.DISTANCE = [0, 1, 100]
|
||||
@@ -4935,7 +4935,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.EXISTS = [false, true]
|
||||
defines.INTERDIR = [false, true]
|
||||
defines.DISTANCE = [0, 1, 100]
|
||||
@@ -5280,7 +5280,7 @@ defines.SIZE = [
|
||||
'2*BLOCK_SIZE',
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
||||
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||
defines.EXISTS = [false, true]
|
||||
defines.INTERDIR = [false, true]
|
||||
defines.DISTANCE = [0, 1, 100]
|
||||
|
||||
@@ -3992,10 +3992,10 @@ code = '''
|
||||
// note if we lose power we may not have the magic string in both blocks!
|
||||
// but we don't lose power in this test so we can assert the magic string
|
||||
// is present in both
|
||||
uint8_t magic[lfs_max(16, READ_SIZE)];
|
||||
CFG->read(CFG, 0, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
||||
uint8_t magic[LFS_MAX(16, READ_SIZE)];
|
||||
CFG->read(CFG, 0, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||
assert(memcmp(&magic[8], "littlefs", 8) == 0);
|
||||
CFG->read(CFG, 1, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
||||
CFG->read(CFG, 1, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||
assert(memcmp(&magic[8], "littlefs", 8) == 0);
|
||||
'''
|
||||
|
||||
@@ -4046,10 +4046,10 @@ code = '''
|
||||
// note if we lose power we may not have the magic string in both blocks!
|
||||
// but we don't lose power in this test so we can assert the magic string
|
||||
// is present in both
|
||||
uint8_t magic[lfs_max(16, READ_SIZE)];
|
||||
CFG->read(CFG, 0, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
||||
uint8_t magic[LFS_MAX(16, READ_SIZE)];
|
||||
CFG->read(CFG, 0, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||
assert(memcmp(&magic[8], "littlefs", 8) == 0);
|
||||
CFG->read(CFG, 1, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
||||
CFG->read(CFG, 1, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||
assert(memcmp(&magic[8], "littlefs", 8) == 0);
|
||||
'''
|
||||
|
||||
@@ -4117,9 +4117,9 @@ code = '''
|
||||
// note if we lose power we may not have the magic string in both blocks!
|
||||
// but we don't lose power in this test so we can assert the magic string
|
||||
// is present in both
|
||||
uint8_t magic[lfs_max(16, READ_SIZE)];
|
||||
CFG->read(CFG, 0, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
||||
uint8_t magic[LFS_MAX(16, READ_SIZE)];
|
||||
CFG->read(CFG, 0, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||
assert(memcmp(&magic[8], "littlefs", 8) == 0);
|
||||
CFG->read(CFG, 1, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
||||
CFG->read(CFG, 1, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||
assert(memcmp(&magic[8], "littlefs", 8) == 0);
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user