53d2b02f2a
Aside from reworking the internals of test_.py to work well with inherited TestCase classes, this also provides the two main features that were the main reason for revamping the test framework 1. ./scripts/test_.py --reentrant Runs reentrant tests (tests with reentrant=true in the .toml configuration) under gdb such that the program is killed on every call to lfs_emubd_prog or lfs_emubd_erase. Currently this just increments a number of prog/erases to skip, which means it doesn't necessarily check every possible branch of the test, but this should still provide a good coverage of power-loss tests. 2. ./scripts/test_.py --gdb Run the tests and if a failure is hit, drop into GDB. In theory this will be very useful for reproducing and debugging test failures. Note this can be combined with --reentrant to drop into GDB on the exact cycle of power-loss where the tests fail.
221 lines
6.4 KiB
TOML
221 lines
6.4 KiB
TOML
[[case]] # format
|
|
code = """
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
"""
|
|
|
|
[[case]] # mount/unmount
|
|
code = """
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
"""
|
|
|
|
[[case]] # reentrant format
|
|
code = """
|
|
int err = lfs_mount(&lfs, &cfg);
|
|
if (err) {
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
}
|
|
lfs_unmount(&lfs) => 0;
|
|
"""
|
|
reentrant = true
|
|
|
|
[[case]] # root
|
|
code = """
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, ".") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, "..") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
lfs_dir_close(&lfs, &dir) => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
"""
|
|
|
|
[[case]] # directory creation
|
|
code = """
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "dir%03d", i);
|
|
lfs_mkdir(&lfs, path) => 0;
|
|
}
|
|
lfs_unmount(&lfs) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, ".") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, "..") == 0);
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "dir%03d", i);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, path) == 0);
|
|
}
|
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
lfs_dir_close(&lfs, &dir) => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
"""
|
|
define.N = 'range(0, 100, 3)'
|
|
|
|
[[case]] # directory removal
|
|
code = """
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "removeme%03d", i);
|
|
lfs_mkdir(&lfs, path) => 0;
|
|
}
|
|
lfs_unmount(&lfs) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, ".") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, "..") == 0);
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "removeme%03d", i);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, path) == 0);
|
|
}
|
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
lfs_dir_close(&lfs, &dir) => 0;
|
|
lfs_unmount(&lfs);
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "removeme%03d", i);
|
|
lfs_remove(&lfs, path) => 0;
|
|
}
|
|
lfs_unmount(&lfs);
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, ".") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, "..") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
lfs_dir_close(&lfs, &dir) => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
"""
|
|
define.N = 'range(3, 100, 11)'
|
|
|
|
[[case]] # file creation
|
|
code = """
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "file%03d", i);
|
|
lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
|
lfs_file_close(&lfs, &file) => 0;
|
|
}
|
|
lfs_unmount(&lfs) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, ".") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, "..") == 0);
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "file%03d", i);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_REG);
|
|
assert(strcmp(info.name, path) == 0);
|
|
}
|
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
lfs_dir_close(&lfs, &dir) => 0;
|
|
lfs_unmount(&lfs);
|
|
"""
|
|
define.N = 'range(3, 100, 11)'
|
|
|
|
[[case]] # file removal
|
|
code = """
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "removeme%03d", i);
|
|
lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
|
lfs_file_close(&lfs, &file) => 0;
|
|
}
|
|
lfs_unmount(&lfs) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, ".") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, "..") == 0);
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "removeme%03d", i);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_REG);
|
|
assert(strcmp(info.name, path) == 0);
|
|
}
|
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
lfs_dir_close(&lfs, &dir) => 0;
|
|
lfs_unmount(&lfs);
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
for (int i = 0; i < N; i++) {
|
|
sprintf(path, "removeme%03d", i);
|
|
lfs_remove(&lfs, path) => 0;
|
|
}
|
|
lfs_unmount(&lfs);
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, ".") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
assert(info.type == LFS_TYPE_DIR);
|
|
assert(strcmp(info.name, "..") == 0);
|
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
lfs_dir_close(&lfs, &dir) => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
"""
|
|
define.N = 'range(0, 100, 3)'
|
|
|
|
[[case]] # error cases
|
|
code = """
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_mkdir(&lfs, "potato") => 0;
|
|
lfs_file_open(&lfs, &file, "burito", LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
|
lfs_file_close(&lfs, &file) => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_mkdir(&lfs, "potato") => LFS_ERR_EXIST;
|
|
lfs_dir_open(&lfs, &dir, "tomato") => LFS_ERR_NOENT;
|
|
lfs_dir_open(&lfs, &dir, "burito") => LFS_ERR_NOTDIR;
|
|
lfs_file_open(&lfs, &file, "tomato", LFS_O_RDONLY) => LFS_ERR_NOENT;
|
|
lfs_file_open(&lfs, &file, "potato", LFS_O_RDONLY) => LFS_ERR_ISDIR;
|
|
lfs_unmount(&lfs) => 0;
|
|
"""
|