From f4af70f82dff9f20d8faa343b124d65c2096f196 Mon Sep 17 00:00:00 2001 From: anh Date: Wed, 8 Jan 2020 11:19:42 -0500 Subject: [PATCH 1/8] Fix #459, resolve doxygen obsolete warning --- cmake/cfe-common.doxyfile.in | 7 +------ cmake/osal-common.doxyfile.in | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/cmake/cfe-common.doxyfile.in b/cmake/cfe-common.doxyfile.in index fe3aa34cc..3343853bd 100644 --- a/cmake/cfe-common.doxyfile.in +++ b/cmake/cfe-common.doxyfile.in @@ -26,7 +26,6 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 @@ -93,7 +92,6 @@ GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES -SHOW_DIRECTORIES = YES FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages @@ -159,7 +157,6 @@ HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO HTML_DYNAMIC_SECTIONS = NO CHM_FILE = @@ -206,9 +203,7 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = +XML_OUTPUT = xml XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output diff --git a/cmake/osal-common.doxyfile.in b/cmake/osal-common.doxyfile.in index 6c4c39e62..44d52c3b0 100644 --- a/cmake/osal-common.doxyfile.in +++ b/cmake/osal-common.doxyfile.in @@ -26,7 +26,6 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 @@ -66,7 +65,6 @@ GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES -SHOW_DIRECTORIES = YES FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages @@ -128,7 +126,6 @@ HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO HTML_DYNAMIC_SECTIONS = NO CHM_FILE = @@ -175,9 +172,7 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = +XML_OUTPUT = xml XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output From b5c369a9165f139e8b4838f9e618be9516ccdd9f Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 8 Jan 2020 16:01:45 -0500 Subject: [PATCH 2/8] Fix #355: Add global scope option to omit deprecated items Adds a "global_build_options.cmake" file akin to the existing arch_build/mission_build option files. Include an example of this file that optionally does add_definitions() to omit the deprected elements for build testing. --- CMakeLists.txt | 6 +++++ cmake/sample_defs/global_build_options.cmake | 25 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 cmake/sample_defs/global_build_options.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b859fee3a..66fe338b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,12 @@ include(${MISSION_DEFS}/targets.cmake) # Scan the list of targets and organize by target system type. read_targetconfig() +# Include global-scope build customization +# Note if this feature is used it should only set basic options +# that have wide support (e.g. add_definitions). It should not +# set anything target or machine specific. +include("${MISSION_DEFS}/global_build_options.cmake" OPTIONAL) + # Additionally the target mission might require additional # custom build steps or override some routines. In particular # some architectures might need some special installation steps diff --git a/cmake/sample_defs/global_build_options.cmake b/cmake/sample_defs/global_build_options.cmake new file mode 100644 index 000000000..2f49e0dda --- /dev/null +++ b/cmake/sample_defs/global_build_options.cmake @@ -0,0 +1,25 @@ +# +# Example global_build_options.cmake +# ---------------------------------- +# +# This may set global definitions that apply to ALL targets in ALL scopes, +# including FSW code that is cross-compiled for a target as well as code +# built for the development host itself (native). +# +# As such, it should only invoke basic commands that have wide applicability, +# such as "add_definitions()" for macro definitions that should be set +# globally. It should not include any compiler-specific options that might +# change between compiler vendors or target processor families. +# + +# If the OMIT_DEPRECATED flag is specified, then define the respective macros +# that omit the deprecated features from the build. This is conditional in this +# example for CI purposes, so it can be tested both ways. Most projects would +# likely set this only one way. +set(OMIT_DEPRECATED $ENV{OMIT_DEPRECATED} CACHE STRING "Omit deprecated elements") +if (OMIT_DEPRECATED) + message (STATUS "OMIT_DEPRECATED=true: Not including deprecated elements in build") + add_definitions(-DCFE_OMIT_DEPRECATED_6_6 -DOSAL_OMIT_DEPRECATED) +else() + message (STATUS "OMIT_DEPRECATED=false: Deprecated elements included in build") +endif (OMIT_DEPRECATED) From ebd356b7d81656d60211fcced597573aef13f39b Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 8 Jan 2020 15:33:08 -0500 Subject: [PATCH 3/8] Fix #24: Add strict warning flags Add extra compile options for mission scope and arch scope. These are separated to support cross compile environments that do not/cannot use the same flags on both builds. For "mission" build the targets are never cross compiled, only built for the native host machine. It should be safe to assume a compiler in the GCC family and the strict warnings should _always_ be applicable here. For "arch" build the options are compiler vendor dependent. The file as-supplied can only be used if all the target cross compilers are in the same family and support the same warning options. However, this file can be modified without affecting the options used for the host side tools. --- cmake/sample_defs/arch_build.cmake | 37 +++++++++++++++++++++++++++ cmake/sample_defs/mission_build.cmake | 27 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 cmake/sample_defs/arch_build.cmake create mode 100644 cmake/sample_defs/mission_build.cmake diff --git a/cmake/sample_defs/arch_build.cmake b/cmake/sample_defs/arch_build.cmake new file mode 100644 index 000000000..aa0c1ec35 --- /dev/null +++ b/cmake/sample_defs/arch_build.cmake @@ -0,0 +1,37 @@ +# +# Example arch_build.cmake +# ------------------------- +# +# This file will be automatically included in the arch-specific build scope +# +# Definitions and options specified here will be used when cross-compiling +# _all_ FSW code for _all_ targets defined in targets.cmake. +# +# Avoid machine-specific code generation options in this file (e.g. -f,-m options); such +# options should be localized to the toolchain file such that they will only be +# included on the machines where they apply. +# +# CAUTION: In heterogeneous environments where different cross compilers are +# used for different CPUs, particularly if from different vendors, it is likely +# that compile options will need to be different as well. +# +# In general, options in this file can only be used in cases where all CPUs use a +# compiler from the same vendor and/or are all GCC based such that they accept similar +# command line options. +# +# This file can alternatively be named as "arch_build_${TARGETSYSTEM}.cmake" +# where ${TARGETSYSTEM} represents the system type, matching the toolchain. +# +# These example options assume a GCC-style toolchain is used for cross compilation, +# and uses the same warning options that are applied at the mission level. +# +add_compile_options( + -std=c99 # Target the C99 standard (without gcc extensions) + -pedantic # Issue all the warnings demanded by strict ISO C + -Wall # Warn about most questionable operations + -Wstrict-prototypes # Warn about missing prototypes + -Wwrite-strings # Warn if not treating string literals as "const" + -Wpointer-arith # Warn about suspicious pointer operations + -Werror # Treat warnings as errors (code should be clean) +) + diff --git a/cmake/sample_defs/mission_build.cmake b/cmake/sample_defs/mission_build.cmake new file mode 100644 index 000000000..0cd78732e --- /dev/null +++ b/cmake/sample_defs/mission_build.cmake @@ -0,0 +1,27 @@ +# +# Example mission_build.cmake +# --------------------------- +# +# This file will be automatically included in the top level ("mission") build scope +# +# Definitions and options specified here will be used when building local tools and +# other code that runs on the development host, but do _NOT_ apply to flight software +# (embedded) code or anything built for the target machine. +# +# These options assume a GCC toolchain but a similar set should be applicable to clang. +# +add_compile_options( + -std=c99 # Target the C99 standard (without gcc extensions) + -pedantic # Issue all the warnings demanded by strict ISO C + -Wall # Warn about most questionable operations + -Wstrict-prototypes # Warn about missing prototypes + -Wwrite-strings # Warn if not treating string literals as "const" + -Wpointer-arith # Warn about suspicious pointer operations + -Werror # Treat warnings as errors (code should be clean) +) + +# The _XOPEN_SOURCE directive is required for glibc to enable conformance with the +# the X/Open standard version 6, which includes POSIX.1c as well as SUSv2/UNIX98 extensions. +add_definitions( + -D_XOPEN_SOURCE=600 +) From 7a2f49b58ba114b5b0925d805f8ac4175a359933 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 9 Jan 2020 12:16:03 -0500 Subject: [PATCH 4/8] Issue #24: Add _custom suffix to extension files Add a _custom suffix to differentiate the customization file from the base file in the cmake directory. --- CMakeLists.txt | 6 +++--- .../{arch_build.cmake => arch_build_custom.cmake} | 6 +++--- .../{mission_build.cmake => mission_build_custom.cmake} | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename cmake/sample_defs/{arch_build.cmake => arch_build_custom.cmake} (91%) rename cmake/sample_defs/{mission_build.cmake => mission_build_custom.cmake} (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b859fee3a..84fd2a502 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,10 +97,10 @@ read_targetconfig() # The custom script may override functions such as the # cfe_exec_do_install() and cfe_app_do_install() functions for this if (IS_CFS_ARCH_BUILD) - include("${MISSION_DEFS}/arch_build.cmake" OPTIONAL) - include("${MISSION_DEFS}/arch_build_${TARGETSYSTEM}.cmake" OPTIONAL) + include("${MISSION_DEFS}/arch_build_custom.cmake" OPTIONAL) + include("${MISSION_DEFS}/arch_build_custom_${TARGETSYSTEM}.cmake" OPTIONAL) elseif (IS_CFS_MISSION_BUILD) - include("${MISSION_DEFS}/mission_build.cmake" OPTIONAL) + include("${MISSION_DEFS}/mission_build_custom.cmake" OPTIONAL) endif (IS_CFS_ARCH_BUILD) # Call the prepare function defined by the sub-script diff --git a/cmake/sample_defs/arch_build.cmake b/cmake/sample_defs/arch_build_custom.cmake similarity index 91% rename from cmake/sample_defs/arch_build.cmake rename to cmake/sample_defs/arch_build_custom.cmake index aa0c1ec35..14d41a517 100644 --- a/cmake/sample_defs/arch_build.cmake +++ b/cmake/sample_defs/arch_build_custom.cmake @@ -1,6 +1,6 @@ # -# Example arch_build.cmake -# ------------------------- +# Example arch_build_custom.cmake +# ------------------------------- # # This file will be automatically included in the arch-specific build scope # @@ -19,7 +19,7 @@ # compiler from the same vendor and/or are all GCC based such that they accept similar # command line options. # -# This file can alternatively be named as "arch_build_${TARGETSYSTEM}.cmake" +# This file can alternatively be named as "arch_build_custom_${TARGETSYSTEM}.cmake" # where ${TARGETSYSTEM} represents the system type, matching the toolchain. # # These example options assume a GCC-style toolchain is used for cross compilation, diff --git a/cmake/sample_defs/mission_build.cmake b/cmake/sample_defs/mission_build_custom.cmake similarity index 94% rename from cmake/sample_defs/mission_build.cmake rename to cmake/sample_defs/mission_build_custom.cmake index 0cd78732e..ae256ba9b 100644 --- a/cmake/sample_defs/mission_build.cmake +++ b/cmake/sample_defs/mission_build_custom.cmake @@ -1,6 +1,6 @@ # -# Example mission_build.cmake -# --------------------------- +# Example mission_build_custom.cmake +# ---------------------------------- # # This file will be automatically included in the top level ("mission") build scope # From c5625fc1bcd9aeca4650ed3ac6faf998cb757f22 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 15 Jan 2020 14:53:32 -0500 Subject: [PATCH 5/8] Update #24: Also enable cast-align warning Include in the basic warning set. Note that at this time the CFE does not build cleanly on all architectures with this warning enabled, pending resolution of issue #313. --- cmake/sample_defs/arch_build_custom.cmake | 1 + cmake/sample_defs/mission_build_custom.cmake | 1 + 2 files changed, 2 insertions(+) diff --git a/cmake/sample_defs/arch_build_custom.cmake b/cmake/sample_defs/arch_build_custom.cmake index 14d41a517..ac1dd99b4 100644 --- a/cmake/sample_defs/arch_build_custom.cmake +++ b/cmake/sample_defs/arch_build_custom.cmake @@ -32,6 +32,7 @@ add_compile_options( -Wstrict-prototypes # Warn about missing prototypes -Wwrite-strings # Warn if not treating string literals as "const" -Wpointer-arith # Warn about suspicious pointer operations + -Wcast-align # Warn about casts that increase alignment requirements -Werror # Treat warnings as errors (code should be clean) ) diff --git a/cmake/sample_defs/mission_build_custom.cmake b/cmake/sample_defs/mission_build_custom.cmake index ae256ba9b..92506bc9a 100644 --- a/cmake/sample_defs/mission_build_custom.cmake +++ b/cmake/sample_defs/mission_build_custom.cmake @@ -17,6 +17,7 @@ add_compile_options( -Wstrict-prototypes # Warn about missing prototypes -Wwrite-strings # Warn if not treating string literals as "const" -Wpointer-arith # Warn about suspicious pointer operations + -Wcast-align # Warn about casts that increase alignment requirements -Werror # Treat warnings as errors (code should be clean) ) From 54fbccb53d555516c2d2f9b5af127726ac5f34ba Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Fri, 17 Jan 2020 16:10:23 -0800 Subject: [PATCH 6/8] Fix #101, Always increment sequence counter Adds logic and associated unit tests Removes no-longer-used EID --- fsw/cfe-core/src/inc/cfe_sb_events.h | 14 --- fsw/cfe-core/src/sb/cfe_sb_api.c | 26 ------ fsw/cfe-core/unit-test/sb_UT.c | 124 ++++++--------------------- 3 files changed, 24 insertions(+), 140 deletions(-) diff --git a/fsw/cfe-core/src/inc/cfe_sb_events.h b/fsw/cfe-core/src/inc/cfe_sb_events.h index c88cf3890..e547c53fa 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_events.h +++ b/fsw/cfe-core/src/inc/cfe_sb_events.h @@ -430,20 +430,6 @@ **/ #define CFE_SB_SUBSCRIPTION_RPT_EID 22 - -/** \brief 'Sending Unsubscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' -** \event 'Sending Unsubscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when SB subscription reporting is enabled, -** (which is disabled by default) and a subscription is successfully received. -**/ -#define CFE_SB_UNSUBSCRIPTION_RPT_EID 24 - - /** \brief 'Pipe Overflow,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' ** \event 'Pipe Overflow,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' ** diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/fsw/cfe-core/src/sb/cfe_sb_api.c index 43d1bb27a..64c674be1 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/fsw/cfe-core/src/sb/cfe_sb_api.c @@ -999,7 +999,6 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, uint32 PipeIdx; uint32 TskId = 0; bool MatchFound = false; - int32 Stat; CFE_SB_DestinationD_t *DestPtr = NULL; char FullName[(OS_MAX_API_NAME * 2)]; @@ -1081,31 +1080,6 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, }while((MatchFound == false)&&(DestPtr != NULL)); - /* if 'Destinations' was decremented to zero above... */ - if(RoutePtr->Destinations==0){ - CFE_SB.StatTlmMsg.Payload.MsgIdsInUse--; - CFE_SB_RouteIdxPush_Unsync(RouteIdx); /* Return the idx to the available list (stack) for reuse */ - CFE_SB_SetRoutingTblIdx(MsgKey,CFE_SB_INVALID_ROUTE_IDX); - - /* Send unsubscribe report only if there are zero requests for this pkt */ - if((CFE_SB.SubscriptionReporting == CFE_SB_ENABLE)&& - (Scope == CFE_SB_GLOBAL)) - { - CFE_SB.SubRprtMsg.Payload.MsgId = MsgId; - CFE_SB.SubRprtMsg.Payload.Pipe = PipeId; - CFE_SB.SubRprtMsg.Payload.Qos.Priority = 0; - CFE_SB.SubRprtMsg.Payload.Qos.Reliability = 0; - CFE_SB.SubRprtMsg.Payload.SubType = CFE_SB_UNSUBSCRIPTION; - CFE_SB_UnlockSharedData(__func__,__LINE__); - Stat = CFE_SB_SendMsg((CFE_SB_Msg_t *)&CFE_SB.SubRprtMsg); - CFE_EVS_SendEventWithAppID(CFE_SB_UNSUBSCRIPTION_RPT_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, - "Sending Unsubscription Report Msg=0x%x,Pipe=%d,Stat=0x%x", - (unsigned int)MsgId,(int)PipeId,(unsigned int)Stat); - CFE_SB_LockSharedData(__func__,__LINE__); - }/* end if */ - - }/* end if */ - CFE_SB_UnlockSharedData(__func__,__LINE__); CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_REMOVED_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index 424116338..40e78b5f4 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -4485,6 +4485,8 @@ void Test_Subscribe_MaxMsgIdCount(void) UT_Text("Begin Test for Maximum Message ID Count"); #endif + SB_ResetUnitTest(); + CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0"); CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); @@ -4739,6 +4741,7 @@ void Test_Subscribe_SubscriptionReporting(void) #endif SB_ResetUnitTest(); + ActRtn = CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); ExpRtn = CFE_SUCCESS; @@ -4816,7 +4819,7 @@ void Test_Subscribe_SubscriptionReporting(void) } else { - ExpRtn = 8; + ExpRtn = 6; ActRtn = UT_GetNumEventsSent(); if (ActRtn != ExpRtn) @@ -4923,7 +4926,6 @@ void Test_Unsubscribe_API(void) Test_Unsubscribe_Local(); Test_Unsubscribe_InvalParam(); Test_Unsubscribe_NoMatch(); - Test_Unsubscribe_SubscriptionReporting(); Test_Unsubscribe_InvalidPipe(); Test_Unsubscribe_InvalidPipeOwner(); Test_Unsubscribe_FirstDestWithMany(); @@ -5235,104 +5237,6 @@ void Test_Unsubscribe_NoMatch(void) TestStat, "Test_Unsubscribe_API", "No match test"); } /* end Test_Unsubscribe_NoMatch */ -/* -** Test message unsubscription response to enabling/disabling subscription -** reporting -*/ -void Test_Unsubscribe_SubscriptionReporting(void) -{ - CFE_SB_PipeId_t TestPipe; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; - uint32 CallerId = 0xFFFFFFFF; - uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test Unsubscribe Subscription Reporting"); -#endif - - SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, TestPipe); - CFE_SB_SetSubscriptionReporting(CFE_SB_ENABLE); - CFE_SB_Unsubscribe(MsgId, TestPipe); - ExpRtn = CFE_SB_UNSUBSCRIPTION; - ActRtn = CFE_SB.SubRprtMsg.Payload.SubType; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unsubscribe not enabled as expected in CFE_SB_Unsubscribe, " - "exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - CFE_SB_Subscribe(MsgId, TestPipe); - - /* Get the caller's Application ID */ - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_ES_GetAppID(&CallerId); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from GetAppID in unsubscribe test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - /* Subscribe to message: LOCAL */ - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_UnsubscribeFull(MsgId, TestPipe, CFE_SB_LOCAL, - CallerId); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from UnsubscribeFull in " - "subscription reporting test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - ExpRtn = 9; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else if (UT_EventIsInHistory(CFE_SB_UNSUBSCRIPTION_RPT_EID) == false) - { - UT_Text("CFE_SB_UNSUBSCRIPTION_RPT_EID not sent"); - TestStat = CFE_FAIL; - } - } - } - } - - CFE_SB_SetSubscriptionReporting(CFE_SB_DISABLE); - CFE_SB_DeletePipe(TestPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Subscription reporting test"); -} /* end Test_Unsubscribe_SubscriptionReporting */ - /* ** Test message unsubscription response to an invalid pipe ID */ @@ -6119,6 +6023,26 @@ void Test_SendMsg_SequenceCount(void) TestStat = CFE_FAIL; } + CFE_SB_Unsubscribe(MsgId, PipeId); /* should have no subscribers now */ + + CFE_SB_SendMsg(TlmPktPtr); /* increment to 3 */ + + CFE_SB_Subscribe(MsgId, PipeId); /* resubscribe so we can receive a msg */ + + CFE_SB_SendMsg(TlmPktPtr); /* increment to 4 */ + + CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); + + if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 4) + { + snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, + "Unexpected sequence count for send in sequence count test, " + "exp=4, act=%d", + CCSDS_RD_SEQ(PtrToMsg->Hdr)); + UT_Text(cMsg); + TestStat = CFE_FAIL; + } + CFE_SB_DeletePipe(PipeId); UT_Report(__FILE__, __LINE__, TestStat, "Test_SendMsg_API", From dae5436c2d192c1f56427e72faf6d140b3e687a8 Mon Sep 17 00:00:00 2001 From: Dan Knutsen Date: Tue, 7 Jan 2020 14:02:23 -0500 Subject: [PATCH 7/8] Fix #412, Clean table services comments/references --- fsw/cfe-core/src/tbl/cfe_tbl_api.c | 4 +- fsw/cfe-core/src/tbl/cfe_tbl_internal.c | 18 ++++---- fsw/cfe-core/src/tbl/cfe_tbl_internal.h | 35 --------------- fsw/cfe-core/src/tbl/cfe_tbl_task.h | 23 ++++++++++ fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c | 8 ++-- fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h | 57 +++++++++++++----------- 6 files changed, 70 insertions(+), 75 deletions(-) diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/fsw/cfe-core/src/tbl/cfe_tbl_api.c index 5f3270604..07ca8f9fb 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_api.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_api.c @@ -1628,7 +1628,7 @@ int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) return Status; -} +} /* End of CFE_TBL_Modified() */ /******************************************************************* @@ -1673,7 +1673,7 @@ int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, } return Status; -} +} /* End of CFE_TBL_NotifyByMessage() */ /************************/ /* End of File Comment */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c index 2f62a0dcf..00e4a7bd4 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c @@ -255,7 +255,7 @@ int32 CFE_TBL_EarlyInit (void) return Status; -}/* end CFE_TBL_EarlyInit */ +}/* End CFE_TBL_EarlyInit */ /******************************************************************* @@ -304,7 +304,7 @@ void CFE_TBL_InitRegistryRecord (CFE_TBL_RegistryRec_t *RegRecPtr) RegRecPtr->ActiveBufferIndex = 0; RegRecPtr->Name[0] = '\0'; RegRecPtr->LastFileLoaded[0] = '\0'; -} +} /* End CFE_TBL_InitRegistryRecord */ /******************************************************************* @@ -433,7 +433,7 @@ int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, uint32 ThisAppId) } return Status; -} +} /* End of CFE_TBL_CheckAccessRights() */ /******************************************************************* ** @@ -1033,7 +1033,7 @@ int32 CFE_TBL_LoadFromFile(CFE_TBL_LoadBuff_t *WorkingBufferPtr, } return Status; -} +} /* End of CFE_TBL_LoadFromFile() */ /******************************************************************* @@ -1167,7 +1167,7 @@ void CFE_TBL_NotifyTblUsersOfUpdate(CFE_TBL_RegistryRec_t *RegRecPtr) AccessIterator = CFE_TBL_TaskData.Handles[AccessIterator].NextLink; } -} +} /* End of CFE_TBL_NotifyTblUsersOfUpdate() */ /******************************************************************* ** @@ -1422,7 +1422,7 @@ int32 CFE_TBL_CleanUpApp(uint32 AppId) } return CFE_SUCCESS; -} +} /* End of CFE_TBL_CleanUpApp() */ /******************************************************************* ** @@ -1446,7 +1446,7 @@ void CFE_TBL_FindCriticalTblInfo(CFE_TBL_CritRegRec_t **CritRegRecPtr, CFE_ES_CD break; } } -} +} /* End of CFE_TBL_FindCriticalTblInfo() */ /******************************************************************* @@ -1500,7 +1500,7 @@ void CFE_TBL_UpdateCriticalTblCDS(CFE_TBL_RegistryRec_t *RegRecPtr) } /* Don't bother notifying the caller of the problem since the active table is still legitimate */ -} +} /* End of CFE_TBL_UpdateCriticalTblCDS() */ /******************************************************************* @@ -1543,7 +1543,7 @@ int32 CFE_TBL_SendNotificationMsg(CFE_TBL_RegistryRec_t *RegRecPtr) } return Status; -} +} /* End of CFE_TBL_SendNotificationMsg() */ /************************/ /* End of File Comment */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h b/fsw/cfe-core/src/tbl/cfe_tbl_internal.h index c15283693..eff912186 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.h @@ -590,41 +590,6 @@ void CFE_TBL_UpdateCriticalTblCDS(CFE_TBL_RegistryRec_t *RegRecPtr); ******************************************************************************/ int32 CFE_TBL_SendNotificationMsg(CFE_TBL_RegistryRec_t *RegRecPtr); - -/*****************************************************************************/ -/** -** \brief Gathers data and puts it into the Housekeeping Message format -** -** \par Description -** Gathers data from the Table Services Application, computes necessary data values and identifies -** what Table Validation information needs to be reported in Housekeeping Telemetry. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \retval None -******************************************************************************/ -extern void CFE_TBL_GetHkData(void); - - -/*****************************************************************************/ -/** -** \brief Convert Table Registry Entry for a Table into a Message -** -** \par Description -** Extracts the Table Registry information for the table specified by the -** #CFE_TBL_TaskData_t::HkTlmTblRegIndex variable. It then formats the -** Registry contents into a format appropriate for downlink. -** -** \par Assumptions, External Events, and Notes: -** #CFE_TBL_TaskData_t::HkTlmTblRegIndex is assumed to be a valid index into -** the Table Registry. -** -** \retval None -******************************************************************************/ -extern void CFE_TBL_GetTblRegData(void); - - /*****************************************************************************/ /** ** \brief Performs a byte swap on a uint32 integer diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.h b/fsw/cfe-core/src/tbl/cfe_tbl_task.h index 029fd6f2f..93aba6ee4 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.h @@ -347,6 +347,29 @@ typedef struct * Functions */ +/*****************************************************************************/ +/** +** \brief Compares message with #CFE_TBL_CmdHandlerTbl to identify the message +** +** \par Description +** Searches the Command Handler Table for an entry matching the +** message ID and, if necessary, the Command Code. If an entry +** is not located, an error code is returned. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MessageID message ID of command message received on command pipe +** +** \param[in] CommandCode command code from command message received on command pipe +** +** \retval #CFE_SUCCESS \copydoc CFE_SUCCESS +** \retval #CFE_TBL_BAD_CMD_CODE \copydoc CFE_TBL_BAD_CMD_CODE +** \retval #CFE_TBL_BAD_MSG_ID \copydoc CFE_TBL_BAD_MSG_ID +** +******************************************************************************/ +extern int16 CFE_TBL_SearchCmdHndlrTbl(CFE_SB_MsgId_t MessageID, uint16 CommandCode); + /*****************************************************************************/ /** ** \brief cFE Table Services Core Application Initialization diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c index 8b6ae0899..67b264d6a 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c @@ -259,7 +259,7 @@ void CFE_TBL_GetHkData(void) sizeof(CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.LastTblUpdated].Name)); } } -} +} /* End of CFE_TBL_GetHkData() */ /******************************************************************* ** @@ -315,7 +315,7 @@ void CFE_TBL_GetTblRegData(void) sizeof(CFE_TBL_TaskData.TblRegPacket.Payload.LastFileLoaded), sizeof(RegRecPtr->LastFileLoaded)); CFE_ES_GetAppName(CFE_TBL_TaskData.TblRegPacket.Payload.OwnerAppName, RegRecPtr->OwnerAppId, sizeof(CFE_TBL_TaskData.TblRegPacket.Payload.OwnerAppName)); -} +} /* End of CFE_TBL_GetTblRegData() */ /******************************************************************* @@ -855,7 +855,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T } return ReturnCode; -} +} /* End of CFE_TBL_DumpToFile() */ /******************************************************************* ** @@ -1522,7 +1522,7 @@ void CFE_TBL_AbortLoad(CFE_TBL_RegistryRec_t *RegRecPtr) CFE_EVS_EventType_INFORMATION, "Table Load Aborted for '%s'", RegRecPtr->Name); -} +} /* End of CFE_TBL_AbortLoad() */ /************************/ /* End of File Comment */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h index 3667cd885..c71e28810 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h @@ -80,6 +80,38 @@ typedef struct { /* Command Message Processing Functions */ +/*****************************************************************************/ +/** +** \brief Gathers data and puts it into the Housekeeping Message format +** +** \par Description +** Gathers data from the Table Services Application, computes necessary data values and identifies +** what Table Validation information needs to be reported in Housekeeping Telemetry. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \retval None +******************************************************************************/ +extern void CFE_TBL_GetHkData(void); + +/*****************************************************************************/ +/** +** \brief Convert Table Registry Entry for a Table into a Message +** +** \par Description +** Extracts the Table Registry information for the table specified by the +** #CFE_TBL_TaskData_t::HkTlmTblRegIndex variable. It then formats the +** Registry contents into a format appropriate for downlink. +** +** \par Assumptions, External Events, and Notes: +** #CFE_TBL_TaskData_t::HkTlmTblRegIndex is assumed to be a valid index into +** the Table Registry. +** +** \retval None +******************************************************************************/ +extern void CFE_TBL_GetTblRegData(void); + /*****************************************************************************/ /** ** \brief Process Housekeeping Request Message @@ -299,31 +331,6 @@ int32 CFE_TBL_AbortLoadCmd(const CFE_TBL_AbortLoad_t *data); extern CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, const void *DumpDataAddr, uint32 TblSizeInBytes); - -/*****************************************************************************/ -/** -** \brief Compares message with #CFE_TBL_CmdHandlerTbl to identify the message -** -** \par Description -** Searches the Command Handler Table for an entry matching the -** message ID and, if necessary, the Command Code. If an entry -** is not located, an error code is returned. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MessageID message ID of command message received on command pipe -** -** \param[in] CommandCode command code from command message received on command pipe -** -** \retval #CFE_SUCCESS \copydoc CFE_SUCCESS -** \retval #CFE_TBL_BAD_CMD_CODE \copydoc CFE_TBL_BAD_CMD_CODE -** \retval #CFE_TBL_BAD_MSG_ID \copydoc CFE_TBL_BAD_MSG_ID -** -******************************************************************************/ - -extern int16 CFE_TBL_SearchCmdHndlrTbl(CFE_SB_MsgId_t MessageID, uint16 CommandCode); - /*****************************************************************************/ /** ** \brief Aborts load by freeing associated inactive buffers and sending event message From 067ffe230d1038a8f0b340e0453619998594f4d2 Mon Sep 17 00:00:00 2001 From: anh Date: Thu, 9 Jan 2020 13:18:41 -0500 Subject: [PATCH 8/8] Fix #189, Add test coverage for cfe_efs_task.c --- fsw/cfe-core/unit-test/evs_UT.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fsw/cfe-core/unit-test/evs_UT.c b/fsw/cfe-core/unit-test/evs_UT.c index b09d9c846..c2ee35260 100644 --- a/fsw/cfe-core/unit-test/evs_UT.c +++ b/fsw/cfe-core/unit-test/evs_UT.c @@ -53,7 +53,7 @@ static const char *EVS_SYSLOG_MSGS[] = "EVS:Error reading cmd pipe,RC=0x%08X\n", "EVS:Call to CFE_ES_RegisterApp Failed:RC=0x%08X\n", "EVS:Call to CFE_ES_GetAppID Failed:RC=0x%08X\n", - NULL, /* index 11 not used */ + "EVS:Call to CFE_EVS_Register Failed:RC=0x%08X\n", "EVS:Call to CFE_SB_CreatePipe Failed:RC=0x%08X\n", "EVS:Subscribing to Cmds Failed:RC=0x%08X\n", "EVS:Subscribing to HK Request Failed:RC=0x%08X\n" @@ -407,6 +407,15 @@ void Test_Init(void) "CFE_EVS_TaskInit", "Call to CFE_ES_RegisterApp failure"); + /* Test task initialization where event services fails */ + UT_InitData(); + UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetAppID), 2, -1); /* Set Failure in CFE_EVS_Register -> EVS_GetApp_ID */ + CFE_EVS_TaskInit(); + UT_Report(__FILE__, __LINE__, + UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[11]), + "CFE_EVS_TaskInit", + "Call to CFE_EVS_Register failure"); + /* Test task initialization where the pipe creation fails */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_SB_CreatePipe), 1, -1);