Skip to content

Commit

Permalink
Merge pull request #350 from nasa/ic-20200108
Browse files Browse the repository at this point in the history
Integration Candidate 20200108
  • Loading branch information
skliper authored Jan 17, 2020
2 parents 781992c + 6ad6f2f commit 702bf5e
Show file tree
Hide file tree
Showing 58 changed files with 153 additions and 109 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function(add_osal_ut_exe TGTNAME)
# It is not an issue for UT builds that use OSAL stubs or no OSAL at all.
set_target_properties(${TGTNAME} PROPERTIES COMPILE_DEFINITIONS "_UNIT_TEST_")
set_target_properties(${TGTNAME} PROPERTIES COMPILE_FLAGS "${UT_C_FLAGS}")
set_target_properties(${TGTNAME} PROPERTIES LINK_FLAGS "${UT_C_FLAGS} -u OS_VolumeTable -u OS_STATIC_SYMBOL_TABLE -u UT_BSP_DoText")
target_link_libraries(${TGTNAME} ut_bsp osal ut_assert ${OSAL_LINK_LIBS})
set_target_properties(${TGTNAME} PROPERTIES LINK_FLAGS "${UT_C_FLAGS} -u OS_VolumeTable -u OS_Application_Startup")
target_link_libraries(${TGTNAME} ut_assert osal)
add_test(${TGTNAME} ${TGTNAME})
foreach(TGT ${INSTALL_TARGET_LIST})
install(TARGETS ${TGTNAME} DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
Expand Down Expand Up @@ -206,6 +206,7 @@ if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/bsp/${UT_OSAL_BSPTYPE}/ut-src)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/bsp/${UT_OSAL_BSPTYPE}/ut-src UT_BSPFILES)
add_library(ut_bsp STATIC EXCLUDE_FROM_ALL ${UT_BSPFILES})
set_target_properties(ut_bsp PROPERTIES COMPILE_DEFINITIONS "_UNIT_TEST_")
target_link_libraries(ut_assert ut_bsp)
endif()

if (ENABLE_UNIT_TESTS)
Expand Down Expand Up @@ -246,7 +247,6 @@ if (ENABLE_UNIT_TESTS)
src/ut-stubs/osapi-utstub-timebase.c)

add_library(ut_osapi_stubs STATIC ${UT_OSAPI_STUB_SRCFILES})
target_link_libraries(ut_osapi_stubs ut_assert)

add_subdirectory(src/tests tests)
add_subdirectory(src/unit-tests unit-tests)
Expand Down
13 changes: 4 additions & 9 deletions src/bsp/mcp750-vxworks/ut-src/bsp_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ void UT_BSP_DoTestSegmentReport(const char *SegmentName, const UtAssert_TestCoun
UT_BSP_DoText(UTASSERT_CASETYPE_END, ReportBuffer);
}

void UT_BSP_Setup(const char *Name)
void UT_BSP_Setup(void)
{
UT_BSP_DoText(UTASSERT_CASETYPE_BEGIN, Name);
UT_BSP_DoText(UTASSERT_CASETYPE_BEGIN, "VxWorks UNIT TEST");
}


Expand Down Expand Up @@ -203,20 +203,15 @@ int RunTest(void)

if (RetVal == 0)
{
UT_BSP_Setup("VxWorks UNIT TEST");

/*
** Call application specific entry point.
*/
OS_Application_Startup();

/*
** In unit test mode, call the UtTest_Run function (part of UT Assert library)
** The OS_Application_Run function is part of UT Assert library
*/
UtTest_Run();

UT_BSP_EndTest(UtAssert_GetCounters());

OS_Application_Run();

RetVal = (UtAssert_GetCounters()->CaseCount[UTASSERT_CASETYPE_FAILURE] +
UtAssert_GetCounters()->CaseCount[UTASSERT_CASETYPE_TSF]);
Expand Down
10 changes: 4 additions & 6 deletions src/bsp/pc-linux/ut-src/bsp_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void UT_BSP_ParseCommandLine(int argc, char *argv[])
}
}

