Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #259, updated osapi-filesys.c + ut_osfilesys_diskio_tes.ct to use… #387

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions src/os/shared/osapi-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,7 @@ int32 OS_rmfs (const char *devname)
}
else
{
/*
* Although OS_ERR_NAME_NOT_FOUND is more descriptive and a
* better indicator of the real failure, this preserves
* backward compatibility with unit tests that
* are checking specifically for the "OS_FS_ERROR" code.
*/
return_code = OS_FS_ERROR;
return_code = OS_ERR_NAME_NOT_FOUND;
}

return return_code;
Expand Down Expand Up @@ -692,13 +686,7 @@ int32 OS_mount (const char *devname, const char* mountpoint)

if (return_code != OS_SUCCESS)
{
/*
* Although OS_ERR_NAME_NOT_FOUND is more descriptive and a
* better indicator of the real failure, this preserves
* backward compatibility with unit tests that
* are checking specifically for the "OS_FS_ERROR" code.
*/
return_code = OS_FS_ERROR;
return_code = OS_ERR_NAME_NOT_FOUND;
}

return return_code;
Expand Down Expand Up @@ -777,13 +765,7 @@ int32 OS_unmount (const char *mountpoint)

if (return_code != OS_SUCCESS)
{
/*
* Although OS_ERR_NAME_NOT_FOUND is more descriptive and a
* better indicator of the real failure, this preserves
* backward compatibility with unit tests that
* are checking specifically for the "OS_FS_ERROR" code.
*/
return_code = OS_FS_ERROR;
return_code = OS_ERR_NAME_NOT_FOUND;
}

return return_code;
Expand Down Expand Up @@ -991,8 +973,7 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint)
}
else
{
/* preserves historical (vague) error code */
return_code = OS_FS_ERROR;
return_code = OS_ERR_NAME_NOT_FOUND;
}


Expand Down
32 changes: 16 additions & 16 deletions src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ void UT_os_makefs_test()
** Purpose: Removes or un-maps the target file system
** Parameters: *devname - a pointer to the name of the "generic" drive
** Returns: OS_FS_ERR_INVALID_POINTER if any of the pointers passed in is NULL
** OS_FS_ERROR if the given device is not found in the Volume table
** OS_ERR_NAME_NOT_FOUND if the given device is not found in the Volume table
** OS_FS_SUCCESS if succeeded
** OS_ERR_NOT_IMPLEMENTED if not implemented
** -----------------------------------------------------
Expand All @@ -426,7 +426,7 @@ void UT_os_makefs_test()
** 1) Make sure no file system has been created previously
** 2) Call this routine with some device name as argument
** 3) Expect the returned value to be
** (a) OS_FS_ERROR
** (a) OS_ERR_NAME_NOT_FOUND
** -----------------------------------------------------
** Test #3: Nominal condition
** 1) Call OS_mkfs to create a file system
Expand Down Expand Up @@ -465,7 +465,7 @@ void UT_os_removefs_test()
/*-----------------------------------------------------*/
testDesc = "#2 Invalid-device-arg";

if (OS_rmfs(g_devNames[2]) == OS_FS_ERROR)
if (OS_rmfs(g_devNames[2]) == OS_ERR_NAME_NOT_FOUND)
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);
Expand Down Expand Up @@ -500,7 +500,7 @@ void UT_os_removefs_test()
** Parameters: *devname - a pointer to the name of the drive to mount
** *mountpoint - a pointer to the name to call this disk from now on
** Returns: OS_FS_ERR_INVALID_POINTER if any of the pointers passed in is NULL
** OS_FS_ERROR if the given device is not found in the Volume table
** OS_ERR_NAME_NOT_FOUND if the given device is not found in the Volume table
** OS_FS_SUCCESS if succeeded
** OS_ERR_NOT_IMPLEMENTED if not implemented
** -----------------------------------------------------
Expand All @@ -520,7 +520,7 @@ void UT_os_removefs_test()
** 1) Make sure no file system has been created previously
** 2) Call this routine with some device name as argument
** 3) Expect the returned value to be
** (a) OS_FS_ERROR
** (a) OS_ERR_NAME_NOT_FOUND
** -----------------------------------------------------
** Test #3: Nominal condition
** 1) Call OS_mkfs to create a file system
Expand All @@ -531,7 +531,7 @@ void UT_os_removefs_test()
** (a) OS_FS_SUCCESS
** 5) Call this routine again exactly as in #3
** 6) Expect the returned value to be
** (a) OS_FS_ERROR
** (a) OS_ERR_NAME_NOT_FOUND
** 7) Call OS_unmount with the mount-point used in #3 as argument
** 8) Expect the returned value to be
** (a) OS_FS_SUCCESS
Expand Down Expand Up @@ -563,7 +563,7 @@ void UT_os_mount_test()
/*-----------------------------------------------------*/
testDesc = "#2 Invalid-device-arg";

