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:
@@ -115,8 +115,8 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size);
|
|||||||
BENCH_DEFINE(BLOCK_SIZE, 4096 ) \
|
BENCH_DEFINE(BLOCK_SIZE, 4096 ) \
|
||||||
BENCH_DEFINE(BLOCK_COUNT, DISK_SIZE/BLOCK_SIZE ) \
|
BENCH_DEFINE(BLOCK_COUNT, DISK_SIZE/BLOCK_SIZE ) \
|
||||||
BENCH_DEFINE(DISK_SIZE, 1024*1024 ) \
|
BENCH_DEFINE(DISK_SIZE, 1024*1024 ) \
|
||||||
BENCH_DEFINE(RCACHE_SIZE, lfs_max(16, READ_SIZE) ) \
|
BENCH_DEFINE(RCACHE_SIZE, LFS_MAX(16, READ_SIZE) ) \
|
||||||
BENCH_DEFINE(PCACHE_SIZE, lfs_max(16, PROG_SIZE) ) \
|
BENCH_DEFINE(PCACHE_SIZE, LFS_MAX(16, PROG_SIZE) ) \
|
||||||
BENCH_DEFINE(FBUFFER_SIZE, 16 ) \
|
BENCH_DEFINE(FBUFFER_SIZE, 16 ) \
|
||||||
BENCH_DEFINE(LOOKAHEAD_SIZE, 16 ) \
|
BENCH_DEFINE(LOOKAHEAD_SIZE, 16 ) \
|
||||||
BENCH_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \
|
BENCH_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size);
|
|||||||
TEST_DEFINE(BLOCK_SIZE, 4096 ) \
|
TEST_DEFINE(BLOCK_SIZE, 4096 ) \
|
||||||
TEST_DEFINE(BLOCK_COUNT, DISK_SIZE/BLOCK_SIZE ) \
|
TEST_DEFINE(BLOCK_COUNT, DISK_SIZE/BLOCK_SIZE ) \
|
||||||
TEST_DEFINE(DISK_SIZE, 1024*1024 ) \
|
TEST_DEFINE(DISK_SIZE, 1024*1024 ) \
|
||||||
TEST_DEFINE(RCACHE_SIZE, lfs_max(16, READ_SIZE) ) \
|
TEST_DEFINE(RCACHE_SIZE, LFS_MAX(16, READ_SIZE) ) \
|
||||||
TEST_DEFINE(PCACHE_SIZE, lfs_max(16, PROG_SIZE) ) \
|
TEST_DEFINE(PCACHE_SIZE, LFS_MAX(16, PROG_SIZE) ) \
|
||||||
TEST_DEFINE(FBUFFER_SIZE, 16 ) \
|
TEST_DEFINE(FBUFFER_SIZE, 16 ) \
|
||||||
TEST_DEFINE(LOOKAHEAD_SIZE, 16 ) \
|
TEST_DEFINE(LOOKAHEAD_SIZE, 16 ) \
|
||||||
TEST_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \
|
TEST_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \
|
||||||
|
|||||||
+5
-5
@@ -10,7 +10,7 @@
|
|||||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||||
code = '''
|
code = '''
|
||||||
uint8_t buffer[lfs_max(READ, PROG)];
|
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||||
|
|
||||||
// write data
|
// write data
|
||||||
CFG->erase(CFG, 0) => 0;
|
CFG->erase(CFG, 0) => 0;
|
||||||
@@ -35,7 +35,7 @@ code = '''
|
|||||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||||
code = '''
|
code = '''
|
||||||
uint8_t buffer[lfs_max(READ, PROG)];
|
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||||
lfs_block_t block;
|
lfs_block_t block;
|
||||||
|
|
||||||
// write block 0
|
// write block 0
|
||||||
@@ -93,7 +93,7 @@ code = '''
|
|||||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||||
code = '''
|
code = '''
|
||||||
uint8_t buffer[lfs_max(READ, PROG)];
|
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||||
lfs_block_t block;
|
lfs_block_t block;
|
||||||
|
|
||||||
// write block 0
|
// write block 0
|
||||||
@@ -151,7 +151,7 @@ code = '''
|
|||||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||||
code = '''
|
code = '''
|
||||||
uint8_t buffer[lfs_max(READ, PROG)];
|
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||||
|
|
||||||
// write/read every power of 2
|
// write/read every power of 2
|
||||||
lfs_block_t block = 1;
|
lfs_block_t block = 1;
|
||||||
@@ -197,7 +197,7 @@ code = '''
|
|||||||
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
defines.READ = ['READ_SIZE', 'BLOCK_SIZE']
|
||||||
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
defines.PROG = ['PROG_SIZE', 'BLOCK_SIZE']
|
||||||
code = '''
|
code = '''
|
||||||
uint8_t buffer[lfs_max(READ, PROG)];
|
uint8_t buffer[LFS_MAX(READ, PROG)];
|
||||||
|
|
||||||
// write/read every fibonacci number on our device
|
// write/read every fibonacci number on our device
|
||||||
lfs_block_t block = 1;
|
lfs_block_t block = 1;
|
||||||
|
|||||||
+18
-18
@@ -12,7 +12,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.SYNC = [false, true]
|
defines.SYNC = [false, true]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -212,7 +212,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
reentrant = true
|
reentrant = true
|
||||||
code = '''
|
code = '''
|
||||||
// format once per test
|
// format once per test
|
||||||
@@ -376,7 +376,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.SYNC = [false, true]
|
defines.SYNC = [false, true]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -566,7 +566,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.SYNC = [false, true]
|
defines.SYNC = [false, true]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -755,7 +755,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.SYNC = [false, true]
|
defines.SYNC = [false, true]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -1073,7 +1073,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfsr_format(&lfs, CFG) => 0;
|
lfsr_format(&lfs, CFG) => 0;
|
||||||
@@ -1182,7 +1182,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
# SYNC=0x1 => sync before orphaning
|
# SYNC=0x1 => sync before orphaning
|
||||||
# SYNC=0x2 => sync after orphaning
|
# SYNC=0x2 => sync after orphaning
|
||||||
defines.SYNC = [0, 1, 2, 3]
|
defines.SYNC = [0, 1, 2, 3]
|
||||||
@@ -1461,7 +1461,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfsr_format(&lfs, CFG) => 0;
|
lfsr_format(&lfs, CFG) => 0;
|
||||||
@@ -2143,7 +2143,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfsr_format(&lfs, CFG) => 0;
|
lfsr_format(&lfs, CFG) => 0;
|
||||||
@@ -2270,7 +2270,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfsr_format(&lfs, CFG) => 0;
|
lfsr_format(&lfs, CFG) => 0;
|
||||||
@@ -2397,7 +2397,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.SYNC = [false, true]
|
defines.SYNC = [false, true]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -2623,7 +2623,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.SYNC = [false, true]
|
defines.SYNC = [false, true]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -2849,7 +2849,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.SYNC = [false, true]
|
defines.SYNC = [false, true]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -3110,7 +3110,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.SYNC = [false, true]
|
defines.SYNC = [false, true]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -4403,7 +4403,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.EXISTS = [false, true]
|
defines.EXISTS = [false, true]
|
||||||
defines.INTERDIR = [false, true]
|
defines.INTERDIR = [false, true]
|
||||||
defines.DISTANCE = [0, 1, 100]
|
defines.DISTANCE = [0, 1, 100]
|
||||||
@@ -4639,7 +4639,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.EXISTS = [false, true]
|
defines.EXISTS = [false, true]
|
||||||
defines.INTERDIR = [false, true]
|
defines.INTERDIR = [false, true]
|
||||||
defines.DISTANCE = [0, 1, 100]
|
defines.DISTANCE = [0, 1, 100]
|
||||||
@@ -4935,7 +4935,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.EXISTS = [false, true]
|
defines.EXISTS = [false, true]
|
||||||
defines.INTERDIR = [false, true]
|
defines.INTERDIR = [false, true]
|
||||||
defines.DISTANCE = [0, 1, 100]
|
defines.DISTANCE = [0, 1, 100]
|
||||||
@@ -5280,7 +5280,7 @@ defines.SIZE = [
|
|||||||
'2*BLOCK_SIZE',
|
'2*BLOCK_SIZE',
|
||||||
'4*BLOCK_SIZE',
|
'4*BLOCK_SIZE',
|
||||||
]
|
]
|
||||||
defines.CHUNK = 'lfs_min(64, SIZE)'
|
defines.CHUNK = 'LFS_MIN(64, SIZE)'
|
||||||
defines.EXISTS = [false, true]
|
defines.EXISTS = [false, true]
|
||||||
defines.INTERDIR = [false, true]
|
defines.INTERDIR = [false, true]
|
||||||
defines.DISTANCE = [0, 1, 100]
|
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!
|
// 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
|
// but we don't lose power in this test so we can assert the magic string
|
||||||
// is present in both
|
// is present in both
|
||||||
uint8_t magic[lfs_max(16, READ_SIZE)];
|
uint8_t magic[LFS_MAX(16, READ_SIZE)];
|
||||||
CFG->read(CFG, 0, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
CFG->read(CFG, 0, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||||
assert(memcmp(&magic[8], "littlefs", 8) == 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);
|
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!
|
// 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
|
// but we don't lose power in this test so we can assert the magic string
|
||||||
// is present in both
|
// is present in both
|
||||||
uint8_t magic[lfs_max(16, READ_SIZE)];
|
uint8_t magic[LFS_MAX(16, READ_SIZE)];
|
||||||
CFG->read(CFG, 0, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
CFG->read(CFG, 0, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||||
assert(memcmp(&magic[8], "littlefs", 8) == 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);
|
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!
|
// 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
|
// but we don't lose power in this test so we can assert the magic string
|
||||||
// is present in both
|
// is present in both
|
||||||
uint8_t magic[lfs_max(16, READ_SIZE)];
|
uint8_t magic[LFS_MAX(16, READ_SIZE)];
|
||||||
CFG->read(CFG, 0, 0, magic, lfs_max(16, READ_SIZE)) => 0;
|
CFG->read(CFG, 0, 0, magic, LFS_MAX(16, READ_SIZE)) => 0;
|
||||||
assert(memcmp(&magic[8], "littlefs", 8) == 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);
|
assert(memcmp(&magic[8], "littlefs", 8) == 0);
|
||||||
'''
|
'''
|
||||||
|
|||||||
Reference in New Issue
Block a user