diff --git a/src/os/vxworks/CMakeLists.txt b/src/os/vxworks/CMakeLists.txt index 9a510d041..9d1cc84d7 100644 --- a/src/os/vxworks/CMakeLists.txt +++ b/src/os/vxworks/CMakeLists.txt @@ -14,7 +14,7 @@ set(VXWORKS_BASE_SRCLIST src/os-impl-console.c src/os-impl-countsem.c src/os-impl-errors.c - src/os-impl-dirs.c + src/os-impl-dirs-globals.c src/os-impl-files.c src/os-impl-filesys.c src/os-impl-heap.c @@ -45,6 +45,15 @@ 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) diff --git a/src/os/vxworks/inc/os-impl-tasks.h b/src/os/vxworks/inc/os-impl-tasks.h index 8ae32d36b..d716ba88a 100644 --- a/src/os/vxworks/inc/os-impl-tasks.h +++ b/src/os/vxworks/inc/os-impl-tasks.h @@ -31,13 +31,21 @@ #include #include +#if defined(VX_WIND_TCB_SIZE) +/* vxworks >= 7.0 should provide this symbol via taskLib.h. WIND_TCB is an opaque type */ +typedef char OS_VxWorks_TCB_t[VX_WIND_TCB_SIZE]; +#else +/* older vxworks expose the definition of VX_WIND_TCB_SIZE */ +typedef WIND_TCB OS_VxWorks_TCB_t; +#endif /* !defined(VX_WIND_TCB_SIZE) */ + /*tasks */ typedef struct { - WIND_TCB tcb; /* Must be first */ - TASK_ID vxid; - void * heap_block; /* set non-null if the stack was obtained with malloc() */ - size_t heap_block_size; + OS_VxWorks_TCB_t tcb; /* Must be first */ + TASK_ID vxid; + void *heap_block; /* set non-null if the stack was obtained with malloc() */ + size_t heap_block_size; } OS_impl_task_internal_record_t; /* Tables where the OS object information is stored */ diff --git a/src/os/vxworks/src/os-impl-common.c b/src/os/vxworks/src/os-impl-common.c index beed30470..8d98dce3b 100644 --- a/src/os/vxworks/src/os-impl-common.c +++ b/src/os/vxworks/src/os-impl-common.c @@ -184,8 +184,11 @@ int32 OS_VxWorks_GenericSemTake(SEM_ID vxid, int sys_ticks) * check for the timeout condition, * which has a different return code and * not necessarily an error of concern. + * + * vxworks7: if sys_ticks == 0, then if the semaphore can + * not be taken S_objLib_OBJ_UNAVAILABLE will be returned */ - if (errno == S_objLib_OBJ_TIMEOUT) + if ((errno == S_objLib_OBJ_TIMEOUT) || (!sys_ticks && (errno == S_objLib_OBJ_UNAVAILABLE))) { return OS_SEM_TIMEOUT; } diff --git a/src/os/vxworks/src/os-impl-dirs-globals.c b/src/os/vxworks/src/os-impl-dirs-globals.c new file mode 100644 index 000000000..7be3ab73a --- /dev/null +++ b/src/os/vxworks/src/os-impl-dirs-globals.c @@ -0,0 +1,55 @@ +/* + * NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" + * + * Copyright (c) 2019 United States Government as represented by + * the Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file os-impl-dirs.c + * \ingroup vxworks + * \author joseph.p.hickey@nasa.gov + * + */ + +/**************************************************************************************** + INCLUDE FILES +****************************************************************************************/ + +#include "os-vxworks.h" +#include "os-impl-dirs.h" +#include "os-shared-dir.h" + + +/* + * The directory handle table. + */ +OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; + + +/*---------------------------------------------------------------- + * + * Function: OS_VxWorks_DirAPI_Impl_Init + * + * Purpose: Local helper routine, not part of OSAL API. + * + *-----------------------------------------------------------------*/ +int32 OS_VxWorks_DirAPI_Impl_Init(void) +{ + memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table)); + return OS_SUCCESS; +} /* end OS_VxWorks_DirAPI_Impl_Init */ + diff --git a/src/os/vxworks/src/os-impl-dirs.c b/src/os/vxworks/src/os-impl-dirs.c index 513b8b878..5933030f4 100644 --- a/src/os/vxworks/src/os-impl-dirs.c +++ b/src/os/vxworks/src/os-impl-dirs.c @@ -33,24 +33,6 @@ #include "os-impl-dirs.h" #include "os-shared-dir.h" -/* - * The directory handle table. - */ -OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; - -/*---------------------------------------------------------------- - * - * Function: OS_VxWorks_DirAPI_Impl_Init - * - * Purpose: Local helper routine, not part of OSAL API. - * - *-----------------------------------------------------------------*/ -int32 OS_VxWorks_DirAPI_Impl_Init(void) -{ - memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table)); - return OS_SUCCESS; -} /* end OS_VxWorks_DirAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_DirCreate_Impl diff --git a/src/os/vxworks/src/os-impl-tasks.c b/src/os/vxworks/src/os-impl-tasks.c index 83afb2922..eaa125619 100644 --- a/src/os/vxworks/src/os-impl-tasks.c +++ b/src/os/vxworks/src/os-impl-tasks.c @@ -238,7 +238,7 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) #endif id.id = OS_global_task_table[task_id].active_id; - status = taskInit(&lrec->tcb, /* address of new task's TCB */ + status = taskInit((WIND_TCB*)&lrec->tcb, /* address of new task's TCB */ (char *)OS_global_task_table[task_id].name_entry, vxpri, /* priority of new task */ vxflags, /* task option word */ (char *)actualstackbase, /* base of new task's stack */ diff --git a/src/unit-test-coverage/vxworks/CMakeLists.txt b/src/unit-test-coverage/vxworks/CMakeLists.txt index fee10fc5e..afcf47eb1 100644 --- a/src/unit-test-coverage/vxworks/CMakeLists.txt +++ b/src/unit-test-coverage/vxworks/CMakeLists.txt @@ -6,6 +6,7 @@ set(VXWORKS_MODULE_LIST console countsem dirs + dirs-globals files filesys idmap diff --git a/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt b/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt index f5e1d59f5..459d59373 100644 --- a/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt +++ b/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt @@ -13,6 +13,7 @@ add_library(ut-adaptor-${SETNAME} STATIC src/ut-adaptor-console.c src/ut-adaptor-countsem.c src/ut-adaptor-dirs.c + src/ut-adaptor-dirtable-stub.c src/ut-adaptor-files.c src/ut-adaptor-filesys.c src/ut-adaptor-idmap.c diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-dirtable-stub.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-dirtable-stub.c new file mode 100644 index 000000000..766326414 --- /dev/null +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-dirtable-stub.c @@ -0,0 +1,36 @@ +/* + * NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" + * + * Copyright (c) 2019 United States Government as represented by + * the Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file ut-adaptor-filetable-stub.c + * \ingroup adaptors + * \author joseph.p.hickey@nasa.gov + * + */ +/* pull in the OSAL configuration */ +#include "osconfig.h" +#include "ut-adaptor-filetable-stub.h" + +#include +#include +#include + +OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; + diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-dirs-globals.c b/src/unit-test-coverage/vxworks/src/coveragetest-dirs-globals.c new file mode 100644 index 000000000..c7c402383 --- /dev/null +++ b/src/unit-test-coverage/vxworks/src/coveragetest-dirs-globals.c @@ -0,0 +1,76 @@ +/* + * NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer" + * + * Copyright (c) 2019 United States Government as represented by + * the Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file coveragetest-dirs-globals.c + * \ingroup vxworks + * \author steven.seeger@nasa.gov + * + */ + +#include "os-vxworks-coveragetest.h" +#include "ut-adaptor-dirs.h" + +#include "os-shared-dir.h" + +#include +#include +#include +#include +#include + +void Test_OS_VxWorks_DirAPI_Impl_Init(void) +{ + /* + * Test Case For: + * int32 OS_VxWorks_DirAPI_Impl_Init(void) + */ + OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_DirAPI_Impl_Init(), OS_SUCCESS); +} + +/* ------------------- End of test cases --------------------------------------*/ + +/* Osapi_Test_Setup + * + * Purpose: + * Called by the unit test tool to set up the app prior to each test + */ +void Osapi_Test_Setup(void) +{ + UT_ResetState(0); +} + +/* + * Osapi_Test_Teardown + * + * Purpose: + * Called by the unit test tool to tear down the app after each test + */ +void Osapi_Test_Teardown(void) {} + +/* UtTest_Setup + * + * Purpose: + * Registers the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(OS_VxWorks_DirAPI_Impl_Init); +} diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c b/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c index f31a0bbe2..e96a7cc8e 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c @@ -36,15 +36,6 @@ #include #include -void Test_OS_VxWorks_DirAPI_Impl_Init(void) -{ - /* - * Test Case For: - * int32 OS_VxWorks_DirAPI_Impl_Init(void) - */ - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_DirAPI_Impl_Init(), OS_SUCCESS); -} - void Test_OS_DirCreate_Impl(void) { /* @@ -139,7 +130,6 @@ void Osapi_Test_Teardown(void) {} */ void UtTest_Setup(void) { - ADD_TEST(OS_VxWorks_DirAPI_Impl_Init); ADD_TEST(OS_DirCreate_Impl); ADD_TEST(OS_DirOpen_Impl); ADD_TEST(OS_DirClose_Impl);