improve fs test code

This commit is contained in:
lixianjing 2020-05-17 16:55:45 +08:00
parent 04385e2626
commit 926c0c0cd2
2 changed files with 15 additions and 3 deletions

View File

@ -284,11 +284,9 @@ bool_t file_exist(const char* name) {
return fs_file_exist(os_fs(), name);
}
ret_t fs_test(fs_t* fs) {
ret_t fs_test_file(fs_t* fs) {
char buff[32];
fs_item_t item;
fs_file_t* fp = NULL;
fs_dir_t* dir = NULL;
const char* filename = "./test.txt";
memset(buff, 0x00, sizeof(buff));
@ -325,6 +323,13 @@ ret_t fs_test(fs_t* fs) {
assert(fs_remove_file(fs, "./test.bin") == RET_OK);
assert(!fs_file_exist(fs, "./test.bin"));
return RET_OK;
}
ret_t fs_test_dir(fs_t* fs) {
fs_item_t item;
fs_dir_t* dir = NULL;
assert(!fs_dir_exist(fs, "./a"));
assert(fs_create_dir(fs, "./a") == RET_OK);
assert(fs_dir_exist(fs, "./a"));
@ -376,3 +381,8 @@ ret_t fs_test(fs_t* fs) {
return RET_OK;
}
ret_t fs_test(fs_t* fs) {
fs_test_file(fs);
return fs_test_dir(fs);
}

View File

@ -669,6 +669,8 @@ ret_t file_write(const char* name, const void* buff, uint32_t size);
/*basic function test*/
ret_t fs_test(fs_t* fs);
ret_t fs_test_file(fs_t* fs);
ret_t fs_test_dir(fs_t* fs);
END_C_DECLS