tests: posix: fs: add test suite for rmdir
add test suite for POSIX API rmdir Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
This commit is contained in:
parent
f616c43c9e
commit
e8ab88bd15
1 changed files with 27 additions and 0 deletions
|
@ -150,3 +150,30 @@ ZTEST(posix_fs_dir_test, test_fs_readdir_threadsafe)
|
|||
zassert_true(test_mkdir() == TC_PASS);
|
||||
zassert_true(test_lsdir(TEST_DIR, true) == TC_PASS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test for POSIX rmdir API
|
||||
*
|
||||
* @details Test creates a new directory through POSIX
|
||||
* mkdir API and remove directory using rmdir.
|
||||
*/
|
||||
ZTEST(posix_fs_dir_test, test_fs_rmdir)
|
||||
{
|
||||
#define IRWXG 0070
|
||||
/* Create and remove empty directory */
|
||||
zassert_ok(mkdir(TEST_DIR, IRWXG), "Error creating dir: %d", errno);
|
||||
zassert_ok(rmdir(TEST_DIR), "Error removing dir: %d\n", errno);
|
||||
|
||||
/* Create directory and open a file in the directory
|
||||
* now removing the directory will fail, test will
|
||||
* fail in removal of non empty directory
|
||||
*/
|
||||
zassert_ok(mkdir(TEST_DIR, IRWXG), "Error creating dir: %d", errno);
|
||||
zassert_not_equal(open(TEST_DIR_FILE, O_CREAT | O_RDWR), -1,
|
||||
"Error creating file: %d", errno);
|
||||
zassert_not_ok(rmdir(TEST_DIR), "Error Non empty dir removed");
|
||||
zassert_not_ok(rmdir(""), "Error Invalid path removed");
|
||||
zassert_not_ok(rmdir(NULL), "Error Invalid path removed");
|
||||
zassert_not_ok(rmdir("TEST_DIR."), "Error Invalid path removed");
|
||||
zassert_not_ok(rmdir(TEST_FILE), "Error file removed");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue