fprime/Svc/DpWriter/test/ut/DpWriterTestMain.cpp
Rob Bocchino b89b5d91c4
Add DpWriter (#2593)
* Pull in framework changes from data-products branch

* Pull in changes to DpManager from data-products branch

* Pull in DpWriter from data-products branch

* Fix spelling

* Revise FileNameString

* Fix warnings in CI

* Fix static analysis warnings

* Fix static analysis warnings

* Revise formatting and comments

* Revise banner comments

* Revise FileNameString per PR comment

* Revise path names in config headers

If a header H.hpp exists in the F Prime source base, then

is dangerous. Because [project root] and [fprime root] are both
in the list of include paths, it's not clear whether this means "include
[project root]/config/H.hpp" or "include [fprime root]/config/H.hpp."

On the other hand,

or

has no such ambiguity, because only one of [project root]/config
and [fprime root]/config is in the list of include paths.

* Revise path names in config headers

If a header H.hpp exists in the F Prime source base, then

`#include "config/H.hpp"`

is dangerous. Because [project root] and [fprime root] are both
in the list of include paths, it's not clear whether this means "include
[project root]/config/H.hpp" or "include [fprime root]/config/H.hpp."

On the other hand,

include <config/H.hpp>

or

`#include "config/H.hpp"`

has no such ambiguity, because only one of [project root]/config
and [fprime root]/config is in the list of include paths.
2024-03-28 16:09:38 -07:00

132 lines
3.7 KiB
C++

// ======================================================================
// \title DpWriterTestMain.cpp
// \author bocchino
// \brief cpp file for DpWriter component test main function
// ======================================================================
#include "Fw/Test/UnitTest.hpp"
#include "STest/Random/Random.hpp"
#include "Svc/DpWriter/test/ut/Rules/Testers.hpp"
#include "Svc/DpWriter/test/ut/Scenarios/Random.hpp"
namespace Svc {
TEST(BufferSendIn, BufferTooSmallForData) {
COMMENT("Invoke bufferSendIn with a buffer that is too small to hold the data size specified in the header.");
REQUIREMENT("SVC-DPMANAGER-001");
BufferSendIn::Tester tester;
tester.BufferTooSmallForData();
}
TEST(BufferSendIn, BufferTooSmallForPacket) {
COMMENT("Invoke bufferSendIn with a buffer that is too small to hold a data product packet.");
REQUIREMENT("SVC-DPMANAGER-001");
BufferSendIn::Tester tester;
tester.BufferTooSmallForPacket();
}
TEST(BufferSendIn, FileOpenError) {
COMMENT("Invoke bufferSendIn with a file open error.");
REQUIREMENT("SVC-DPMANAGER-001");
BufferSendIn::Tester tester;
tester.FileOpenError();
}
TEST(BufferSendIn, FileWriteError) {
COMMENT("Invoke bufferSendIn with a file write error.");
REQUIREMENT("SVC-DPMANAGER-001");
BufferSendIn::Tester tester;
tester.FileWriteError();
}
TEST(BufferSendIn, InvalidBuffer) {
COMMENT("Invoke bufferSendIn with an invalid buffer.");
REQUIREMENT("SVC-DPMANAGER-001");
BufferSendIn::Tester tester;
tester.InvalidBuffer();
}
TEST(BufferSendIn, InvalidHeader) {
COMMENT("Invoke bufferSendIn with an invalid packet header.");
REQUIREMENT("SVC-DPMANAGER-001");
BufferSendIn::Tester tester;
tester.InvalidHeader();
}
TEST(BufferSendIn, InvalidHeaderHash) {
COMMENT("Invoke bufferSendIn with a buffer that has an invalid header hash.");
REQUIREMENT("SVC-DPMANAGER-001");
BufferSendIn::Tester tester;
tester.InvalidHeaderHash();
}
TEST(BufferSendIn, OK) {
COMMENT("Invoke bufferSendIn with nominal input.");
REQUIREMENT("SVC-DPMANAGER-001");
REQUIREMENT("SVC-DPMANAGER-002");
REQUIREMENT("SVC-DPMANAGER-003");
REQUIREMENT("SVC-DPMANAGER-004");
REQUIREMENT("SVC-DPMANAGER-005");
BufferSendIn::Tester tester;
tester.OK();
}
TEST(CLEAR_EVENT_THROTTLE, OK) {
COMMENT("Test the CLEAR_EVENT_THROTTLE command.");
REQUIREMENT("SVC-DPMANAGER-006");
CLEAR_EVENT_THROTTLE::Tester tester;
tester.OK();
}
TEST(FileOpenStatus, Error) {
COMMENT("Set the file open status to an error value.");
FileOpenStatus::Tester tester;
tester.Error();
}
TEST(FileOpenStatus, OK) {
COMMENT("Set the file open status to OP_OK.");
FileOpenStatus::Tester tester;
tester.OK();
}
TEST(FileWriteStatus, Error) {
COMMENT("Set the file write status to an error value.");
FileWriteStatus::Tester tester;
tester.Error();
}
TEST(FileWriteStatus, OK) {
COMMENT("Set the file write status to OP_OK.");
FileWriteStatus::Tester tester;
tester.OK();
}
TEST(Scenarios, Random) {
COMMENT("Random scenario with all rules.");
REQUIREMENT("SVC-DPMANAGER-001");
REQUIREMENT("SVC-DPMANAGER-002");
REQUIREMENT("SVC-DPMANAGER-003");
REQUIREMENT("SVC-DPMANAGER-004");
REQUIREMENT("SVC-DPMANAGER-005");
REQUIREMENT("SVC-DPMANAGER-006");
const FwSizeType numSteps = 10000;
Scenarios::Random::Tester tester;
tester.run(numSteps);
}
TEST(SchedIn, OK) {
COMMENT("Invoke schedIn with nominal input.");
REQUIREMENT("SVC-DPMANAGER-006");
SchedIn::Tester tester;
tester.OK();
}
} // namespace Svc
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
STest::Random::seed();
return RUN_ALL_TESTS();
}