From 50504c35cc19aea8561a1bd8318913a93b9baaa4 Mon Sep 17 00:00:00 2001 From: jsilveira Date: Wed, 13 Nov 2024 17:45:26 +0100 Subject: [PATCH 1/4] feat: implemented empty cmd seq event --- Svc/CmdSequencer/Events.fppi | 8 ++++++++ Svc/CmdSequencer/FPrimeSequence.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Svc/CmdSequencer/Events.fppi b/Svc/CmdSequencer/Events.fppi index 954645bdd0..8b3cf8633c 100644 --- a/Svc/CmdSequencer/Events.fppi +++ b/Svc/CmdSequencer/Events.fppi @@ -214,3 +214,11 @@ event CS_JoinWaitingNotComplete() \ severity warning high \ id 24 \ format "Still waiting for sequence file to complete" + +event CS_FileEmpty( + #fileName: string size 60 @< The name of the sequence file + ) \ + severity warning high \ + id 25 \ + format "Sequence file is empty. Ignoring." + #format "Sequence file {} is empty. Ignoring." \ No newline at end of file diff --git a/Svc/CmdSequencer/FPrimeSequence.cpp b/Svc/CmdSequencer/FPrimeSequence.cpp index f51343709a..6f508d3075 100644 --- a/Svc/CmdSequencer/FPrimeSequence.cpp +++ b/Svc/CmdSequencer/FPrimeSequence.cpp @@ -91,9 +91,14 @@ namespace Svc { } void CmdSequencerComponentImpl::FPrimeSequence :: - nextRecord(Record& record) + nextRecord(Record& record) { Fw::SerializeStatus status = this->deserializeRecord(record); + if (status == Fw::SerializeStatus::FW_DESERIALIZE_BUFFER_EMPTY) + { + this->m_component.log_WARNING_HI_CS_FileEmpty(); + return; + } FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); } From 8a2bca20b729c72bb52fc2b4b0e5ba9863e64ea3 Mon Sep 17 00:00:00 2001 From: jsilveira Date: Sat, 16 Nov 2024 17:51:57 +0100 Subject: [PATCH 2/4] feat: improved empty seq warnings --- Svc/CmdSequencer/CmdSequencerImpl.hpp | 3 +++ Svc/CmdSequencer/Events.cpp | 11 +++++++++++ Svc/CmdSequencer/Events.fppi | 9 ++++----- Svc/CmdSequencer/FPrimeSequence.cpp | 11 ++++++----- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Svc/CmdSequencer/CmdSequencerImpl.hpp b/Svc/CmdSequencer/CmdSequencerImpl.hpp index 4df41c99b2..feb8ee5117 100644 --- a/Svc/CmdSequencer/CmdSequencerImpl.hpp +++ b/Svc/CmdSequencer/CmdSequencerImpl.hpp @@ -111,6 +111,9 @@ namespace Svc { const FwTimeContextStoreType seqTimeContext //!< The sequence file time context ); + // No Records + void noRecords(); + PRIVATE: //! The enclosing component diff --git a/Svc/CmdSequencer/Events.cpp b/Svc/CmdSequencer/Events.cpp index 62f29e4dda..a4c11f117e 100644 --- a/Svc/CmdSequencer/Events.cpp +++ b/Svc/CmdSequencer/Events.cpp @@ -130,6 +130,17 @@ namespace Svc { ); component.error(); } + + void CmdSequencerComponentImpl::Sequence::Events :: + noRecords() + { + Fw::LogStringArg& logFileName = this->m_sequence.getLogFileName(); + CmdSequencerComponentImpl& component = this->m_sequence.m_component; + component.log_WARNING_LO_CS_NoRecords( + logFileName + ); + component.error(); + } } diff --git a/Svc/CmdSequencer/Events.fppi b/Svc/CmdSequencer/Events.fppi index 8b3cf8633c..f17ad14dfa 100644 --- a/Svc/CmdSequencer/Events.fppi +++ b/Svc/CmdSequencer/Events.fppi @@ -215,10 +215,9 @@ event CS_JoinWaitingNotComplete() \ id 24 \ format "Still waiting for sequence file to complete" -event CS_FileEmpty( - #fileName: string size 60 @< The name of the sequence file +event CS_NoRecords( + fileName: string size 60 @< The name of the sequence file ) \ - severity warning high \ + severity warning low \ id 25 \ - format "Sequence file is empty. Ignoring." - #format "Sequence file {} is empty. Ignoring." \ No newline at end of file + format "Sequence file {} has no records. Ignoring." \ No newline at end of file diff --git a/Svc/CmdSequencer/FPrimeSequence.cpp b/Svc/CmdSequencer/FPrimeSequence.cpp index 6f508d3075..a24c343be6 100644 --- a/Svc/CmdSequencer/FPrimeSequence.cpp +++ b/Svc/CmdSequencer/FPrimeSequence.cpp @@ -94,11 +94,6 @@ namespace Svc { nextRecord(Record& record) { Fw::SerializeStatus status = this->deserializeRecord(record); - if (status == Fw::SerializeStatus::FW_DESERIALIZE_BUFFER_EMPTY) - { - this->m_component.log_WARNING_HI_CS_FileEmpty(); - return; - } FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); } @@ -428,6 +423,12 @@ namespace Svc { const U32 numRecords = this->m_header.m_numRecords; Sequence::Record record; + if (numRecords == 0) + { + this->m_events.noRecords(); + return false; + } + // Deserialize all records for (NATIVE_UINT_TYPE recordNumber = 0; recordNumber < numRecords; recordNumber++) { Fw::SerializeStatus status = this->deserializeRecord(record); From 85350036508f83c8846d3fc5658bd74fd6cf325c Mon Sep 17 00:00:00 2001 From: jsilveira Date: Sun, 17 Nov 2024 16:03:52 +0100 Subject: [PATCH 3/4] feat: implemented ut for NoRecords Event --- Svc/CmdSequencer/CMakeLists.txt | 5 +- Svc/CmdSequencer/test/ut/CmdSequencerMain.cpp | 11 +++ Svc/CmdSequencer/test/ut/NoRecords.cpp | 99 +++++++++++++++++++ Svc/CmdSequencer/test/ut/NoRecords.hpp | 54 ++++++++++ .../test/ut/SequenceFiles/NoRecordsFile.cpp | 55 +++++++++++ .../test/ut/SequenceFiles/NoRecordsFile.hpp | 47 +++++++++ 6 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 Svc/CmdSequencer/test/ut/NoRecords.cpp create mode 100644 Svc/CmdSequencer/test/ut/NoRecords.hpp create mode 100644 Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp create mode 100644 Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.hpp diff --git a/Svc/CmdSequencer/CMakeLists.txt b/Svc/CmdSequencer/CMakeLists.txt index 6573dff0b0..cf6ff013a6 100644 --- a/Svc/CmdSequencer/CMakeLists.txt +++ b/Svc/CmdSequencer/CMakeLists.txt @@ -16,7 +16,8 @@ set(SOURCE_FILES ) register_fprime_module() -### UTs ### + +# ## UTs ### set(UT_SOURCE_FILES "${FPRIME_FRAMEWORK_PATH}/Svc/CmdSequencer/CmdSequencer.fpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/AMPCS.cpp" @@ -30,12 +31,14 @@ set(UT_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/test/ut/Mixed.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/MixedRelativeBase.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/NoFiles.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/NoRecords.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/Relative.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/AMPCS/CRCs.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/AMPCS/Headers.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/AMPCS/Records.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/BadCRCFile.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/BadDescriptorFile.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/NoRecordsFile.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/BadTimeBaseFile.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/BadTimeContextFile.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/SequenceFiles/Buffers.cpp" diff --git a/Svc/CmdSequencer/test/ut/CmdSequencerMain.cpp b/Svc/CmdSequencer/test/ut/CmdSequencerMain.cpp index e19e31d783..27732a66e2 100644 --- a/Svc/CmdSequencer/test/ut/CmdSequencerMain.cpp +++ b/Svc/CmdSequencer/test/ut/CmdSequencerMain.cpp @@ -13,6 +13,7 @@ #include "Svc/CmdSequencer/test/ut/Immediate.hpp" #include "Svc/CmdSequencer/test/ut/ImmediateEOS.hpp" #include "Svc/CmdSequencer/test/ut/InvalidFiles.hpp" +#include "Svc/CmdSequencer/test/ut/NoRecords.hpp" #include "Svc/CmdSequencer/test/ut/NoFiles.hpp" #include "Svc/CmdSequencer/test/ut/Relative.hpp" #include "Svc/CmdSequencer/test/ut/SequenceFiles/SequenceFiles.hpp" @@ -316,6 +317,7 @@ TEST(InvalidFiles, USecFieldTooShort) { tester.USecFieldTooShort(); } + TEST(Mixed, AutoByCommand) { TEST_CASE(103.1.4,"Nominal Timed Relative Commands"); Svc::Mixed::CmdSequencerTester tester; @@ -390,6 +392,15 @@ TEST(JoinWait, JoinWaitWithActiveSeq) { tester.test_join_wait_with_active_seq(); } +TEST(InvalidFiles, RunNoRecords) { + Svc::NoRecords::CmdSequencerTester tester; + tester.RunNoRecords(); +} + +TEST(InvalidFiles, ValidateNoRecords) { + Svc::NoRecords::CmdSequencerTester tester; + tester.ValidateNoRecords(); +} int main(int argc, char **argv) { // Create ./bin directory for test files diff --git a/Svc/CmdSequencer/test/ut/NoRecords.cpp b/Svc/CmdSequencer/test/ut/NoRecords.cpp new file mode 100644 index 0000000000..8c9c09b512 --- /dev/null +++ b/Svc/CmdSequencer/test/ut/NoRecords.cpp @@ -0,0 +1,99 @@ +// ====================================================================== +// \title NoRecords.hpp +// \author Joaquim Silveira +// \brief Test command sequence with no records +// +// ====================================================================== + +#include "Svc/CmdSequencer/test/ut/CommandBuffers.hpp" +#include "Svc/CmdSequencer/test/ut/NoRecords.hpp" +#include "Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.hpp" + +namespace Svc { + + namespace NoRecords { + + // ---------------------------------------------------------------------- + // Constructors + // ---------------------------------------------------------------------- + + CmdSequencerTester :: + CmdSequencerTester(const SequenceFiles::File::Format::t format) : + Svc::CmdSequencerTester(format) + { + + } + + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + void CmdSequencerTester :: + Init() + { + // Nothing to do + } + + void CmdSequencerTester :: + ValidateNoRecords() + { + SequenceFiles::NoRecordsFile file(this->format); + + // Set the time + Fw::Time testTime(TB_WORKSTATION_TIME, 0, 0); + this->setTestTime(testTime); + + // Write the file + const char* const fileName = file.getName().toChar(); + file.write(); + + // Validate the file + this->sendCmd_CS_VALIDATE(0, 0, Fw::CmdStringArg(fileName)); + this->clearAndDispatch(); + + // Assert command response + ASSERT_CMD_RESPONSE_SIZE(1); + ASSERT_CMD_RESPONSE( + 0, + CmdSequencerComponentBase::OPCODE_CS_VALIDATE, + 0, + Fw::CmdResponse::EXECUTION_ERROR + ); + // Assert events + ASSERT_EVENTS_SIZE(1); + ASSERT_EVENTS_CS_NoRecords(0, fileName); + } + + void CmdSequencerTester :: + RunNoRecords() + { + SequenceFiles::NoRecordsFile file(this->format); + + // Set the time + Fw::Time testTime(TB_WORKSTATION_TIME, 0, 0); + this->setTestTime(testTime); + + // Write the file + const char* const fileName = file.getName().toChar(); + file.write(); + + // Send run command + this->sendCmd_CS_RUN(0, 0, Fw::CmdStringArg(fileName), Svc::CmdSequencer_BlockState::NO_BLOCK); + this->clearAndDispatch(); + // Assert command response + ASSERT_CMD_RESPONSE_SIZE(1); + ASSERT_CMD_RESPONSE( + 0, + CmdSequencerComponentBase::OPCODE_CS_RUN, + 0, + Fw::CmdResponse::EXECUTION_ERROR + ); + // Assert events + ASSERT_EVENTS_SIZE(1); + ASSERT_EVENTS_CS_NoRecords(0, fileName); + + } + + } + +} diff --git a/Svc/CmdSequencer/test/ut/NoRecords.hpp b/Svc/CmdSequencer/test/ut/NoRecords.hpp new file mode 100644 index 0000000000..d070b2ae36 --- /dev/null +++ b/Svc/CmdSequencer/test/ut/NoRecords.hpp @@ -0,0 +1,54 @@ +// ====================================================================== +// \title NoRecords.hpp +// \author Joaquim Silveira +// \brief Test command sequence with no records +// +// ====================================================================== + +#ifndef Svc_NoRecords_HPP +#define Svc_NoRecords_HPP + +#include "CmdSequencerTester.hpp" + +namespace Svc { + + namespace NoRecords { + + //! Test sequencer behavior with no input files + class CmdSequencerTester : + public Svc::CmdSequencerTester + { + + public: + + // ---------------------------------------------------------------------- + // Constructors + // ---------------------------------------------------------------------- + + //! Construct object CmdSequencerTester + CmdSequencerTester( + const SequenceFiles::File::Format::t format = + SequenceFiles::File::Format::F_PRIME //!< The file format to use + ); + + public: + + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Initialization + void Init(); + + //! Issue a validate command on an empty sequence + void ValidateNoRecords(); + + //! Issue a run command on an empty sequence + void RunNoRecords(); + }; + + } + +} + +#endif diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp new file mode 100644 index 0000000000..2b0c33a732 --- /dev/null +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.cpp @@ -0,0 +1,55 @@ +// ====================================================================== +// \title NoRecordsFile.cpp +// \author Rob Bocchino +// \brief NoRecordsFile implementation +// +// \copyright +// Copyright (C) 2009-2018 California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. + +#include "Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/AMPCS.hpp" +#include "Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp" +#include "Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/FPrime.hpp" +#include "Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.hpp" +#include "gtest/gtest.h" + +namespace Svc { + + namespace SequenceFiles { + + NoRecordsFile :: + NoRecordsFile(const Format::t format) : + File("norecords", format) + { + } + + void NoRecordsFile::serializeFPrime(Fw::SerializeBufferBase& buffer) { + // Header + const NATIVE_INT_TYPE numRecs = 0; + const U32 recordDataSize = numRecs * FPrime::Records::STANDARD_SIZE; + const U32 dataSize = recordDataSize + FPrime::CRCs::SIZE; + const TimeBase timeBase = TB_WORKSTATION_TIME; + const U32 timeContext = 0; + FPrime::Headers::serialize(dataSize, numRecs, timeBase, timeContext, buffer); + + // No Records + + // CRC + FPrime::CRCs::serialize(buffer); + } + + void NoRecordsFile :: + serializeAMPCS(Fw::SerializeBufferBase& buffer) + { + // Header + AMPCS::Headers::serialize(buffer); + // No Records + + // CRC + AMPCS::CRCs::createFile(buffer, this->getName().toChar()); + } + + } + +} diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.hpp b/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.hpp new file mode 100644 index 0000000000..612eb59188 --- /dev/null +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.hpp @@ -0,0 +1,47 @@ +// ====================================================================== +// \title NoRecordsFile.hpp +// \author Joaquim Silveira +// \brief NoRecords interface + + +#ifndef Svc_SequenceFiles_NoRecordsFile_HPP +#define Svc_SequenceFiles_NoRecordsFile_HPP + +#include "Svc/CmdSequencer/test/ut/SequenceFiles/File.hpp" +#include "Svc/CmdSequencer/CmdSequencerImpl.hpp" + +namespace Svc { + + namespace SequenceFiles { + + //! A file containing no records + class NoRecordsFile : + public File + { + + public: + + //! Construct a NoRecordsFile + NoRecordsFile( + const Format::t format //!< The file format + ); + + public: + + //! Serialize the file in F Prime format + void serializeFPrime( + Fw::SerializeBufferBase& buffer //!< The buffer + ); + + //! Serialize the file in AMPCS format + void serializeAMPCS( + Fw::SerializeBufferBase& buffer //!< The buffer + ); + + }; + + } + +} + +#endif From 903481512db37b24c4a76abcc95344f8a9d4b11b Mon Sep 17 00:00:00 2001 From: M Starch Date: Mon, 18 Nov 2024 09:24:39 -0800 Subject: [PATCH 4/4] sp --- .github/actions/spelling/expect.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index fd41ed7e2c..65b9766c64 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -470,6 +470,7 @@ jdperez jenkins jenkinsci jishii +Joaquim jobrestrictions joshuaa jpl @@ -594,6 +595,7 @@ nogen noncomma NONINFRINGEMENT noparent +norecords normalwidths NOSIZE NOSPEC @@ -842,6 +844,7 @@ showinitializer sideeffect sighandler Signedness +Silveira sinc Sinha sloc