Skip to content

Commit

Permalink
Fix #2484, implement header files for testcase
Browse files Browse the repository at this point in the history
Move the message and table definitions into separate header files,
that follow the established naming patterns.
  • Loading branch information
jphickey committed Dec 19, 2023
1 parent 7f5ebcd commit 08e645f
Show file tree
Hide file tree
Showing 17 changed files with 379 additions and 239 deletions.
8 changes: 4 additions & 4 deletions modules/cfe_testcase/arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ set(TEST_PLATFORM_CONFIG_FILE_LIST
# the distribution default copies
foreach(TEST_CFGFILE ${TEST_PLATFORM_CONFIG_FILE_LIST})
get_filename_component(CFGKEY "${TEST_CFGFILE}" NAME_WE)
if (DEFINED TEST_CFGFILE_SRC_${CFGKEY})
set(DEFAULT_SOURCE "${TEST_CFGFILE_SRC_${CFGKEY}}")
if (DEFINED TESTCASE_CFGFILE_SRC_${CFGKEY})
set(DEFAULT_SOURCE GENERATED_FILE "${TESTCASE_CFGFILE_SRC_${CFGKEY}}")
else()
set(DEFAULT_SOURCE "${CMAKE_CURRENT_LIST_DIR}/config/default_${TEST_CFGFILE}")
set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${TEST_CFGFILE}")
endif()
generate_config_includefile(
FILE_NAME "${TEST_CFGFILE}"
FALLBACK_FILE ${DEFAULT_SOURCE}
${DEFAULT_SOURCE}
)
endforeach()
29 changes: 29 additions & 0 deletions modules/cfe_testcase/config/default_cfe_test_msg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 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
* CFE Test app (CFE_TEST) Application Message Definitions
*/
#ifndef CFE_TEST_MSG_H
#define CFE_TEST_MSG_H

#include "cfe_test_msgdefs.h"
#include "cfe_test_msgstruct.h"

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@

/**
* @file
* CFE Test app (CFE_TEST) Application Message IDs
* CFE Test app (CFE_TEST) Application Message Definitions
*/
#ifndef CFE_TEST_MSGIDS_H
#define CFE_TEST_MSGIDS_H
#ifndef CFE_TEST_MSGDEFS_H
#define CFE_TEST_MSGDEFS_H

#include "cfe_core_api_base_msgids.h"
#include "cfe_test_topicids.h"
#include "common_types.h"

/*
** cFE Command Message Id's
*/
#define CFE_TEST_CMD_MID CFE_PLATFORM_CMD_MID_BASE + CFE_MISSION_TEST_CMD_MSG /* 0x1802 */
/* A 64-bit payload (worst case for alignment) */
typedef struct CFE_TEST_TestPayload64
{
uint64 Value;
} CFE_TEST_TestPayload64_t;

/*
** CFE Telemetry Message Id's
*/
#define CFE_TEST_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_TEST_HK_TLM_MSG /* 0x0802 */
/* A 32-bit payload (most common case for alignment) */
typedef struct CFE_TEST_TestPayload32
{
uint32 Value;
} CFE_TEST_TestPayload32_t;

#endif
57 changes: 57 additions & 0 deletions modules/cfe_testcase/config/default_cfe_test_msgstruct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 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
* CFE Test app (CFE_TEST) Application Message Definitions
*/
#ifndef CFE_TEST_MSGSTRUCT_H
#define CFE_TEST_MSGSTRUCT_H

#include "cfe_msg_hdr.h"
#include "cfe_test_msgdefs.h"

/* A simple command message with a 64 bit payload */
typedef struct CFE_TEST_TestCmdMessage
{
CFE_MSG_CommandHeader_t CommandHeader;
CFE_TEST_TestPayload64_t Payload;
} CFE_TEST_TestCmdMessage64_t;

/* A simple telemetry message with a 64 bit payload */
typedef struct CFE_TEST_TestTlmMessage
{
CFE_MSG_TelemetryHeader_t TelemetryHeader;
CFE_TEST_TestPayload64_t Payload;
} CFE_TEST_TestTlmMessage64_t;

/* A simple command message with a 32 bit payload */
typedef struct
{
CFE_MSG_CommandHeader_t CommandHeader;
CFE_TEST_TestPayload32_t Payload;
} CFE_TEST_TestCmdMessage32_t;

/* A simple telemetry message with a 32 bit payload */
typedef struct
{
CFE_MSG_TelemetryHeader_t TelemetryHeader;
CFE_TEST_TestPayload32_t Payload;
} CFE_TEST_TestTlmMessage32_t;

#endif
9 changes: 1 addition & 8 deletions modules/cfe_testcase/config/default_cfe_test_tbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
#ifndef CFE_TEST_TBL_H
#define CFE_TEST_TBL_H

/*
* Test table structure
*/
typedef struct
{
uint16 Int1;
uint16 Int2;
} TBL_TEST_Table_t;
#include "cfe_test_tblstruct.h"

#endif /* CFE_TEST_TBL_H */
39 changes: 39 additions & 0 deletions modules/cfe_testcase/config/default_cfe_test_tblstruct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 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
*
* CFE Test Table struct definition
*/

#ifndef CFE_TEST_TBLSTRUCT_H
#define CFE_TEST_TBLSTRUCT_H

#include "common_types.h"

/*
* Test table structure
*/
typedef struct
{
uint16 Int1;
uint16 Int2;
} CFE_TEST_TestTable_t;

#endif /* CFE_TEST_TBLSTRUCT_H */
12 changes: 8 additions & 4 deletions modules/cfe_testcase/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
###########################################################

# The list of header files that control the TEST configuration
set(TEST_MISSION_CONFIG_FILE_LIST
set(TESTCASE_MISSION_CONFIG_FILE_LIST
cfe_test_msg.h
cfe_test_msgdefs.h
cfe_test_msgstruct.h
cfe_test_tbl.h
cfe_test_tblstruct.h
cfe_test_topicids.h
)

# Create wrappers around the all the config header files
# This makes them individually overridable by the missions, without modifying
# the distribution default copies
foreach(TEST_CFGFILE ${TEST_MISSION_CONFIG_FILE_LIST})
foreach(TEST_CFGFILE ${TESTCASE_MISSION_CONFIG_FILE_LIST})
get_filename_component(CFGKEY "${TEST_CFGFILE}" NAME_WE)
if (DEFINED TEST_CFGFILE_SRC_${CFGKEY})
set(DEFAULT_SOURCE GENERATED_FILE "${TEST_CFGFILE_SRC_${CFGKEY}}")
if (DEFINED TESTCASE_CFGFILE_SRC_${CFGKEY})
set(DEFAULT_SOURCE GENERATED_FILE "${TESTCASE_CFGFILE_SRC_${CFGKEY}}")
else()
set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${TEST_CFGFILE}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion modules/cfe_testcase/src/cfe_test_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/* Setup function to register a table */
void RegisterTestTable(void)
{
UtAssert_INT32_EQ(CFE_TBL_Register(&CFE_FT_Global.TblHandle, CFE_FT_Global.TblName, sizeof(TBL_TEST_Table_t),
UtAssert_INT32_EQ(CFE_TBL_Register(&CFE_FT_Global.TblHandle, CFE_FT_Global.TblName, sizeof(CFE_TEST_TestTable_t),
CFE_TBL_OPT_DEFAULT, NULL),
CFE_SUCCESS);
}
Expand Down
Loading

0 comments on commit 08e645f

Please sign in to comment.