nasa / cFE

The Core Flight System (cFS) Core Flight Executive (cFE)
Apache License 2.0
408 stars 200 forks source link

Unit tests fail to build when MESSAGE_FORMAT_IS_CCSDS_VER_2 is enabled #618

Closed johnphamngc closed 4 years ago

johnphamngc commented 4 years ago

Describe the bug Unit tests fail to build when MESSAGE_FORMAT_IS_CCSDS_VER_2 is enabled

To Reproduce Enable MESSAGE_FORMAT_IS_CCSDS_VER_2 in *mission_cfg.h Run make CFLAGS="-m32 -Wno-format" SIMULATION=native ENABLE_UNIT_TESTS=true

Expected behavior Compilation succeeds, however build actually fails due to missing #include

Code snips This can be fixed by doing the following

--- a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c
+++ b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c
@@ -34,6 +34,8 @@
 */
 #include <string.h>
 #include "cfe.h"
+#include "cfe_platform_cfg.h"
+#include "../sb/cfe_sb_msg_id_util.h"
 #include "utstubs.h"

However, subsequently a checksum error is encountered when running the tests. This was worked around by doing the following, but unsure if the workaround is correct.

--- a/fsw/cfe-core/unit-test/sb_UT.c
+++ b/fsw/cfe-core/unit-test/sb_UT.c
@@ -9456,7 +9456,7 @@ void Test_CFE_SB_ChecksumUtils(void)
 #ifndef MESSAGE_FORMAT_IS_CCSDS_VER_2
     ExpRtnFrmGet = 0x2f;
 #else
-    ExpRtnFrmGet = 0x65;
+    ExpRtnFrmGet = 0x61;
 #endif

     /* Validation expected to return true */

System observed on:

Reporter Info John N Pham, Northrop Grumman

johnphamngc commented 4 years ago

It looks like Test_CFE_SB_ChecksumUtils has further issues w/ CCSDSv2, as it assumes SID = MsgID in multiple cases, and doesn't account for the fact that ApidQSystemId is populated w/ the spacecraft ID by CFE_SB_InitMsg (which is a user configurable value, causing ExpRtnFrmGet to be wrong if the spacecraft ID is changed from the defaults).

jphickey commented 4 years ago

I mistakenly filed a duplicate ticket about this because I just discovered it myself. Looks like there are a few issues in here.