Skip to content

Commit

Permalink
Merge pull request #706 from jphickey/fix-697-vxworks6-dir
Browse files Browse the repository at this point in the history
Fix #697, use POSIX dir implementation on VxWorks6
  • Loading branch information
astrogeco authored Jan 13, 2021
2 parents 2f2600f + ed990e7 commit e9ff3a6
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 201 deletions.
15 changes: 6 additions & 9 deletions src/os/vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set(VXWORKS_IMPL_SRCLIST
../portable/os-impl-bsd-select.c
../portable/os-impl-posix-io.c
../portable/os-impl-posix-files.c
../portable/os-impl-posix-dirs.c
)

if (OSAL_CONFIG_INCLUDE_SHELL)
Expand All @@ -45,15 +46,6 @@ else ()
)
endif ()

if (CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 7.0)
list(APPEND VXWORKS_IMPL_SRCLIST
../portable/os-impl-posix-dirs.c
)
else ()
list(APPEND VXWORKS_IMPL_SRCLIST
src/os-impl-dirs.c
)
endif ()
# If some form of module loading is configured,
# then build the module loader
if (OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER)
Expand Down Expand Up @@ -86,3 +78,8 @@ add_library(osal_vxworks_impl OBJECT
${VXWORKS_BASE_SRCLIST}
${VXWORKS_IMPL_SRCLIST}
)

if (CMAKE_SYSTEM_VERSION VERSION_LESS 7.0)
target_compile_definitions(osal_vxworks_impl PRIVATE OSAL_VXWORKS6_COMPATIBILITY)
endif ()

12 changes: 12 additions & 0 deletions src/os/vxworks/inc/os-impl-dirs.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,20 @@
#include "osconfig.h"
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>

/*
* In VxWorks 6.x the system mkdir() function only has a path argument
* In VxWorks 7 it is now POSIX compilant and adds a mode argument
*
* This macro simply discards the second argument, allowing code to use
* mkdir() in a consistent, POSIX compliant fashion.
*/
#ifdef OSAL_VXWORKS6_COMPATIBILITY
#define mkdir(path,mode) mkdir(path)
#endif

typedef struct
{
DIR *dp;
Expand Down
172 changes: 0 additions & 172 deletions src/os/vxworks/src/os-impl-dirs.c

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@
*/

/**
* \file coveragetest-dirs.c
* \ingroup vxworks
* \file coveragetest-posix-dirs.c
* \author joseph.p.hickey@nasa.gov
*
*/

#include "os-vxworks-coveragetest.h"
#include "ut-adaptor-dirs.h"
#include "os-portable-coveragetest.h"

#include "os-shared-dir.h"
#include "os-shared-idmap.h"

#include <OCS_stdlib.h>
#include <OCS_taskLib.h>
#include <OCS_dirent.h>
#include <OCS_unistd.h>
#include <OCS_stat.h>
Expand All @@ -42,10 +40,10 @@ void Test_OS_DirCreate_Impl(void)
* Test Case For:
* int32 OS_DirCreate_Impl(const char *local_path, uint32 access)
*/
OSAPI_TEST_FUNCTION_RC(OS_DirCreate_Impl("dir", 0), OS_SUCCESS);
OSAPI_TEST_FUNCTION_RC(OS_DirCreate_Impl, ("dir", 0), OS_SUCCESS);

UT_SetDefaultReturnValue(UT_KEY(OCS_mkdir), -1);
OSAPI_TEST_FUNCTION_RC(OS_DirCreate_Impl("dir", 0), OS_ERROR);
OSAPI_TEST_FUNCTION_RC(OS_DirCreate_Impl, ("dir", 0), OS_ERROR);
}

void Test_OS_DirOpen_Impl(void)
Expand All @@ -54,11 +52,13 @@ void Test_OS_DirOpen_Impl(void)
* Test Case For:
* int32 OS_DirOpen_Impl(uint32 local_id, const char *local_path)
*/
OS_object_token_t token = UT_TOKEN_0;
OS_object_token_t token;

OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl(&token, "dir"), OS_SUCCESS);
memset(&token, 0, sizeof(token));

OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl, (&token, "dir"), OS_SUCCESS);
UT_SetDefaultReturnValue(UT_KEY(OCS_opendir), -1);
OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl(&token, "dir"), OS_ERROR);
OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl, (&token, "dir"), OS_ERROR);
}

void Test_OS_DirClose_Impl(void)
Expand All @@ -67,9 +67,11 @@ void Test_OS_DirClose_Impl(void)
* Test Case For:
* int32 OS_DirClose_Impl(uint32 local_id)
*/
OS_object_token_t token = UT_TOKEN_0;
OS_object_token_t token;

memset(&token, 0, sizeof(token));

