* 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.
12 KiB
DpWriter Component Tests
1. Abstract State
1.1. Variables
| Variable | Type | Description | Initial Value |
|---|---|---|---|
m_NumBuffersReceived |
OnChangeChannel<U32> |
The number of buffers received | 0 |
m_NumBytesWritten |
OnChangeChannel<U64> |
The number of bytes written | 0 |
m_NumErrors |
OnChangeChannel<U32> |
The number of errors | 0 |
m_NumFailedWrites |
OnChangeChannel<U32> |
The number of failed writes | 0 |
m_NumSuccessfulWrites |
OnChangeChannel<U32> |
The number of successful writes | 0 |
m_bufferTooSmallForDataEventCount |
FwSizeType |
The number of BufferTooSmallForData events since the last throttle clear |
0 |
m_bufferTooSmallForPacketEventCount |
FwSizeType |
The number of BufferTooSmallForPacket events since the last throttle clear |
0 |
m_fileOpenErrorEventCount |
FwSizeType |
The number of file open error events since the last throttle clear | 0 |
m_fileWriteErrorEventCount |
FwSizeType |
The number of file write error events since the last throttle clear | 0 |
m_invalidBufferEventCount |
FwSizeType |
The number of buffer invalid events since the last throttle clear | 0 |
m_invalidHeaderEventCount |
FwSizeType |
The number of invalid packet descriptor events since the last throttle clear | 0 |
m_invalidHeaderHashEventCount |
FwSizeType |
The number of invalid header hash events since the last throttle clear | 0 |
2. Rule Groups
2.1. FileOpenStatus
This rule group manages the file open status in the test harness.
2.1.1. OK
This rule sets the file open status to Os::File::OP_OK, simulating a system state
in which a file open call succeeds.
Precondition:
Os::Stub::File::Test::StaticData::data.openStatus != Os::File::OP_OK.
Action:
Os::Stub::File::Test::StaticData::data.openStatus = Os::File::OP_OK.
Test:
- Apply rule
FileOpenStatus::Error. - Apply rule
FileOpenStatus::OK.
Requirements tested: None (helper rule).
2.1.2. Error
This rule sets the file open status to an error value, simulating a system state in which a file open call fails.
Precondition:
Os::Stub::File::Test::StaticData::data.openStatus == Os::File::OP_OK.
Action:
Set Os::Stub::File::Test::StaticData::data.openStatus to a random
value other than Os::File::OP_OK.
Test:
- Apply rule
FileOpenStatus::Error.
Requirements tested: None (helper rule).
2.2. FileWriteStatus
This rule group manages the file write status in the test harness.
2.2.1. OK
This rule sets the file open status to Os::File::OP_OK, simulating a system state
in which a file write call succeeds.
Precondition:
Os::Stub::File::Test::StaticData::data.writeStatus != Os::File::OP_OK.
Action:
Os::Stub::File::Test::StaticData::data.writeStatus = Os::File::OP_OK.
Test:
- Apply rule
FileWriteStatus::Error. - Apply rule
FileWriteStatus::OK.
Requirements tested: None (helper rule).
2.2.2. Error
This rule sets the file write status to an error value, simulating a system state in which a file write call fails.
Precondition:
Os::Stub::File::Test::StaticData::data.writeStatus == Os::File::OP_OK.
Action:
Set Os::Stub::File::Test::StaticData::data.writeStatus to a random value
other than Os::File::OP_OK.
Test:
- Apply rule
FileWriteStatus::Error.
Requirements tested: None (helper rule).
2.3. SchedIn
This rule group sends test input to the schedIn port.
2.3.1. OK
This rule invokes schedIn with nominal input.
Precondition: true
Action:
- Clear history.
- Invoke
schedInwith a random context. - Check telemetry.
Test:
- Apply rule
SchedIn::OK.
Requirements tested:
SVC-DPWRITER-006.
2.4. BufferSendIn
This rule group sends test input to the bufferSendIn port.
2.4.1. OK
This rule invokes bufferSendIn with nominal input.
Precondition:
fileOpenStatus == Os::File::OP_OK and
fileWriteStatus == Os::File::OP_OK.
Action:
- Clear history.
- Update
m_NumBuffersReceived. - Construct a random buffer B with valid packet data and random processing bits.
- Send B to
bufferSendIn. - Assert that the event history contains one element.
- Assert that the event history for
FileWrittencontains one element. - Check the event arguments.
- Check output on processing ports.
- Check output on notification port.
- Check output on deallocation port.
- Verify that
Os::File::writehas been called with the expected arguments. - Update
m_NumBytesWritten. - Update
m_NumSuccessfulWrites.
Test:
- Apply rule
BufferSendIn::OK.
Requirements tested:
SVC-DPWRITER-001,
SVC-DPWRITER-002,
SVC-DPWRITER-003,
SVC-DPWRITER-004,
SVC-DPWRITER-005
2.4.2. InvalidBuffer
This rule invokes bufferSendIn with an invalid buffer.
Precondition:
true
Action:
- Clear history.
- Update
m_NumBuffersReceived. - Construct an invalid buffer B.
- If
m_invalidBufferEventCount<DpWriterComponentBase::EVENTID_INVALIDBUFFER_THROTTLE, then- Assert that the event history contains one element.
- Assert that the event history for
InvalidBuffercontains one element. - Increment
m_invalidBufferEventCount.
- Otherwise assert that the event history is empty.
- Verify no data product file.
- Verify no port output.
- Increment
m_NumErrors.
Test:
- Apply rule
BufferSendIn::InvalidBuffer.
Requirements tested:
SVC-DPWRITER-001
2.4.3. BufferTooSmallForPacket
This rule invokes bufferSendIn with a buffer that is too small to
hold a data product packet.
Precondition:
true
Action:
- Clear history.
- Increment
m_NumBuffersReceived. - Construct a valid buffer B that is too small to hold a data product packet.
- If
m_bufferTooSmallEventCount<DpWriterComponentBase::EVENTID_BUFFERTOOSMALLFORPACKET_THROTTLE, then- Assert that the event history contains one element.
- Assert that the event history for
BufferTooSmallForPacketcontains one element. - Check the event arguments.
- Increment
m_bufferTooSmallEventCount.
- Otherwise assert that the event history is empty.
- Assert no DP written notification.
- Assert buffer sent for deallocation.
- Verify no data product file.
- Increment
m_NumErrors.
Requirements tested:
SVC-DPWRITER-001
2.4.4. InvalidHeaderHash
This rule invokes bufferSendIn with a buffer that has an invalid
header hash.
Precondition:
true
Action:
- Clear history.
- Increment
m_NumBuffersReceived. - Construct a valid buffer B that is large enough to hold a data product packet and that has an invalid header hash.
- If
m_invalidHeaderHashEventCount<DpWriterComponentBase::EVENTID_INVALIDHEADERHASH_THROTTLE, then- Assert that the event history contains one element.
- Assert that the event history for
InvalidHeaderHashcontains one element. - Check the event arguments.
- Increment
m_invalidHeaderHashEventCount.
- Otherwise assert that the event history is empty.
- Assert no DP written notification.
- Assert buffer sent for deallocation.
- Verify no data product file.
- Increment
m_NumErrors.
Test:
- Apply rule
BufferSendIn::BufferTooSmallForPacket.
Requirements tested:
SVC-DPWRITER-001
2.4.5. InvalidHeader
This rule invokes bufferSendIn with an invalid packet header.
Precondition:
true
Action:
- Clear history.
- Increment
m_NumBuffersReceived. - Construct a valid buffer B with an invalid packet header.
- If
m_invalidPacketHeaderEventCount<DpWriterComponentBase::EVENTID_INVALIDHEADER_THROTTLE, then- Assert that the event history contains one element.
- Assert that the event history for
InvalidHeadercontains one element. - Check the event arguments.
- Increment
m_invalidPacketHeaderEventCount.
- Otherwise assert that the event history is empty.
- Assert no DP written notification.
- Assert buffer sent for deallocation.
- Verify no data product file.
- Increment
m_NumErrors.
Test:
- Apply rule
BufferSendIn::InvalidHeader.
Requirements tested:
SVC-DPWRITER-001
2.4.6. BufferTooSmallForData
This rule invokes bufferSendIn with a buffer that is too small to
hold the data size specified in the header.
Precondition:
true
Action:
- Clear history.
- Increment
m_NumBuffersReceived. - Construct a valid buffer B with a valid packet header, but a data size that will not fit in B.
- If
m_bufferTooSmallForDataEventCount<DpWriterComponentBase::EVENTID_BUFFERTOOSMALLFORDATA_THROTTLE, then- Assert that the event history contains one element.
- Assert that the event history for
BufferTooSmallForDatacontains one element. - Check the event arguments.
- Increment
m_bufferTooSmallForDataEventCount.
- Otherwise assert that the event history is empty.
- Assert no DP written notification.
- Assert buffer sent for deallocation.
- Verify no data product file.
- Increment
m_NumErrors.
Test:
- Apply rule
BufferSendIn::BufferTooSmallForData.
Requirements tested:
SVC-DPWRITER-001
2.4.7. FileOpenError
This rule invokes bufferSendIn with a file open error.
Precondition:
fileOpenStatus != Os::File::OP_OK
Action:
- Clear history.
- Update
m_NumBuffersReceived. - Construct a random buffer B with valid packet data.
- Send B to
bufferSendIn. - Assert that the event history contains one element.
- Assert that the event history for
FileOpenErrorcontains one element. - Check the event arguments.
- Assert no DP written notification.
- Assert buffer sent for deallocation.
- Verify no data product file.
- Increment
m_NumFailedWrites. - Increment
m_NumErrors.
Test:
- Apply rule
FileOpenStatus::Error. - Apply rule
BufferSendIn::FileOpenError.
Requirements tested:
SVC-DPWRITER-004
2.4.8. FileWriteError
This rule invokes bufferSendIn with a file write error.
Precondition:
fileOpenStatus == Os::File::OP_OK and
fileWriteStatus != Os::File::OP_OK
Action:
- Clear history.
- Update
m_NumBuffersReceived. - Construct a random buffer B with valid packet data.
- Send B to
bufferSendIn. - Assert that the event history contains one element.
- Assert that the event history for
FileWriteErrorcontains one element. - Check the event arguments.
- Assert no DP written notification.
- Assert buffer sent for deallocation.
- Verify no data product file.
- Increment
m_NumFailedWrites. - Increment
m_NumErrors.
Test:
- Apply rule
FileWriteStatus::Error. - Apply rule
BufferSendIn::FileWriteError.
Requirements tested:
SVC-DPWRITER-004
2.5. CLEAR_EVENT_THROTTLE
This rule group tests the CLEAR_EVENT_THROTTLE command.
2.5.1. OK
This rule sends the CLEAR_EVENT_THROTTLE command.
Precondition: true
Action:
- Clear the history.
- Send command
CLEAR_EVENT_THROTTLE. - Check the command response.
- Assert
DpWriterComponentBase::m_InvalidBufferThrottle== 0. - Set
m_bufferTooSmallForDataEventCount= 0. - Set
m_bufferTooSmallForPacketEventCount= 0. - Set
m_fileOpenErrorEventCount= 0. - Set
m_fileWriteErrorEventCount= 0. - Set
m_invalidBufferEventCount= 0. - Set
m_invalidHeaderEventCount= 0. - Set
m_invalidHeaderHashEventCount= 0.
Test:
- Apply rule
BufferSendIn::InvalidBufferDpWriterComponentBase::EVENTID_INVALIDBUFFER_THROTTLE+ 1 times. - Apply rule
CLEAR_EVENT_THROTTLE::OK. - Apply rule
BufferSendIn::InvalidBuffer
3. Implementation
See the DpWriter test README for a description of the pattern used to implement the tests.