Skip to content

Commit

Permalink
Revise file name string sizes in AssertFatalAdapter events (#2796)
Browse files Browse the repository at this point in the history
* Revise file name strings for assertion events

* Fix FPP tests

* Remove debug print statements

* Add comments to config files

* Revise FpConfig

Also fix bug in CmdSplitterTester

* Shorten file name length from 256 to 200

For consitency with AMPCS compatibility code
AMPCS arguments have max size 255
  • Loading branch information
bocchino authored Jul 24, 2024
1 parent cd5dbc0 commit 129d7f5
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 19 deletions.
4 changes: 3 additions & 1 deletion FppTest/component/tests/EventTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ void Tester ::testEvent(NATIVE_INT_TYPE portNum, FppTest::Types::LogStringParams

ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_EventString_SIZE(1);
ASSERT_EVENTS_EventString(portNum, data.args.val1.toChar(), data.args.val2.toChar());
Fw::StringTemplate<80> arg1(data.args.val1);
Fw::StringTemplate<100> arg2(data.args.val2);
ASSERT_EVENTS_EventString(portNum, arg1.toChar(), arg2.toChar());

this->printTextLogHistory(stdout);
}
Expand Down
2 changes: 1 addition & 1 deletion Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ namespace Svc {
Fw::LogStringArg fileArg(file);
#endif

CHAR msg[FW_ASSERT_TEXT_SIZE] = {0};
CHAR msg[Fw::StringBase::BUFFER_SIZE(FW_ASSERT_TEXT_SIZE)] = {0};
Fw::defaultReportAssert(file,lineNo,numArgs,arg1,arg2,arg3,arg4,arg5,arg6,msg,sizeof(msg));
// fprintf(stderr... allocates large buffers on stack as stderr is unbuffered by the OS
// and this can conflict with the traditionally smaller stack sizes.
Expand Down
16 changes: 8 additions & 8 deletions Svc/AssertFatalAdapter/AssertFatalEvents.fppi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@ An assert happened
event AF_ASSERT_0(
file: string size 80 @< The source file of the assert
file: string size AssertFatalAdapterEventFileSize @< The source file of the assert
line: U32 @< Line number of the assert
) \
severity fatal \
Expand All @@ -9,7 +9,7 @@ event AF_ASSERT_0(

@ An assert happened
event AF_ASSERT_1(
file: string size 80 @< The source file of the assert
file: string size AssertFatalAdapterEventFileSize @< The source file of the assert
line: U32 @< Line number of the assert
arg1: U32 @< First assert argument
) \
Expand All @@ -19,7 +19,7 @@ event AF_ASSERT_1(

@ An assert happened
event AF_ASSERT_2(
file: string size 80 @< The source file of the assert
file: string size AssertFatalAdapterEventFileSize @< The source file of the assert
line: U32 @< Line number of the assert
arg1: U32 @< First assert argument
arg2: U32 @< Second assert argument
Expand All @@ -30,7 +30,7 @@ event AF_ASSERT_2(

@ An assert happened
event AF_ASSERT_3(
file: string size 80 @< The source file of the assert
file: string size AssertFatalAdapterEventFileSize @< The source file of the assert
line: U32 @< Line number of the assert
arg1: U32 @< First assert argument
arg2: U32 @< Second assert argument
Expand All @@ -42,7 +42,7 @@ event AF_ASSERT_3(

@ An assert happened
event AF_ASSERT_4(
file: string size 80 @< The source file of the assert
file: string size AssertFatalAdapterEventFileSize @< The source file of the assert
line: U32 @< Line number of the assert
arg1: U32 @< First assert argument
arg2: U32 @< Second assert argument
Expand All @@ -55,7 +55,7 @@ event AF_ASSERT_4(

@ An assert happened
event AF_ASSERT_5(
file: string size 80 @< The source file of the assert
file: string size AssertFatalAdapterEventFileSize @< The source file of the assert
line: U32 @< Line number of the assert
arg1: U32 @< First assert argument
arg2: U32 @< Second assert argument
Expand All @@ -69,7 +69,7 @@ event AF_ASSERT_5(

@ An assert happened
event AF_ASSERT_6(
file: string size 80 @< The source file of the assert
file: string size AssertFatalAdapterEventFileSize @< The source file of the assert
line: U32 @< Line number of the assert
arg1: U32 @< First assert argument
arg2: U32 @< Second assert argument
Expand All @@ -84,7 +84,7 @@ event AF_ASSERT_6(

@ An unexpected assert happened
event AF_UNEXPECTED_ASSERT(
file: string size 80 @< The source file of the assert
file: string size AssertFatalAdapterEventFileSize @< The source file of the assert
line: U32 @< Line number of the assert
numArgs: U32 @< Number of unexpected arguments
) \
Expand Down
10 changes: 8 additions & 2 deletions Svc/AssertFatalAdapter/test/ut/AssertFatalAdapterTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
//
// ======================================================================

#include "AssertFatalAdapterTester.hpp"
#include "Fw/Types/String.hpp"
#include "Fw/Types/StringUtils.hpp"
#include "AssertFatalAdapterTester.hpp"
#include "config/FppConstantsAc.hpp"

#define INSTANCE 0
#define MAX_HISTORY_SIZE 10
Expand Down Expand Up @@ -40,7 +41,12 @@ namespace Svc {
void AssertFatalAdapterTester::testAsserts() {

U32 lineNo;
char file[80 + 1]; // Limit to 80 characters in the port call

// Apply all truncations to file buffer size
const FwSizeType fileMaxSize =
FW_MIN(FW_MIN(AssertFatalAdapterEventFileSize, FW_LOG_STRING_MAX_SIZE), FW_ASSERT_TEXT_SIZE);

char file[Fw::StringBase::BUFFER_SIZE(fileMaxSize)];
Fw::String fileString;

// Asserts may be turned off resulting in this component doing a no-op
Expand Down
2 changes: 1 addition & 1 deletion Svc/CmdSplitter/test/ut/CmdSplitterTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void CmdSplitterTester ::test_response_forwarding() {
Fw::CmdResponse response;
response.e = static_cast<Fw::CmdResponse::T>(STest::Pick::lowerUpper(0, Fw::CmdResponse::NUM_CONSTANTS));
U32 cmdSeq = static_cast<U32>(STest::Pick::any());
this->active_command_source = static_cast<NATIVE_INT_TYPE>(STest::Pick::lowerUpper(
this->active_command_source = static_cast<NATIVE_INT_TYPE>(STest::Pick::startLength(
0, CmdDispatcherSequencePorts));

this->invoke_to_seqCmdStatus(this->active_command_source, opcode, cmdSeq, response);
Expand Down
7 changes: 5 additions & 2 deletions Svc/TlmChan/test/ut/TlmChanTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
static const NATIVE_UINT_TYPE TEST_CHAN_SIZE = sizeof(FwChanIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32);
static const NATIVE_UINT_TYPE CHANS_PER_COMBUFFER =
(FW_COM_BUFFER_MAX_SIZE - sizeof(FwPacketDescriptorType)) / TEST_CHAN_SIZE;
static constexpr FwSizeType INTEGER_DIVISION_ROUNDED_UP(FwSizeType a, FwSizeType b) {
return ((a % b) == 0) ? (a / b) : (a / b) + 1;
}

namespace Svc {

Expand Down Expand Up @@ -75,7 +78,7 @@ void TlmChanTester::runMultiChannel() {
// do a run, and all the packets should be sent
this->doRun(true);
ASSERT_TRUE(this->m_bufferRecv);
ASSERT_EQ((FW_NUM_ARRAY_ELEMENTS(ID_0) / CHANS_PER_COMBUFFER) + 1, this->m_numBuffs);
ASSERT_EQ(INTEGER_DIVISION_ROUNDED_UP(FW_NUM_ARRAY_ELEMENTS(ID_0), CHANS_PER_COMBUFFER), this->m_numBuffs);
ASSERT_EQ(1, this->component.m_activeBuffer);

// verify packets
Expand All @@ -102,7 +105,7 @@ void TlmChanTester::runMultiChannel() {
// do a run, and all the packets should be sent
this->doRun(true);
ASSERT_TRUE(this->m_bufferRecv);
ASSERT_EQ((FW_NUM_ARRAY_ELEMENTS(ID_1) / CHANS_PER_COMBUFFER) + 1, this->m_numBuffs);
ASSERT_EQ(INTEGER_DIVISION_ROUNDED_UP(FW_NUM_ARRAY_ELEMENTS(ID_1), CHANS_PER_COMBUFFER), this->m_numBuffs);
ASSERT_EQ(0, this->component.m_activeBuffer);

// verify packets
Expand Down
8 changes: 7 additions & 1 deletion config/AcConstants.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ constant DpManagerNumPorts = 5
constant DpWriterNumProcPorts = 5

@ The size of a file name string
constant FileNameStringSize = 256
constant FileNameStringSize = 200

@ The size of a file name in an AssertFatalAdapter event
@ Note: File names in assertion failures are also truncated by
@ the constants FW_ASSERT_TEXT_SIZE and FW_LOG_STRING_MAX_SIZE, set
@ in FpConfig.h.
constant AssertFatalAdapterEventFileSize = FileNameStringSize

# ----------------------------------------------------------------------
# Hub connections. Connections on all deployments should mirror these settings.
Expand Down
8 changes: 5 additions & 3 deletions config/FpConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ typedef FwIndexType FwQueueSizeType;
#endif

// Define max length of assert string
// Note: This constant truncates file names in assertion failure event reports
#ifndef FW_ASSERT_TEXT_SIZE
#define FW_ASSERT_TEXT_SIZE 120 //!< Size of string used to store assert description
#define FW_ASSERT_TEXT_SIZE 256 //!< Size of string used to store assert description
#endif

// Adjust various configuration parameters in the architecture. Some of the above enables may disable some of the values
Expand Down Expand Up @@ -264,7 +265,7 @@ typedef FwIndexType FwQueueSizeType;

// Specifies the size of the buffer that contains a communications packet.
#ifndef FW_COM_BUFFER_MAX_SIZE
#define FW_COM_BUFFER_MAX_SIZE 128 //!< Max size of Fw::Com buffer
#define FW_COM_BUFFER_MAX_SIZE 512
#endif

// Specifies the size of the buffer that contains the serialized command arguments.
Expand Down Expand Up @@ -294,8 +295,9 @@ typedef FwIndexType FwQueueSizeType;
#endif

// Specifies the maximum size of a string in a log event
// Note: This constant truncates file names in assertion failure event reports
#ifndef FW_LOG_STRING_MAX_SIZE
#define FW_LOG_STRING_MAX_SIZE 100 //!< Max size of log string parameter type
#define FW_LOG_STRING_MAX_SIZE 200 //!< Max size of log string parameter type
#endif

// Specifies the size of the buffer that contains the serialized telemetry value.
Expand Down

0 comments on commit 129d7f5

Please sign in to comment.