OSAPI_TEST_FUNCTION_RC(OS_DirClose_Impl(&token), OS_SUCCESS);
OSAPI_TEST_FUNCTION_RC(OS_DirClose_Impl, (&token), OS_SUCCESS);
}

void Test_OS_DirRead_Impl(void)
Expand All @@ -79,12 +81,14 @@ void Test_OS_DirRead_Impl(void)
* int32 OS_DirRead_Impl(uint32 local_id, os_dirent_t *dirent)
*/
os_dirent_t dirent_buff;
OS_object_token_t token = UT_TOKEN_0;
OS_object_token_t token;

OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(&token, &dirent_buff), OS_SUCCESS);
memset(&token, 0, sizeof(token));

OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl, (&token, &dirent_buff), OS_SUCCESS);

UT_SetDefaultReturnValue(UT_KEY(OCS_readdir), -1);
OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(&token, &dirent_buff), OS_ERROR);
OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl, (&token, &dirent_buff), OS_ERROR);
}

void Test_OS_DirRewind_Impl(void)
Expand All @@ -93,9 +97,11 @@ void Test_OS_DirRewind_Impl(void)
* Test Case For:
* int32 OS_DirRewind_Impl(uint32 local_id)
*/
OS_object_token_t token = UT_TOKEN_0;
OS_object_token_t token;

memset(&token, 0, sizeof(token));

OSAPI_TEST_FUNCTION_RC(OS_DirRewind_Impl(&token), OS_SUCCESS);
OSAPI_TEST_FUNCTION_RC(OS_DirRewind_Impl, (&token), OS_SUCCESS);
}

void Test_OS_DirRemove_Impl(void)
Expand All @@ -104,10 +110,10 @@ void Test_OS_DirRemove_Impl(void)
* Test Case For:
* int32 OS_DirRemove_Impl(const char *local_path)
*/
OSAPI_TEST_FUNCTION_RC(OS_DirRemove_Impl("dir"), OS_SUCCESS);
OSAPI_TEST_FUNCTION_RC(OS_DirRemove_Impl, ("dir"), OS_SUCCESS);

UT_SetDefaultReturnValue(UT_KEY(OCS_rmdir), -1);
OSAPI_TEST_FUNCTION_RC(OS_DirRemove_Impl("dir"), OS_ERROR);
OSAPI_TEST_FUNCTION_RC(OS_DirRemove_Impl, ("dir"), OS_ERROR);
}

/* ------------------- End of test cases --------------------------------------*/
Expand Down
1 change: 1 addition & 0 deletions src/unit-test-coverage/ut-stubs/inc/OCS_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/* POSIX-specific errnos */
#define OCS_EINTR 0x1801
#define OCS_EAGAIN 0x1802
#define OCS_EEXIST 0x180a
#define OCS_EINVAL 0x1803
#define OCS_EMSGSIZE 0x1804
#define OCS_ETIMEDOUT 0x1805
Expand Down
4 changes: 4 additions & 0 deletions src/unit-test-coverage/ut-stubs/inc/OCS_fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
*
* These are exposed to apps through fcntl.h and sys/stat.h
*/
#define OCS_S_IRWXO 0x1110
#define OCS_S_IRWXG 0x2220
#define OCS_S_IRWXU 0x4440

#define OCS_S_IXOTH 0x1000
#define OCS_S_IXGRP 0x2000
#define OCS_S_IXUSR 0x4000
Expand Down
1 change: 1 addition & 0 deletions src/unit-test-coverage/ut-stubs/override_inc/errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define EINTR OCS_EINTR
#define EAGAIN OCS_EAGAIN
#define EINVAL OCS_EINVAL
#define EEXIST OCS_EEXIST
#define EMSGSIZE OCS_EMSGSIZE
#define ETIMEDOUT OCS_ETIMEDOUT
#define ESPIPE OCS_ESPIPE
Expand Down
3 changes: 3 additions & 0 deletions src/unit-test-coverage/ut-stubs/override_inc/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
/* ----------------------------------------- */
/* mappings for declarations in fcntl.h */
/* ----------------------------------------- */
#define S_IRWXU OCS_S_IRWXU
#define S_IRWXG OCS_S_IRWXG
#define S_IRWXO OCS_S_IRWXO
#define S_IXOTH OCS_S_IXOTH
#define S_IXGRP OCS_S_IXGRP
#define S_IXUSR OCS_S_IXUSR
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set(VXWORKS_MODULE_LIST
common
console
countsem
dirs
dirs-globals
files
filesys
Expand All @@ -25,6 +24,7 @@ set(VXWORKS_PORTABLE_BLOCK_LIST
posix-gettime
posix-io
posix-files
posix-dirs

console-bsp
bsd-select
Expand Down

0 comments on commit e9ff3a6

Please sign in to comment.