Added tests over recursive mvs and limited pl testing a bit

Unfortunately the powerloss testing risks being a big time sink.
Figuring out the best scale of powerloss testing during normal testing
is probably going to be a constant balancing act.
This commit is contained in:
Christopher Haster
2023-07-24 22:30:58 -05:00
parent 56adc60a80
commit a27c7d9ddd
+215 -25
View File
@@ -412,6 +412,8 @@ code = '''
[cases.t5_dirs_mkdir_many]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
defines.REMOUNT = [false, true]
# limit powerloss testing due to time
if = '!TEST_PL || N <= 32'
reentrant = true
code = '''
// format once per test
@@ -473,6 +475,8 @@ code = '''
[cases.t5_dirs_mkdir_many_backwards]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
defines.REMOUNT = [false, true]
# limit powerloss testing due to time
if = '!TEST_PL || N <= 32'
reentrant = true
code = '''
// format once per test
@@ -534,6 +538,8 @@ code = '''
[cases.t5_dirs_mkdir_many_2layers]
defines.N = [1, 2, 4, 8, 16]
defines.REMOUNT = [false, true]
# limit powerloss testing due to time
if = '!TEST_PL || N <= 4'
reentrant = true
code = '''
// format once per test
@@ -633,6 +639,8 @@ code = '''
[cases.t5_dirs_mkdir_many_3layers]
defines.N = [1, 2, 4]
defines.REMOUNT = [false, true]
# limit powerloss testing due to time
if = '!TEST_PL || N <= 2'
reentrant = true
code = '''
// format once per test
@@ -770,6 +778,8 @@ code = '''
[cases.t5_dirs_mkdir_many_linkedlist]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.REMOUNT = [false, true]
# limit powerloss testing due to time
if = '!TEST_PL || N <= 16'
reentrant = true
code = '''
// format once per test
@@ -840,6 +850,8 @@ defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
defines.PARENT = [false, true]
defines.REMOUNT = [false, true]
defines.SEED = 'range(10)'
# limit powerloss testing due to time
if = '!TEST_PL || N <= 64'
reentrant = true
code = '''
// format once per test
@@ -1949,8 +1961,7 @@ defines.REMAINING = [64, 2, 1, 0]
defines.REMOUNT = [false, true]
if = [
'N > REMAINING',
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
'!TEST_PL || N <= 32',
]
reentrant = true
@@ -2065,8 +2076,7 @@ defines.REMAINING = [64, 2, 1, 0]
defines.REMOUNT = [false, true]
if = [
'N > REMAINING',
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
'!TEST_PL || N <= 32',
]
reentrant = true
@@ -2181,8 +2191,7 @@ defines.REMAINING = [2, 1, 0]
defines.REMOUNT = [false, true]
if = [
'N > REMAINING',
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
'!TEST_PL || N <= 4',
]
reentrant = true
@@ -2386,8 +2395,7 @@ defines.REMAINING = [2, 1, 0]
defines.REMOUNT = [false, true]
if = [
'N > REMAINING',
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
'!TEST_PL || N <= 2',
]
reentrant = true
@@ -2685,8 +2693,7 @@ defines.REMAINING = [16, 2, 1, 0]
defines.REMOUNT = [false, true]
if = [
'N > REMAINING',
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
'!TEST_PL || N <= 16',
]
reentrant = true
@@ -3311,6 +3318,62 @@ code = '''
lfsr_unmount(&lfs) => 0;
'''
### TODO make this work eventually
##
## test what happens if we try to rename root
#[cases.t5_dirs_mv_root]
#defines.REMOUNT = [false, true]
#reentrant = true
#code = '''
# // format once per test
# lfs_t lfs;
# int err = lfsr_mount(&lfs, cfg);
# if (err) {
# lfsr_format(&lfs, cfg) => 0;
# lfsr_mount(&lfs, cfg) => 0;
# }
#
# // try to rename root, which doesn't really make sense
# lfsr_rename(&lfs, "/", "notroot") => LFS_ERR_INVAL;
#
# // make a directory
# err = lfsr_mkdir(&lfs, "ardvark");
# assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
#
# // try to rename root, which doesn't really make sense
# lfsr_rename(&lfs, "/", "notroot") => LFS_ERR_INVAL;
#
# // remount?
# if (REMOUNT) {
# lfsr_unmount(&lfs) => 0;
# lfsr_mount(&lfs, cfg) => 0;
# // grm should be zero here
# assert(lfs.grm[0] == 0);
# }
#
# // and check that this didn't interfere with our original directory
# struct lfs_info info;
# lfsr_stat(&lfs, "ardvark", &info) => 0;
# assert(strcmp(info.name, "ardvark") == 0);
# assert(info.type == LFS_TYPE_DIR);
#
# lfsr_dir_t dir;
# lfsr_dir_open(&lfs, &dir, "/") => 0;
# lfsr_dir_read(&lfs, &dir, &info) => 0;
# assert(strcmp(info.name, ".") == 0);
# assert(info.type == LFS_TYPE_DIR);
# lfsr_dir_read(&lfs, &dir, &info) => 0;
# assert(strcmp(info.name, "..") == 0);
# assert(info.type == LFS_TYPE_DIR);
# lfsr_dir_read(&lfs, &dir, &info) => 0;
# assert(strcmp(info.name, "ardvark") == 0);
# assert(info.type == LFS_TYPE_DIR);
# lfsr_dir_read(&lfs, &dir, &info) => LFS_ERR_NOENT;
# lfsr_dir_close(&lfs, &dir) => 0;
#
# lfsr_unmount(&lfs) => 0;
#'''
[cases.t5_dirs_mv_siblings]
defines.REMOUNT = [false, true]
reentrant = true
@@ -3792,8 +3855,7 @@ code = '''
[cases.t5_dirs_mv_many]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
defines.REMOUNT = [false, true]
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
if = '!TEST_PL || N <= 32'
reentrant = true
code = '''
@@ -3907,8 +3969,7 @@ code = '''
[cases.t5_dirs_mv_many_backwards]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
defines.REMOUNT = [false, true]
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
if = '!TEST_PL || N <= 32'
reentrant = true
code = '''
@@ -4022,8 +4083,7 @@ code = '''
[cases.t5_dirs_mv_many_2layers]
defines.N = [1, 2, 4, 8, 16]
defines.REMOUNT = [false, true]
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
if = '!TEST_PL || N <= 4'
reentrant = true
code = '''
@@ -4222,8 +4282,7 @@ code = '''
[cases.t5_dirs_mv_many_3layers]
defines.N = [1, 2, 4]
defines.REMOUNT = [false, true]
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
if = '!TEST_PL || N <= 2'
reentrant = true
code = '''
@@ -4511,8 +4570,7 @@ code = '''
[cases.t5_dirs_mv_many_linkedlist]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.REMOUNT = [false, true]
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
# limit powerloss testing due to time
if = '!TEST_PL || N <= 16'
reentrant = true
code = '''
@@ -4792,16 +4850,14 @@ code = '''
# TODO test dir seek end idempotency
# TODO test recursive removes with seeking (test pos updates)
# Recursive here just refers to deleting entries in a directory while
# Recursive here just refers to removing entries in a directory while
# iterating over the directory
#
# This is a useful feature, but it's unintuitive that this should have
# This is a useful feature, but it's unintuitive if this should have
# well-defined behavior, so make sure to test for it
[cases.t5_dirs_rm_many_recursive]
[cases.t5_dirs_rm_recursive]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
defines.PARENT = [false, true]
# this test sort of fights against itself when powerloss testing,
# limit it to a _very_ small number of entries for this reason
if = '!TEST_PL || N <= 32'
reentrant = true
code = '''
@@ -4900,6 +4956,140 @@ code = '''
lfsr_unmount(&lfs) => 0;
'''
# Recursive here just refers to renaming entries in a directory while
# iterating over the directory
#
# This is a useful feature, but it's unintuitive if this should have
# well-defined behavior, so make sure to test for it
[cases.t5_dirs_mv_recursive]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
defines.PARENT = [false, true]
if = '!TEST_PL || N <= 32'
reentrant = true
code = '''
// format once per test
lfs_t lfs;
int err = lfsr_mount(&lfs, cfg);
if (err) {
lfsr_format(&lfs, cfg) => 0;
lfsr_mount(&lfs, cfg) => 0;
}
if (PARENT) {
err = lfsr_mkdir(&lfs, "pricklypear");
assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
err = lfsr_mkdir(&lfs, "quiabentia");
assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
}
// check if we have already started renaming, in case of powerloss
struct lfs_info info;
err = lfsr_stat(&lfs,
(PARENT ? "quiabentia/mved0000" : "/mved0000"), &info);
if (err == LFS_ERR_NOENT) {
// make this many directories
for (lfs_size_t i = 0; i < N; i++) {
char name[256];
sprintf(name, "%s/dir%04d", (PARENT ? "pricklypear" : ""), i);
err = lfsr_mkdir(&lfs, name);
assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
}
// check that our mkdir worked
for (lfs_size_t i = 0; i < N; i++) {
char name[256];
sprintf(name, "%s/dir%04d", (PARENT ? "pricklypear" : ""), i);
struct lfs_info info;
lfsr_stat(&lfs, name, &info) => 0;
char name2[256];
sprintf(name2, "dir%04d", i);
assert(strcmp(info.name, name2) == 0);
assert(info.type == LFS_TYPE_DIR);
}
lfsr_dir_t dir;
lfsr_dir_open(&lfs, &dir, (PARENT ? "pricklypear" : "/")) => 0;
struct lfs_info info;
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, ".") == 0);
assert(info.type == LFS_TYPE_DIR);
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, "..") == 0);
assert(info.type == LFS_TYPE_DIR);
for (lfs_size_t i = 0; i < N; i++) {
char name[256];
sprintf(name, "dir%04d", i);
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, name) == 0);
assert(info.type == LFS_TYPE_DIR);
}
lfsr_dir_read(&lfs, &dir, &info) => LFS_ERR_NOENT;
lfsr_dir_close(&lfs, &dir) => 0;
}
// now rename directories recursively
lfsr_dir_t dir;
lfsr_dir_open(&lfs, &dir, (PARENT ? "pricklypear" : "/")) => 0;
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, ".") == 0);
assert(info.type == LFS_TYPE_DIR);
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, "..") == 0);
assert(info.type == LFS_TYPE_DIR);
for (lfs_size_t i = 0;; i++) {
int err = lfsr_dir_read(&lfs, &dir, &info);
assert(!err || err == LFS_ERR_NOENT);
if (err == LFS_ERR_NOENT || strcmp(info.name, "mved0000") == 0) {
break;
}
assert(i < N);
assert(memcmp(info.name, "dir", strlen("dir")) == 0);
assert(info.type == LFS_TYPE_DIR);
char old_path[1024];
sprintf(old_path, "%s/%s", (PARENT ? "pricklypear" : ""), info.name);
char new_path[1024];
sprintf(new_path, "%s/mved%s", (PARENT ? "quiabentia" : ""),
&info.name[strlen("dir")]);
err = lfsr_rename(&lfs, old_path, new_path);
assert(!err || (TEST_PL && err == LFS_ERR_NOENT));
}
lfsr_dir_close(&lfs, &dir) => 0;
// check that our renames worked
for (lfs_size_t i = 0; i < N; i++) {
char name[256];
sprintf(name, "%s/dir%04d", (PARENT ? "pricklypear" : ""), i);
struct lfs_info info;
lfsr_stat(&lfs, name, &info) => LFS_ERR_NOENT;
sprintf(name, "%s/mved%04d", (PARENT ? "quiabentia" : ""), i);
lfsr_stat(&lfs, name, &info) => 0;
char name2[256];
sprintf(name2, "mved%04d", i);
assert(strcmp(info.name, name2) == 0);
assert(info.type == LFS_TYPE_DIR);
}
lfsr_dir_open(&lfs, &dir, (PARENT ? "quiabentia" : "/")) => 0;
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, ".") == 0);
assert(info.type == LFS_TYPE_DIR);
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, "..") == 0);
assert(info.type == LFS_TYPE_DIR);
for (lfs_size_t i = 0; i < N; i++) {
char name[256];
sprintf(name, "mved%04d", i);
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, name) == 0);
assert(info.type == LFS_TYPE_DIR);
}
lfsr_dir_read(&lfs, &dir, &info) => LFS_ERR_NOENT;
lfsr_dir_close(&lfs, &dir) => 0;
lfsr_unmount(&lfs) => 0;
'''