-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented ut for NoRecords Event
- Loading branch information
1 parent
8a2bca2
commit 8535003
Showing
6 changed files
with
270 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// ====================================================================== | ||
// \title NoRecords.hpp | ||
// \author Joaquim Silveira | ||
Check failure on line 3 in Svc/CmdSequencer/test/ut/NoRecords.cpp GitHub Actions / Spell checking
|
||
// \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); | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// ====================================================================== | ||
// \title NoRecords.hpp | ||
// \author Joaquim Silveira | ||
Check failure on line 3 in Svc/CmdSequencer/test/ut/NoRecords.hpp GitHub Actions / Spell checking
|
||
// \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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// ====================================================================== | ||
// \title NoRecordsFile.hpp | ||
// \author Joaquim Silveira | ||
Check failure on line 3 in Svc/CmdSequencer/test/ut/SequenceFiles/NoRecordsFile.hpp GitHub Actions / Spell checking
|
||
// \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 |