Replace fuzz DENSITY with explicit OPS in tests
This sort of inverts the previous logic. Tests can still define OPS='2*N' to scale the number of ops roughly with the number of entries, but this fits better into the test framework, allows overriding, scaling can be more easily tweaked, can be swapped out with a constant (like in test_wl), etc. Also tweaked some of the related N constants/filter conditions in tests since these are now being effectively doubled... This should leave the resulting number of ops unchanged.
This commit is contained in:
+13
-13
@@ -6651,7 +6651,7 @@ code = '''
|
||||
[cases.test_forphans_orphanzombie_fuzz]
|
||||
defines.N = [1, 2, 4, 8, 16, 32, 64]
|
||||
# do more ops than files to encourage file rewrites
|
||||
defines.DENSITY = 2
|
||||
defines.OPS = '2*N'
|
||||
defines.SIZE = [
|
||||
'0',
|
||||
'FBUFFER_SIZE/2',
|
||||
@@ -6662,7 +6662,7 @@ defines.SIZE = [
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.SEED = 'range(20)'
|
||||
if = '(SIZE*N)/BLOCK_SIZE <= 32'
|
||||
if = '(SIZE*N)/BLOCK_SIZE <= 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
@@ -6684,18 +6684,18 @@ code = '''
|
||||
lfs_size_t sim_file_count = 0;
|
||||
|
||||
uint32_t prng = SEED;
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
for (lfs_size_t i = 0; i < OPS; i++) {
|
||||
nonsense:;
|
||||
// choose which operation to do
|
||||
uint8_t op = TEST_PRNG(&prng) % 5;
|
||||
|
||||
// open a new file?
|
||||
if (op == 0) {
|
||||
if (sim_file_count >= ((N+DENSITY-1) / DENSITY)) {
|
||||
if (sim_file_count >= N) {
|
||||
goto nonsense;
|
||||
}
|
||||
// choose a pseudo-random number
|
||||
lfs_size_t x = TEST_PRNG(&prng) % ((N+DENSITY-1) / DENSITY);
|
||||
lfs_size_t x = TEST_PRNG(&prng) % N;
|
||||
|
||||
// already exists?
|
||||
bool orphan = true;
|
||||
@@ -6847,7 +6847,7 @@ code = '''
|
||||
// rename to
|
||||
lfs_size_t j = TEST_PRNG(&prng) % sim_size;
|
||||
lfs_size_t x = sim[j];
|
||||
lfs_size_t y = TEST_PRNG(&prng) % ((N+DENSITY-1) / DENSITY);
|
||||
lfs_size_t y = TEST_PRNG(&prng) % N;
|
||||
uint32_t wprng = sim_prngs[j];
|
||||
|
||||
// update our sim
|
||||
@@ -6989,7 +6989,7 @@ code = '''
|
||||
[cases.test_forphans_orphanzombiedir_fuzz]
|
||||
defines.N = [1, 2, 4, 8, 16, 32, 64]
|
||||
# do more ops than files to encourage file rewrites
|
||||
defines.DENSITY = 2
|
||||
defines.OPS = '2*N'
|
||||
defines.SIZE = [
|
||||
'0',
|
||||
'FBUFFER_SIZE/2',
|
||||
@@ -7000,7 +7000,7 @@ defines.SIZE = [
|
||||
'4*BLOCK_SIZE',
|
||||
]
|
||||
defines.SEED = 'range(20)'
|
||||
if = '(SIZE*N)/BLOCK_SIZE <= 32'
|
||||
if = '(SIZE*N)/BLOCK_SIZE <= 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
@@ -7023,18 +7023,18 @@ code = '''
|
||||
lfs_size_t sim_file_count = 0;
|
||||
|
||||
uint32_t prng = SEED;
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
for (lfs_size_t i = 0; i < OPS; i++) {
|
||||
nonsense:;
|
||||
// choose which operation to do
|
||||
uint8_t op = TEST_PRNG(&prng) % 8;
|
||||
|
||||
// open a new file?
|
||||
if (op == 0) {
|
||||
if (sim_file_count >= ((N+DENSITY-1) / DENSITY)) {
|
||||
if (sim_file_count >= N) {
|
||||
goto nonsense;
|
||||
}
|
||||
// choose a pseudo-random number
|
||||
lfs_size_t x = TEST_PRNG(&prng) % ((N+DENSITY-1) / DENSITY);
|
||||
lfs_size_t x = TEST_PRNG(&prng) % N;
|
||||
|
||||
// already exists?
|
||||
bool orphan = true;
|
||||
@@ -7194,7 +7194,7 @@ code = '''
|
||||
// rename to
|
||||
lfs_size_t j = TEST_PRNG(&prng) % sim_size;
|
||||
lfs_size_t x = sim[j];
|
||||
lfs_size_t y = TEST_PRNG(&prng) % ((N+DENSITY-1) / DENSITY);
|
||||
lfs_size_t y = TEST_PRNG(&prng) % N;
|
||||
uint32_t wprng = sim_prngs[j];
|
||||
bool isdir = sim_isdirs[j];
|
||||
|
||||
@@ -7270,7 +7270,7 @@ code = '''
|
||||
// toss a directory into the mix
|
||||
} else if (op == 5) {
|
||||
// choose a pseudo-random number
|
||||
lfs_size_t x = TEST_PRNG(&prng) % ((N+DENSITY-1) / DENSITY);
|
||||
lfs_size_t x = TEST_PRNG(&prng) % N;
|
||||
|
||||
// insert into our sim, use negative numbers for dirs
|
||||
for (lfs_size_t k = 0;; k++) {
|
||||
|
||||
Reference in New Issue
Block a user