tests: fs: Fix zassert strings
After introducing compile time argument validation of strings used in zassert macros multiple warnings appear. Fix all of them. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
6deca93285
commit
07a729b480
@ -25,53 +25,53 @@ void test_fs_mount_flags(void)
|
||||
mp->flags |= FS_MOUNT_FLAG_NO_FORMAT;
|
||||
ret = fs_mount(mp);
|
||||
TC_PRINT("Mount unformatted with FS_MOUNT_FLAG_NO_FORMAT set\n");
|
||||
zassert_false(ret == 0, "Expected failure", ret);
|
||||
zassert_false(ret == 0, "Expected failure got %d", ret);
|
||||
|
||||
/* Test FS_MOUNT_FLAG_READ_ONLY on non-formatted volume*/
|
||||
mp->flags = FS_MOUNT_FLAG_READ_ONLY;
|
||||
ret = fs_mount(mp);
|
||||
TC_PRINT("Mount unformatted with FS_MOUNT_FLAG_READ_ONLY set\n");
|
||||
zassert_false(ret == 0, "Expected failure", ret);
|
||||
zassert_false(ret == 0, "Expected failure got %d", ret);
|
||||
|
||||
/* Format volume and add some files/dirs to check read-only flag */
|
||||
mp->flags = 0;
|
||||
ret = fs_mount(mp);
|
||||
TC_PRINT("Mount again to format volume\n");
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
TC_PRINT("Create some file\n");
|
||||
ret = fs_open(&fs, "/sml/some", FS_O_CREATE);
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
fs_close(&fs);
|
||||
TC_PRINT("Create other directory\n");
|
||||
ret = fs_mkdir("/sml/other");
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
|
||||
ret = fs_unmount(mp);
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
|
||||
/* Check fs operation on volume mounted with FS_MOUNT_FLAG_READ_ONLY */
|
||||
mp->flags = FS_MOUNT_FLAG_READ_ONLY;
|
||||
TC_PRINT("Mount as read-only\n");
|
||||
ret = fs_mount(mp);
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
|
||||
/* Attempt creating new file */
|
||||
ret = fs_open(&fs, "/sml/nosome", FS_O_CREATE);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_mkdir("/sml/another");
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_rename("/sml/some", "/sml/nosome");
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_unlink("/sml/some");
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_open(&fs, "/sml/other", FS_O_CREATE);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_open(&fs, "/sml/some", FS_O_RDWR);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_open(&fs, "/sml/some", FS_O_READ);
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
fs_close(&fs);
|
||||
|
||||
ret = fs_unmount(mp);
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ uint32_t calculate_blocks(uint32_t freeb, uint32_t B)
|
||||
|
||||
static void write_to_file(const char *file_path, uint32_t bytes_to_write)
|
||||
{
|
||||
int64_t ret = 0;
|
||||
int ret = 0;
|
||||
struct fs_file_t file;
|
||||
struct fs_dirent entry;
|
||||
|
||||
@ -50,7 +50,7 @@ static void write_to_file(const char *file_path, uint32_t bytes_to_write)
|
||||
zassert_equal(ret, 0, "File open failed (ret=%d)", ret);
|
||||
|
||||
ret = testfs_write_incrementing(&file, 0, bytes_to_write);
|
||||
zassert_equal(ret, bytes_to_write, "Different number of bytes written %ld (expected %ld)",
|
||||
zassert_equal(ret, bytes_to_write, "Different number of bytes written %d (expected %d)",
|
||||
ret, bytes_to_write);
|
||||
|
||||
ret = fs_close(&file);
|
||||
@ -70,7 +70,7 @@ static void write_to_file(const char *file_path, uint32_t bytes_to_write)
|
||||
|
||||
|
||||
ret = testfs_verify_incrementing(&file, 0, bytes_to_write);
|
||||
zassert_equal(ret, bytes_to_write, "Different number of bytes read %ld (expected %ld)",
|
||||
zassert_equal(ret, bytes_to_write, "Different number of bytes read %d (expected %d)",
|
||||
ret, bytes_to_write);
|
||||
|
||||
ret = fs_close(&file);
|
||||
@ -79,7 +79,7 @@ static void write_to_file(const char *file_path, uint32_t bytes_to_write)
|
||||
|
||||
static void truncate_file(const char *file_path, uint32_t new_size)
|
||||
{
|
||||
int64_t ret = 0;
|
||||
int ret = 0;
|
||||
struct fs_file_t file;
|
||||
struct fs_dirent entry;
|
||||
|
||||
@ -102,7 +102,7 @@ static void truncate_file(const char *file_path, uint32_t new_size)
|
||||
zassert_equal(ret, 0, "File seek failed (ret=%d)", ret);
|
||||
|
||||
ret = testfs_verify_incrementing(&file, 0, new_size);
|
||||
zassert_equal(ret, new_size, "Different number of bytes read %ld (expected %ld)",
|
||||
zassert_equal(ret, new_size, "Different number of bytes read %d (expected %d)",
|
||||
ret, new_size);
|
||||
|
||||
ret = fs_close(&file);
|
||||
@ -111,7 +111,7 @@ static void truncate_file(const char *file_path, uint32_t new_size)
|
||||
|
||||
void writing_test(struct ext2_cfg *config)
|
||||
{
|
||||
int64_t ret = 0;
|
||||
int ret = 0;
|
||||
struct fs_statvfs sbuf;
|
||||
struct fs_mount_t *mp = &testfs_mnt;
|
||||
static const char *file_path = "/sml/file";
|
||||
@ -151,7 +151,7 @@ void writing_test(struct ext2_cfg *config)
|
||||
|
||||
ZTEST(ext2tests, test_indirect_block_removal)
|
||||
{
|
||||
int64_t ret = 0;
|
||||
int ret = 0;
|
||||
struct fs_statvfs sbuf;
|
||||
struct fs_mount_t *mp = &testfs_mnt;
|
||||
static const char *file_path = "/sml/file";
|
||||
|
||||
@ -64,11 +64,11 @@ ZTEST(ext2tests, test_statvfs)
|
||||
sbuf.f_bsize, sbuf.f_frsize, sbuf.f_blocks, sbuf.f_bfree);
|
||||
|
||||
zassert_equal(sbuf.f_bsize, 1024,
|
||||
"Wrong block size %lu (expected %lu)", sbuf.f_bsize, 1024);
|
||||
"Wrong block size %lu (expected %d)", sbuf.f_bsize, 1024);
|
||||
zassert_equal(sbuf.f_frsize, 1024,
|
||||
"Wrong frag size %lu (expected %lu)", sbuf.f_frsize, 1024);
|
||||
"Wrong frag size %lu (expected %d)", sbuf.f_frsize, 1024);
|
||||
zassert_equal(sbuf.f_blocks, partition_size / 1024,
|
||||
"Wrong block count %lu (expected %lu)",
|
||||
"Wrong block count %lu (expected %zu)",
|
||||
sbuf.f_blocks, partition_size / 1024);
|
||||
|
||||
ret = fs_unmount(mp);
|
||||
@ -115,11 +115,11 @@ void mkfs_custom_config(struct ext2_cfg *cfg)
|
||||
sbuf.f_bsize, sbuf.f_frsize, sbuf.f_blocks, sbuf.f_bfree);
|
||||
|
||||
zassert_equal(sbuf.f_bsize, cfg->block_size,
|
||||
"Wrong block size %lu (expected %lu)", sbuf.f_bsize, cfg->block_size);
|
||||
"Wrong block size %lu (expected %zu)", sbuf.f_bsize, cfg->block_size);
|
||||
zassert_equal(sbuf.f_frsize, cfg->block_size,
|
||||
"Wrong frag size %lu (expected %lu)", sbuf.f_frsize, cfg->block_size);
|
||||
"Wrong frag size %lu (expected %zu)", sbuf.f_frsize, cfg->block_size);
|
||||
zassert_equal(sbuf.f_blocks, partition_size / cfg->block_size,
|
||||
"Wrong block count %lu (expected %lu)",
|
||||
"Wrong block count %lu (expected %zu)",
|
||||
sbuf.f_blocks, partition_size / cfg->block_size);
|
||||
|
||||
ret = fs_unmount(mp);
|
||||
|
||||
@ -20,8 +20,7 @@ static void test_prepare(void)
|
||||
|
||||
fs_file_t_init(&fs);
|
||||
zassert_equal(fs_mount(&fatfs_mnt), 0);
|
||||
zassert_equal(fs_open(&fs, FATFS_MNTP"/testfile.txt", FS_O_CREATE),
|
||||
0, NULL);
|
||||
zassert_equal(fs_open(&fs, FATFS_MNTP"/testfile.txt", FS_O_CREATE), 0);
|
||||
zassert_equal(fs_close(&fs), 0);
|
||||
zassert_equal(fs_unmount(&fatfs_mnt), 0);
|
||||
}
|
||||
@ -41,21 +40,21 @@ static void test_ops_on_rd(void)
|
||||
fatfs_mnt.flags = FS_MOUNT_FLAG_READ_ONLY;
|
||||
TC_PRINT("Mount as read-only\n");
|
||||
ret = fs_mount(&fatfs_mnt);
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
|
||||
/* Attempt creating new file */
|
||||
ret = fs_open(&fs, FATFS_MNTP"/nosome", FS_O_CREATE);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_mkdir(FATFS_MNTP"/another");
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_rename(FATFS_MNTP"/testfile.txt", FATFS_MNTP"/bestfile.txt");
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_unlink(FATFS_MNTP"/testfile.txt");
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_open(&fs, FATFS_MNTP"/testfile.txt", FS_O_RDWR);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS", ret);
|
||||
zassert_equal(ret, -EROFS, "Expected EROFS got %d", ret);
|
||||
ret = fs_open(&fs, FATFS_MNTP"/testfile.txt", FS_O_READ);
|
||||
zassert_equal(ret, 0, "Expected success", ret);
|
||||
zassert_equal(ret, 0, "Expected success got %d", ret);
|
||||
fs_close(&fs);
|
||||
}
|
||||
|
||||
|
||||
@ -15,15 +15,13 @@ static const char *test_str = "Hello world FAT";
|
||||
void test_fat_open(void)
|
||||
{
|
||||
fs_file_t_init(&test_file);
|
||||
zassert_true(test_file_open(&test_file, TEST_FILE_PATH) == TC_PASS,
|
||||
NULL);
|
||||
zassert_true(test_file_open(&test_file, TEST_FILE_PATH) == TC_PASS);
|
||||
}
|
||||
|
||||
void test_fat_write(void)
|
||||
{
|
||||
TC_PRINT("Write to file %s\n", TEST_FILE_PATH);
|
||||
zassert_true(test_file_write(&test_file, test_str) == TC_PASS,
|
||||
NULL);
|
||||
zassert_true(test_file_write(&test_file, test_str) == TC_PASS);
|
||||
}
|
||||
|
||||
void test_fat_read(void)
|
||||
|
||||
@ -23,7 +23,7 @@ static void test_shell_exec(const char *line, int result)
|
||||
|
||||
TC_PRINT("shell_execute_cmd(%s): %d\n", line, ret);
|
||||
|
||||
zassert_true(ret == result, line);
|
||||
zassert_true(ret == result, "%s", line);
|
||||
}
|
||||
|
||||
ZTEST(multi_fs_help, test_fs_help)
|
||||
|
||||
@ -15,15 +15,13 @@ static const char *test_str = "Hello world LITTLEFS";
|
||||
void test_littlefs_open(void)
|
||||
{
|
||||
fs_file_t_init(&test_file);
|
||||
zassert_true(test_file_open(&test_file, TEST_FILE_PATH) == TC_PASS,
|
||||
NULL);
|
||||
zassert_true(test_file_open(&test_file, TEST_FILE_PATH) == TC_PASS);
|
||||
}
|
||||
|
||||
void test_littlefs_write(void)
|
||||
{
|
||||
TC_PRINT("Write to file %s\n", TEST_FILE_PATH);
|
||||
zassert_true(test_file_write(&test_file, test_str) == TC_PASS,
|
||||
NULL);
|
||||
zassert_true(test_file_write(&test_file, test_str) == TC_PASS);
|
||||
}
|
||||
|
||||
void test_littlefs_read(void)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user