Skip to content

Commit

Permalink
Fix #994, fixed invalid inputs for OS_mkdir
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed May 11, 2021
1 parent 706f0de commit de60c2a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/tests/file-api-test/file-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@ void TestMkRmDirFreeBytes(void)
"Checking Free Blocks: status=%d blocks=%lu", (int)status, (unsigned long)statbuf.blocks_free);

/* make the two directories */
status = OS_mkdir(dir1, 0);
status = OS_mkdir(dir1, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status);

status = OS_mkdir(dir2, 0);
status = OS_mkdir(dir2, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 2 = %d", (int)status);

/* now create two files in the two directories (1 file per directory) */
Expand Down Expand Up @@ -580,10 +580,10 @@ void TestOpenReadCloseDir(void)

/* make the two directories */

status = OS_mkdir(dir1, 0);
status = OS_mkdir(dir1, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status);

status = OS_mkdir(dir2, 0);
status = OS_mkdir(dir2, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 2 = %d", (int)status);

/* now create two files in the two directories (1 file per directory) */
Expand Down Expand Up @@ -788,7 +788,7 @@ void TestRename(void)

/* make the directory */

status = OS_mkdir(dir1, 0);
status = OS_mkdir(dir1, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status);

/* now create a file in the directory */
Expand Down Expand Up @@ -866,7 +866,7 @@ void TestStat(void)
strcpy(buffer1, "111111111111");

/* make the directory */
status = OS_mkdir(dir1, 0);
status = OS_mkdir(dir1, OS_READ_WRITE);
UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status);

/* now create a file */
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Test_OS_mkdir(void)
* int32 OS_mkdir (const char *path, uint32 access)
*/
int32 expected = OS_SUCCESS;
int32 actual = OS_mkdir("Dir", 0);
int32 actual = OS_mkdir("Dir", OS_READ_WRITE);

UtAssert_True(actual == expected, "OS_mkdir() (%ld) == OS_SUCCESS", (long)actual);
}
Expand Down
28 changes: 14 additions & 14 deletions src/unit-tests/osfile-test/ut_osfile_dirio_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void UT_os_makedir_test()
/*-----------------------------------------------------*/
testDesc = "API not implemented";

if (OS_mkdir(NULL, 755) == OS_ERR_NOT_IMPLEMENTED)
if (OS_mkdir(NULL, OS_READ_WRITE) == OS_ERR_NOT_IMPLEMENTED)
{
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA);
goto UT_os_makedir_test_exit_tag;
Expand All @@ -136,23 +136,23 @@ void UT_os_makedir_test()
/*-----------------------------------------------------*/
testDesc = "#1 Null-pointer-arg";

if (OS_mkdir(NULL, 755) == OS_INVALID_POINTER)
if (OS_mkdir(NULL, OS_READ_WRITE) == OS_INVALID_POINTER)
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE);

/*-----------------------------------------------------*/
testDesc = "#2 Path-too-long-arg";

if (OS_mkdir(g_longPathName, 755) == OS_FS_ERR_PATH_TOO_LONG)
if (OS_mkdir(g_longPathName, OS_READ_WRITE) == OS_FS_ERR_PATH_TOO_LONG)
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE);

/*-----------------------------------------------------*/
testDesc = "#3 Invalid-path-arg";

if (OS_mkdir("tmpDir", 755) == OS_FS_ERR_PATH_INVALID)
if (OS_mkdir("tmpDir", OS_READ_WRITE) == OS_FS_ERR_PATH_INVALID)
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE);
Expand All @@ -167,7 +167,7 @@ void UT_os_makedir_test()