if (OS_mount("ramdev0", g_mntNames[2]) == OS_FS_ERROR)
if (OS_mount("ramdev0", g_mntNames[2]) == OS_ERR_NAME_NOT_FOUND)
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);
Expand All @@ -579,7 +579,7 @@ void UT_os_mount_test()
}

if ((OS_mount(g_devNames[3], g_mntNames[3]) == OS_FS_SUCCESS) &&
(OS_mount(g_devNames[3], g_mntNames[3]) == OS_FS_ERROR))
(OS_mount(g_devNames[3], g_mntNames[3]) == OS_ERR_NAME_NOT_FOUND))
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);
Expand All @@ -599,7 +599,7 @@ void UT_os_mount_test()
** Parameters: *mountpoint - a pointer to the name of the drive to unmount
** Returns: OS_FS_ERR_INVALID_POINTER if any of the pointers passed in is NULL
** OS_FS_ERR_PATH_TOO_LONG if the absolute path passed in is too long
** OS_FS_ERROR if the mount-point passed in is not found in the Volume table
** OS_ERR_NAME_NOT_FOUND if the mount-point passed in is not found in the Volume table
** OS_FS_SUCCESS if succeeded
** OS_ERR_NOT_IMPLEMENTED if not implemented
** -----------------------------------------------------
Expand All @@ -625,7 +625,7 @@ void UT_os_mount_test()
** 1) Make sure no file system has been created previously
** 2) Call this routine with some mount-point name as argument
** 3) Expect the returned value to be
** (a) OS_FS_ERROR
** (a) OS_ERR_NAME_NOT_FOUND
** -----------------------------------------------------
** Test #4: Nominal condition
** 1) Call OS_mkfs to create a file system
Expand All @@ -639,7 +639,7 @@ void UT_os_mount_test()
** (a) OS_FS_SUCCESS
** 7) Call this routine again exactly as in #5
** 8) Expect the returned value to be
** (a) OS_FS_ERROR
** (a) OS_ERR_NAME_NOT_FOUND
**--------------------------------------------------------------------------------*/
void UT_os_unmount_test()
{
Expand Down Expand Up @@ -675,7 +675,7 @@ void UT_os_unmount_test()
/*-----------------------------------------------------*/
testDesc = "#3 Invalid-mount-point-arg";

if (OS_unmount(g_mntNames[3]) == OS_FS_ERROR)
if (OS_unmount(g_mntNames[3]) == OS_ERR_NAME_NOT_FOUND)
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);
Expand All @@ -692,7 +692,7 @@ void UT_os_unmount_test()

if ((OS_mount(g_devNames[4], g_mntNames[4]) == OS_FS_SUCCESS) &&
(OS_unmount(g_mntNames[4]) == OS_FS_SUCCESS) &&
(OS_unmount(g_mntNames[4]) == OS_FS_ERROR))
(OS_unmount(g_mntNames[4]) == OS_ERR_NAME_NOT_FOUND))
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);
Expand All @@ -712,7 +712,7 @@ void UT_os_unmount_test()
** *MountPoint - a pointer to the name of the mount-point
** Returns: OS_FS_ERR_INVALID_POINTER if any of the pointers passed in is NULL
** OS_FS_ERR_PATH_TOO_LONG if the mount-point passed in is too long
** OS_FS_ERROR if the mount-point passed in is not found in the Volume table
** OS_ERR_NAME_NOT_FOUND if the mount-point passed in is not found in the Volume table
** OS_FS_SUCCESS if succeeded
** OS_ERR_NOT_IMPLEMENTED if not implemented
** -----------------------------------------------------
Expand Down Expand Up @@ -740,7 +740,7 @@ void UT_os_unmount_test()
** (a) OS_FS_SUCCESS
** 3) Call this routine
** 4) Expect the returned value to be
** (a) OS_FS_ERROR
** (a) OS_ERR_NAME_NOT_FOUND
** -----------------------------------------------------
** Test #4: Nominal condition
** 1) Call OS_mkfs
Expand Down Expand Up @@ -789,7 +789,7 @@ void UT_os_getphysdrivename_test()
/*-----------------------------------------------------*/
testDesc = "#3 Invalid-mount-point-arg";

if (OS_FS_GetPhysDriveName(physDevName, g_mntNames[3]) == OS_FS_ERROR)
if (OS_FS_GetPhysDriveName(physDevName, g_mntNames[3]) == OS_ERR_NAME_NOT_FOUND)
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE);
Expand Down