void UT_BSP_Setup(const char *Name)
void UT_BSP_Setup(void)
{
int mode;
uint32 i;
Expand All @@ -125,7 +125,7 @@ void UT_BSP_Setup(const char *Name)
EnableTermCodes = isatty(STDOUT_FILENO);


UT_BSP_DoText(UTASSERT_CASETYPE_BEGIN, Name);
UT_BSP_DoText(UTASSERT_CASETYPE_BEGIN, "PC-LINUX UNIT TEST");

/*
** Create local directories for "disk" mount points
Expand Down Expand Up @@ -344,7 +344,6 @@ void UT_BSP_EndTest(const UtAssert_TestCounter_t *TestCounters)

int main(int argc, char *argv[])
{
UT_BSP_Setup("PC-LINUX UNIT TEST");
UT_BSP_ParseCommandLine(argc, argv);

/*
Expand All @@ -353,10 +352,9 @@ int main(int argc, char *argv[])
OS_Application_Startup();

/*
** In unit test mode, call the UtTest_Run function (part of UT Assert library)
** The OS_Application_Run function is part of UT Assert library
*/
UtTest_Run();
UT_BSP_EndTest(UtAssert_GetCounters());
OS_Application_Run();

/* Should typically never get here */
return(EXIT_SUCCESS);
Expand Down
11 changes: 4 additions & 7 deletions src/bsp/pc-rtems/ut-src/bsp_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const char * UT_BSP_GetOptionString(int32 OptionNum)
}


void UT_BSP_Setup(const char *Name)
void UT_BSP_Setup(void)
{
int status;
int i;
Expand Down Expand Up @@ -280,7 +280,7 @@ void UT_BSP_Setup(const char *Name)
be sent to the console in case of a slow port */
rtems_task_wake_after(50);

UT_BSP_DoText(UTASSERT_CASETYPE_BEGIN, Name);
UT_BSP_DoText(UTASSERT_CASETYPE_BEGIN, "PC-RTEMS UNIT TEST");
}


Expand Down Expand Up @@ -465,19 +465,16 @@ rtems_task Init(
rtems_task_argument ignored
)
{
UT_BSP_Setup("PC-RTEMS UNIT TEST");

/*
** Call application specific entry point.
** This is supposed to call OS_API_Init()
*/
OS_Application_Startup();

/*
** In unit test mode, call the UtTest_Run function (part of UT Assert library)
** The OS_Application_Run function is part of UT Assert library
*/
UtTest_Run();
UT_BSP_EndTest(UtAssert_GetCounters());
OS_Application_Run();

rtems_shutdown_executive(UtAssert_GetFailCount() != 0);
}
Expand Down
7 changes: 6 additions & 1 deletion src/os/inc/osapi-os-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ typedef void (*OS_ArgCallback_t)(uint32 object_id, void *arg);

/*
** Prototype for application startup function.
** This is implemented by the user application
** This is implemented by the BSP or user application
*/
void OS_Application_Startup(void);

/*
** Prototype for application run function.
** This is implemented by the BSP or user application
*/
void OS_Application_Run(void);

/*
** Exported Functions
Expand Down
29 changes: 29 additions & 0 deletions src/os/posix/ostimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
int status;
int i;
struct sigevent evp;
struct timespec ts;
OS_impl_timebase_internal_record_t *local;
OS_common_record_t *global;
OS_U32ValueWrapper_t arg;
Expand Down Expand Up @@ -403,6 +404,34 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
sigemptyset(&local->sigset);
sigaddset(&local->sigset, local->assigned_signal);

/*
* Ensure that the chosen signal is NOT already pending.
*
* Perform a "sigtimedwait" with a zero timeout to poll the
* status of the selected signal. RT signals are also queued,
* so this needs to be called in a loop to until sigtimedwait()
* returns an error.
*
* The max number of signals that can be queued is available
* via sysconf() as the _SC_SIGQUEUE_MAX value.
*
* The output is irrelevant here; the objective is to just ensure
* that the signal is not already pending.
*/
i = sysconf( _SC_SIGQUEUE_MAX);
do
{
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (sigtimedwait(&local->sigset, NULL, &ts) < 0)
{
/* signal is NOT pending */
break;
}
--i;
}
while(i > 0);

