From 926c0c0cd2309e5a0c69670b7daabc5e90e05461 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Sun, 17 May 2020 16:55:45 +0800 Subject: [PATCH] improve fs test code --- src/tkc/fs.c | 16 +++++++++++++--- src/tkc/fs.h | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/tkc/fs.c b/src/tkc/fs.c index c3cb2125b..1d12efedf 100644 --- a/src/tkc/fs.c +++ b/src/tkc/fs.c @@ -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); +} diff --git a/src/tkc/fs.h b/src/tkc/fs.h index b8856900e..85da71a8c 100644 --- a/src/tkc/fs.h +++ b/src/tkc/fs.h @@ -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