memset(g_dirName, '\0', sizeof(g_dirName));
UT_os_sprintf(g_dirName, "%s/mkdir_Nominal", g_mntName);
if (OS_mkdir(g_dirName, 755) != OS_SUCCESS)
if (OS_mkdir(g_dirName, OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#5 Nominal - File-system-create failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand Down Expand Up @@ -284,7 +284,7 @@ void UT_os_opendir_test()

memset(g_dirName, '\0', sizeof(g_dirName));
UT_os_sprintf(g_dirName, "%s/opendir_Nominal", g_mntName);
if (OS_mkdir(g_dirName, 755) != OS_SUCCESS)
if (OS_mkdir(g_dirName, OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#5 Nominal - Dir-create failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand Down Expand Up @@ -362,7 +362,7 @@ void UT_os_closedir_test()

memset(g_dirName, '\0', sizeof(g_dirName));
UT_os_sprintf(g_dirName, "%s/closeDir3", g_mntName);
if (OS_mkdir(g_dirName, 755) != OS_SUCCESS)
if (OS_mkdir(g_dirName, OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#2 Nominal - Dir-create failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand Down Expand Up @@ -472,7 +472,7 @@ void UT_os_readdir_test()

memset(g_dirName, '\0', sizeof(g_dirName));
UT_os_sprintf(g_dirName, "%s/readdir_Nominal", g_mntName);
if (OS_mkdir(g_dirName, 755) != OS_SUCCESS)
if (OS_mkdir(g_dirName, OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#3 Nominal - Dir-create failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand All @@ -481,7 +481,7 @@ void UT_os_readdir_test()

memset(g_subdirNames[0], '\0', sizeof(g_subdirNames[0]));
UT_os_sprintf(g_subdirNames[0], "%s/%s", g_dirName, g_tgtSubdirs[0]);
if (OS_mkdir(g_subdirNames[0], 755) != OS_SUCCESS)
if (OS_mkdir(g_subdirNames[0], OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#3 Nominal - Dir-create(subdir1) failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand All @@ -491,7 +491,7 @@ void UT_os_readdir_test()

memset(g_subdirNames[1], '\0', sizeof(g_subdirNames[1]));
UT_os_sprintf(g_subdirNames[1], "%s/%s", g_dirName, g_tgtSubdirs[1]);
if (OS_mkdir(g_subdirNames[1], 755) != OS_SUCCESS)
if (OS_mkdir(g_subdirNames[1], OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#3 Nominal - Dir-create(subdir2) failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand Down Expand Up @@ -591,7 +591,7 @@ void UT_os_rewinddir_test()

memset(g_dirName, '\0', sizeof(g_dirName));
UT_os_sprintf(g_dirName, "%s/rewinddir_Nominal", g_mntName);
if (OS_mkdir(g_dirName, 755) != OS_SUCCESS)
if (OS_mkdir(g_dirName, OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#2 Nominal - Dir-create failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand All @@ -601,7 +601,7 @@ void UT_os_rewinddir_test()

memset(g_subdirNames[0], '\0', sizeof(g_subdirNames[0]));
UT_os_sprintf(g_subdirNames[0], "%s/%s", g_dirName, g_tgtSubdirs[0]);
if (OS_mkdir(g_subdirNames[0], 755) != OS_SUCCESS)
if (OS_mkdir(g_subdirNames[0], OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#2 Nominal - Dir-create(subdir1) failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand All @@ -611,7 +611,7 @@ void UT_os_rewinddir_test()

memset(g_subdirNames[1], '\0', sizeof(g_subdirNames[1]));
UT_os_sprintf(g_subdirNames[1], "%s/%s", g_dirName, g_tgtSubdirs[1]);
if (OS_mkdir(g_subdirNames[1], 755) != OS_SUCCESS)
if (OS_mkdir(g_subdirNames[1], OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#2 Nominal - Dir-create(subdir2) failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand Down Expand Up @@ -758,7 +758,7 @@ void UT_os_removedir_test()

memset(g_dirName, '\0', sizeof(g_dirName));
UT_os_sprintf(g_dirName, "%s/rmdir_Nominal", g_mntName);
if (OS_mkdir(g_dirName, 755) != OS_SUCCESS)
if (OS_mkdir(g_dirName, OS_READ_WRITE) != OS_SUCCESS)
{
testDesc = "#5 Nominal - Dir-create failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
Expand Down

0 comments on commit de60c2a

Please sign in to comment.