/*
** Initialize the sigevent structures for the handler.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/tests/bin-sem-flush-test/bin-sem-flush-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void task_3(void)
/*
** Main function
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/bin-sem-test/bin-sem-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void BinSemCheck(void)
}


void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void BinSemTimeoutCheck(void)
UtAssert_True(task_1_timeouts <= limit, "Task 1 timeouts=%u <= %u", (unsigned int)task_1_timeouts, (unsigned int)limit);
}

void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/count-sem-test/count-sem-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void task_3(void)
}
}

void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/file-api-test/file-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ os_fs_err_name_t errname;

/* *************************************** MAIN ************************************** */

void OS_Application_Startup(void)
void UtTest_Setup(void)
{
errname[0] = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/tests/mutex-test/mutex-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void task_3(void)
}
}

void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/osal-core-test/osal-core-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void TestMutexes(void);
void TestGetInfos(void);

/* *************************************** MAIN ************************************** */
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/queue-timeout-test/queue-timeout-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void QueueTimeoutCheck(void)

}

void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/sem-speed-test/sem-speed-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void task_2(void)
}
}

void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/symbol-api-test/symbol-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void TestSymbolApi(void)
} /* end TestSymbolApi */


void OS_Application_Startup(void)
void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/timer-test/timer-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void test_func(uint32 timer_id)

/* ********************** MAIN **************************** */

void OS_Application_Startup(void)
void UtTest_Setup(void)
{

if (OS_API_Init() != OS_SUCCESS)
Expand Down
4 changes: 2 additions & 2 deletions src/unit-test-coverage/portable/coveragetest-posixfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ void Osapi_TearDown(void)

#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Task_Setup, Osapi_TearDown, #test)

/* Osapi_AddTestCase_Tasks
/* UtTest_Setup
*
* Purpose:
* Registers the test cases to execute with the unit test tool
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
ADD_TEST(OS_FileOpen_Impl);
ADD_TEST(OS_FileStat_Impl);
Expand Down
4 changes: 2 additions & 2 deletions src/unit-test-coverage/portable/coveragetest-posixgettime.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ void Osapi_TearDown(void)

#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Task_Setup, Osapi_TearDown, #test)

/* Osapi_AddTestCase_Tasks
/* UtTest_Setup
*
* Purpose:
* Registers the test cases to execute with the unit test tool
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
ADD_TEST(OS_GetLocalTime_Impl);
ADD_TEST(OS_SetLocalTime_Impl);
Expand Down
4 changes: 2 additions & 2 deletions src/unit-test-coverage/portable/coveragetest-posixio.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ void Osapi_TearDown(void)

#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Task_Setup, Osapi_TearDown, #test)

/* Osapi_AddTestCase_Tasks
/* UtTest_Setup
*
* Purpose:
* Registers the test cases to execute with the unit test tool
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
ADD_TEST(OS_GenericClose_Impl);
ADD_TEST(OS_GenericSeek_Impl);
Expand Down
4 changes: 2 additions & 2 deletions src/unit-test-coverage/posix/src/coveragetest-osapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,12 @@ void Osapi_TearDown(void)

#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Task_Setup, Osapi_TearDown, #test)

/* Osapi_AddTestCase_Tasks
/* UtTest_Setup
*
* Purpose:
* Registers the test cases to execute with the unit test tool
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
ADD_TEST(OS_Lock_Global_Impl);
ADD_TEST(OS_Unlock_Global_Impl);
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void Osapi_TearDown(void)
/*
* Register the test cases to execute with the unit test tool
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
ADD_TEST(OS_BinSemAPI_Init);
ADD_TEST(OS_BinSemCreate);
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void Osapi_TearDown(void)
/*
* Register the test cases to execute with the unit test tool
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
ADD_TEST(OS_GetLocalTime);
ADD_TEST(OS_SetLocalTime);
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void Osapi_TearDown(void)
/*
* Register the test cases to execute with the unit test tool
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
ADD_TEST(OS_API_Init);
ADD_TEST(OS_DeleteAllObjects);
Expand Down
2 changes: 1 addition & 1 deletion src/unit-test-coverage/shared/src/coveragetest-countsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void Osapi_TearDown(void)
/*
* Register the test cases to execute with the unit test tool
*/
void OS_Application_Startup(void)
void UtTest_Setup(void)
{
ADD_TEST(OS_CountSemAPI_Init);
ADD_TEST(OS_CountSemCreate);
Expand Down
Loading

0 comments on commit 702bf5e

Please sign in to comment.