mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 16:29:04 -06:00
Testing with configured fixed-size types (#3409)
* Testing with configured fixed-size types * Linux fixes * Final settings * Removing FwNativeIntType
This commit is contained in:
parent
c7828f504d
commit
2dcd21902d
@ -148,7 +148,7 @@ SocketIpStatus IpSocket::send(const SocketDescriptor& socketDescriptor, const U8
|
||||
else if (sent == -1) {
|
||||
return SOCK_SEND_ERROR;
|
||||
}
|
||||
FW_ASSERT(sent > 0, sent);
|
||||
FW_ASSERT(sent > 0, static_cast<FwAssertArgType>(sent));
|
||||
total += static_cast<U32>(sent);
|
||||
}
|
||||
// Failed to retry enough to send all data
|
||||
|
||||
@ -67,7 +67,7 @@ SocketIpStatus UdpSocket::configure(const char* const hostname, const U16 port,
|
||||
|
||||
SocketIpStatus UdpSocket::configureSend(const char* const hostname, const U16 port, const U32 timeout_seconds, const U32 timeout_microseconds) {
|
||||
//Timeout is for the send, so configure send will work with the base class
|
||||
FW_ASSERT(port != 0, port); // Send cannot be on port 0
|
||||
FW_ASSERT(port != 0, static_cast<FwAssertArgType>(port)); // Send cannot be on port 0
|
||||
FW_ASSERT(hostname != nullptr);
|
||||
return this->IpSocket::configure(hostname, port, timeout_seconds, timeout_microseconds);
|
||||
}
|
||||
@ -112,7 +112,7 @@ SocketIpStatus UdpSocket::bind(const PlatformIntType fd) {
|
||||
return SOCK_FAILED_TO_READ_BACK_PORT;
|
||||
}
|
||||
|
||||
FW_ASSERT(sizeof(this->m_state->m_addr_recv) == sizeof(address), sizeof(this->m_state->m_addr_recv), sizeof(address));
|
||||
FW_ASSERT(sizeof(this->m_state->m_addr_recv) == sizeof(address), static_cast<FwAssertArgType>(sizeof(this->m_state->m_addr_recv)), static_cast<FwAssertArgType>(sizeof(address)));
|
||||
memcpy(&this->m_state->m_addr_recv, &address, sizeof(this->m_state->m_addr_recv));
|
||||
|
||||
return SOCK_SUCCESS;
|
||||
@ -152,8 +152,8 @@ SocketIpStatus UdpSocket::openProtocol(SocketDescriptor& socketDescriptor) {
|
||||
::close(socketFd);
|
||||
return status;
|
||||
}
|
||||
FW_ASSERT(sizeof(this->m_state->m_addr_send) == sizeof(address), sizeof(this->m_state->m_addr_send),
|
||||
sizeof(address));
|
||||
FW_ASSERT(sizeof(this->m_state->m_addr_send) == sizeof(address), static_cast<FwAssertArgType>(sizeof(this->m_state->m_addr_send)),
|
||||
static_cast<FwAssertArgType>(sizeof(address)));
|
||||
memcpy(&this->m_state->m_addr_send, &address, sizeof(this->m_state->m_addr_send));
|
||||
}
|
||||
|
||||
@ -184,9 +184,9 @@ SocketIpStatus UdpSocket::openProtocol(SocketDescriptor& socketDescriptor) {
|
||||
}
|
||||
// Neither configuration method was called
|
||||
else {
|
||||
FW_ASSERT(port > 0 || recv_port > 0, port, recv_port);
|
||||
FW_ASSERT(port > 0 || recv_port > 0, static_cast<FwAssertArgType>(port), static_cast<FwAssertArgType>(recv_port));
|
||||
}
|
||||
FW_ASSERT(status == SOCK_SUCCESS, status);
|
||||
FW_ASSERT(status == SOCK_SUCCESS, static_cast<FwAssertArgType>(status));
|
||||
socketDescriptor.fd = socketFd;
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ namespace Fw {
|
||||
}
|
||||
|
||||
void InputPortBase::setPortNum(FwIndexType portNum) {
|
||||
FW_ASSERT(portNum >= 0,portNum);
|
||||
FW_ASSERT(portNum >= 0, static_cast<FwAssertArgType>(portNum));
|
||||
this->m_portNum = portNum;
|
||||
}
|
||||
|
||||
|
||||
@ -196,10 +196,10 @@ namespace Fw {
|
||||
)
|
||||
{
|
||||
#if FW_USE_TIME_BASE
|
||||
FW_ASSERT(a.getTimeBase() == b.getTimeBase(), a.getTimeBase(), b.getTimeBase() );
|
||||
FW_ASSERT(a.getTimeBase() == b.getTimeBase(), static_cast<FwAssertArgType>(a.getTimeBase()), static_cast<FwAssertArgType>(b.getTimeBase()) );
|
||||
#endif
|
||||
#if FW_USE_TIME_CONTEXT
|
||||
FW_ASSERT(a.getContext() == b.getContext(), a.getContext(), b.getContext() );
|
||||
FW_ASSERT(a.getContext() == b.getContext(), static_cast<FwAssertArgType>(a.getContext()), static_cast<FwAssertArgType>(b.getContext()) );
|
||||
#endif
|
||||
U32 seconds = a.getSeconds() + b.getSeconds();
|
||||
U32 uSeconds = a.getUSeconds() + b.getUSeconds();
|
||||
@ -219,10 +219,10 @@ namespace Fw {
|
||||
)
|
||||
{
|
||||
#if FW_USE_TIME_BASE
|
||||
FW_ASSERT(minuend.getTimeBase() == subtrahend.getTimeBase(), minuend.getTimeBase(), subtrahend.getTimeBase());
|
||||
FW_ASSERT(minuend.getTimeBase() == subtrahend.getTimeBase(), static_cast<FwAssertArgType>(minuend.getTimeBase()), static_cast<FwAssertArgType>(subtrahend.getTimeBase()));
|
||||
#endif
|
||||
#if FW_USE_TIME_CONTEXT
|
||||
FW_ASSERT(minuend.getContext() == subtrahend.getContext(), minuend.getContext(), subtrahend.getContext());
|
||||
FW_ASSERT(minuend.getContext() == subtrahend.getContext(), static_cast<FwAssertArgType>(minuend.getContext()), static_cast<FwAssertArgType>(subtrahend.getContext()));
|
||||
#endif
|
||||
// Assert minuend is greater than subtrahend
|
||||
FW_ASSERT(minuend >= subtrahend);
|
||||
|
||||
@ -24,7 +24,7 @@ namespace Fw {
|
||||
this->m_numEntries = 0;
|
||||
// make sure packet type is correct before serializing. It should
|
||||
// never be anything but FW_PACKET_TELEM, so assert.
|
||||
FW_ASSERT(FW_PACKET_TELEM == this->m_type,this->m_type);
|
||||
FW_ASSERT(FW_PACKET_TELEM == this->m_type, static_cast<FwAssertArgType>(this->m_type));
|
||||
// serialize descriptor
|
||||
// The function serializeBase inherited from ComPacket converts this->m_type
|
||||
// to type FwPacketDescriptorType and serializes the result into this->m_tlmBuffer.
|
||||
|
||||
@ -88,7 +88,9 @@ TEST(Nominal, PushPop) {
|
||||
|
||||
printf("Testing pop...\n");
|
||||
//heap.print();
|
||||
for(FwQueuePriorityType ii = DEPTH-1; ii >= 0; --ii) {
|
||||
for(FwSizeType i = 0; i < DEPTH; i++) {
|
||||
ASSERT_TRUE(DEPTH - 1 >= i);
|
||||
FwSizeType ii = DEPTH - 1 - i;
|
||||
ret = heap.pop(value, id);
|
||||
ASSERT_TRUE(ret);
|
||||
ASSERT_EQ(id, static_cast<FwSizeType>(ii));
|
||||
@ -104,8 +106,8 @@ TEST(Nominal, PushPop) {
|
||||
printf("Passed.\n");
|
||||
|
||||
printf("Testing random...\n");
|
||||
FwQueuePriorityType values[DEPTH] = {56, 0, 500, 57, 5};
|
||||
FwSizeType sorted[DEPTH] = {500, 57, 56, 5, 0};
|
||||
FwQueuePriorityType values[DEPTH] = {56, 0, 127, 57, 5};
|
||||
FwSizeType sorted[DEPTH] = {127, 57, 56, 5, 0};
|
||||
//heap.print();
|
||||
// Push values on in random order:
|
||||
for(FwSizeType ii = 0; ii < DEPTH; ++ii) {
|
||||
@ -188,9 +190,9 @@ TEST(Nominal, PushPop) {
|
||||
// for things of the same priority and in priority
|
||||
// order for things of different priorities.
|
||||
FwQueuePriorityType pries[DEPTH] = {1, 7, 100, 1, 7};
|
||||
FwQueuePriorityType data2[DEPTH] = {4, 22, 99, 12344, 33};
|
||||
FwQueuePriorityType data2[DEPTH] = {4, 22, 99, 127, 33};
|
||||
FwQueuePriorityType orderedPries[DEPTH] = {100, 7, 7, 1, 1};
|
||||
FwSizeType ordered[DEPTH] = {99, 22, 33, 4, 12344};
|
||||
FwSizeType ordered[DEPTH] = {99, 22, 33, 4, 127};
|
||||
// Push values on in random order:
|
||||
for(FwSizeType ii = 0; ii < DEPTH; ++ii) {
|
||||
// Push next value in the list:
|
||||
|
||||
@ -13,7 +13,7 @@ namespace Mutex {
|
||||
|
||||
PosixConditionVariable::PosixConditionVariable() {
|
||||
PlatformIntType status = pthread_cond_init(&this->m_handle.m_condition, nullptr);
|
||||
FW_ASSERT(status == 0, status); // If this fails, something horrible happened.
|
||||
FW_ASSERT(status == 0, static_cast<FwAssertArgType>(status)); // If this fails, something horrible happened.
|
||||
}
|
||||
PosixConditionVariable::~PosixConditionVariable() {
|
||||
(void)pthread_cond_destroy(&this->m_handle.m_condition);
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
static void testTaskRoutine(void* pointer) {
|
||||
Os::Test::Mutex::Tester* tester = reinterpret_cast<Os::Test::Mutex::Tester*>(pointer);
|
||||
|
||||
for (FwIndexType i = 0; i < 100000; i++) {
|
||||
for (FwSizeType i = 0; i < 100000; i++) {
|
||||
tester->m_mutex.lock();
|
||||
tester->m_state = Os::Test::Mutex::Tester::MutexState::LOCKED;
|
||||
|
||||
@ -51,7 +51,7 @@ TEST_F(FunctionalityTester, PosixMutexDataProtection) {
|
||||
|
||||
Os::Test::Mutex::Tester::ProtectDataCheck protect_data_rule;
|
||||
|
||||
for (FwIndexType i = 0; i < 100000; i++) {
|
||||
for (FwSizeType i = 0; i < 100000; i++) {
|
||||
protect_data_rule.apply(*tester);
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ QueueInterface::Status Queue ::create(const Fw::StringBase& name, FwSizeType dep
|
||||
|
||||
QueueInterface::Status Queue::send(const U8* buffer,
|
||||
FwSizeType size,
|
||||
PlatformIntType priority,
|
||||
FwQueuePriorityType priority,
|
||||
QueueInterface::BlockingType blockType) {
|
||||
FW_ASSERT(&this->m_delegate == reinterpret_cast<QueueInterface*>(&this->m_handle_storage[0]));
|
||||
FW_ASSERT(buffer != nullptr);
|
||||
@ -60,7 +60,7 @@ QueueInterface::Status Queue::receive(U8* destination,
|
||||
FwSizeType capacity,
|
||||
QueueInterface::BlockingType blockType,
|
||||
FwSizeType& actualSize,
|
||||
PlatformIntType& priority) {
|
||||
FwQueuePriorityType& priority) {
|
||||
FW_ASSERT(&this->m_delegate == reinterpret_cast<QueueInterface*>(&this->m_handle_storage[0]));
|
||||
FW_ASSERT(destination != nullptr);
|
||||
// Check if initialized
|
||||
@ -90,14 +90,14 @@ QueueHandle* Queue::getHandle(){
|
||||
}
|
||||
|
||||
QueueInterface::Status Queue::send(const Fw::SerializeBufferBase& message,
|
||||
PlatformIntType priority,
|
||||
FwQueuePriorityType priority,
|
||||
QueueInterface::BlockingType blockType) {
|
||||
return this->send(message.getBuffAddr(), message.getBuffLength(), priority, blockType);
|
||||
}
|
||||
|
||||
QueueInterface::Status Queue::receive(Fw::SerializeBufferBase& destination,
|
||||
QueueInterface::BlockingType blockType,
|
||||
PlatformIntType& priority) {
|
||||
FwQueuePriorityType& priority) {
|
||||
FwSizeType actualSize = 0;
|
||||
destination.resetSer(); // Reset the buffer
|
||||
QueueInterface::Status status =
|
||||
|
||||
@ -11,6 +11,7 @@ namespace Queue {
|
||||
namespace Test {
|
||||
|
||||
StaticData StaticData::data;
|
||||
U64 InjectableStlQueueHandle::Message::order_counter = 0;
|
||||
|
||||
InjectableStlQueueHandle::InjectableStlQueueHandle() :
|
||||
// Creates the necessary handle on the heap to keep the handle size small
|
||||
@ -63,6 +64,7 @@ QueueInterface::Status InjectableStlQueue::send(const U8* buffer, FwSizeType siz
|
||||
(void) std::memcpy(message.data, buffer, static_cast<size_t>(size));
|
||||
message.priority = priority;
|
||||
message.size = size;
|
||||
message.order = InjectableStlQueueHandle::Message::order_counter++;
|
||||
this->m_handle.m_storage.push(message);
|
||||
this->m_handle.m_high_water = FW_MAX(this->m_handle.m_high_water, this->m_handle.m_storage.size());
|
||||
return QueueInterface::Status::OP_OK;
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
#include "Os/Queue.hpp"
|
||||
#include <queue>
|
||||
#include <deque>
|
||||
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
|
||||
namespace Os {
|
||||
namespace Stub {
|
||||
@ -62,11 +63,20 @@ struct InjectableStlQueueHandle : public QueueHandle {
|
||||
U8 data[STUB_QUEUE_TEST_MESSAGE_MAX_SIZE];
|
||||
FwQueuePriorityType priority;
|
||||
FwSizeType size;
|
||||
U64 order;
|
||||
static U64 order_counter;
|
||||
//! \brief comparison utility for messages
|
||||
struct LessMessage {
|
||||
bool operator()(const Message& a, const Message& b) {
|
||||
// Compare priority for unequal priority
|
||||
if (a.priority != b.priority) {
|
||||
return std::greater<FwQueuePriorityType>()(a.priority, b.priority);
|
||||
}
|
||||
// Cannot have like ordered items
|
||||
assert(a.order != b.order);
|
||||
// Compare received order for unequal received orders
|
||||
return a.order > b.order;
|
||||
}
|
||||
};
|
||||
};
|
||||
InjectableStlQueueHandle();
|
||||
|
||||
@ -50,7 +50,7 @@ struct Tester {
|
||||
std::vector<TestDirectory> m_test_dirs;
|
||||
std::vector<TestFile> m_test_files;
|
||||
|
||||
FwIndexType m_counter; //!< Counter for generating unique file/directory names
|
||||
U64 m_counter; //!< Counter for generating unique file/directory names
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Functions to manipulate the state of the Tester w.r.t filesystem
|
||||
@ -84,9 +84,11 @@ struct Tester {
|
||||
// Helper functions for testing
|
||||
// ----------------------------------------------------------------
|
||||
std::string get_new_filename() {
|
||||
assert(m_counter != std::numeric_limits<U64>::max());
|
||||
return "test_file_" + std::to_string(m_counter++);
|
||||
}
|
||||
std::string get_new_dirname() {
|
||||
assert(m_counter != std::numeric_limits<U64>::max());
|
||||
return "test_dir_" + std::to_string(m_counter++);
|
||||
}
|
||||
TestFile& get_random_file() {
|
||||
|
||||
@ -15,6 +15,7 @@ namespace Os {
|
||||
namespace Test {
|
||||
namespace Queue {
|
||||
FwSizeType Tester::QueueState::queues = 0;
|
||||
U64 Tester::QueueMessage::order_counter = 0;
|
||||
|
||||
PriorityCompare const Tester::QueueMessageComparer::HELPER = PriorityCompare();
|
||||
|
||||
@ -38,6 +39,10 @@ Os::QueueInterface::Status Tester::shadow_send(const U8* buffer,
|
||||
QueueMessage qm;
|
||||
qm.priority = priority;
|
||||
qm.size = size;
|
||||
qm.order = QueueMessage::order_counter++;
|
||||
// Overflow imminent, fail now!
|
||||
assert(QueueMessage::order_counter != std::numeric_limits<U64>::max());
|
||||
|
||||
std::memcpy(qm.data, buffer, static_cast<size_t>(size));
|
||||
if (size > this->shadow.messageSize) {
|
||||
return QueueInterface::Status::SIZE_MISMATCH;
|
||||
@ -113,7 +118,7 @@ TEST(InterfaceUninitialized, SendPointer) {
|
||||
Os::Queue queue;
|
||||
Fw::String name = "My queue";
|
||||
const FwSizeType messageSize = 200;
|
||||
const FwQueuePriorityType priority = 300;
|
||||
const FwQueuePriorityType priority = 127;
|
||||
U8 buffer[messageSize];
|
||||
|
||||
Os::QueueInterface::Status status =
|
||||
@ -125,7 +130,7 @@ TEST(InterfaceUninitialized, SendBuffer) {
|
||||
Os::Queue queue;
|
||||
Fw::String name = "My queue";
|
||||
const FwSizeType messageSize = 200;
|
||||
const FwQueuePriorityType priority = 300;
|
||||
const FwQueuePriorityType priority = 127;
|
||||
U8 storage[messageSize];
|
||||
Fw::ExternalSerializeBuffer buffer(storage, sizeof storage);
|
||||
|
||||
@ -173,7 +178,7 @@ TEST(InterfaceInvalid, SendPointerNull) {
|
||||
Os::Queue queue;
|
||||
Fw::String name = "My queue";
|
||||
const FwSizeType messageSize = 200;
|
||||
const FwQueuePriorityType priority = 300;
|
||||
const FwQueuePriorityType priority = 127;
|
||||
ASSERT_DEATH_IF_SUPPORTED(queue.send(nullptr, messageSize, priority, Os::QueueInterface::BlockingType::BLOCKING),
|
||||
"Assert:.*Queue\\.cpp");
|
||||
}
|
||||
@ -182,7 +187,7 @@ TEST(InterfaceInvalid, SendInvalidEnum) {
|
||||
Os::Queue queue;
|
||||
Fw::String name = "My queue";
|
||||
const FwSizeType messageSize = 200;
|
||||
const FwQueuePriorityType priority = 300;
|
||||
const FwQueuePriorityType priority = 127;
|
||||
Os::QueueInterface::BlockingType blockingType =
|
||||
static_cast<Os::QueueInterface::BlockingType>(Os::QueueInterface::BlockingType::BLOCKING + 1);
|
||||
ASSERT_DEATH_IF_SUPPORTED(queue.send(nullptr, messageSize, priority, blockingType), "Assert:.*Queue\\.cpp");
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "CommonTests.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
|
||||
struct PickedMessage {
|
||||
FwSizeType size;
|
||||
FwQueuePriorityType priority;
|
||||
@ -17,7 +18,8 @@ PickedMessage pick_message(FwSizeType max_size) {
|
||||
PickedMessage message;
|
||||
|
||||
message.size = STest::Random::lowerUpper(1, max_size);
|
||||
message.priority = STest::Random::lowerUpper(0, std::numeric_limits<U32>::max());
|
||||
// Force priority to be in a smaller range to produce more same-priority messages
|
||||
message.priority = STest::Random::lowerUpper(0, std::numeric_limits<I8>::max());
|
||||
|
||||
message.sent = new U8[message.size];
|
||||
for (FwSizeType i = 0; i < message.size; i++) {
|
||||
|
||||
@ -33,6 +33,8 @@ struct Tester {
|
||||
U8 data[QUEUE_MESSAGE_SIZE_UPPER_BOUND];
|
||||
FwQueuePriorityType priority = 0;
|
||||
FwSizeType size = 0;
|
||||
U64 order = 0;
|
||||
static U64 order_counter;
|
||||
};
|
||||
|
||||
struct ReceiveMessage {
|
||||
@ -42,7 +44,16 @@ struct Tester {
|
||||
};
|
||||
|
||||
struct QueueMessageComparer {
|
||||
bool operator()(const QueueMessage& a, const QueueMessage& b) { return HELPER(a.priority, b.priority); }
|
||||
bool operator()(const QueueMessage& a, const QueueMessage& b){
|
||||
// Compare priority for unequal priority
|
||||
if (a.priority != b.priority) {
|
||||
return HELPER(a.priority, b.priority);
|
||||
}
|
||||
// Cannot have like ordered items
|
||||
assert(a.order != b.order);
|
||||
// Compare received order for unequal received orders
|
||||
return a.order > b.order;
|
||||
}
|
||||
|
||||
private:
|
||||
static const PriorityCompare HELPER;
|
||||
|
||||
@ -32,10 +32,12 @@ namespace Svc {
|
||||
|
||||
void ActiveRateGroup::configure(U32 contexts[], FwIndexType numContexts) {
|
||||
FW_ASSERT(contexts);
|
||||
FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(),numContexts,this->getNum_RateGroupMemberOut_OutputPorts());
|
||||
FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(),
|
||||
static_cast<FwAssertArgType>(numContexts),
|
||||
static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
|
||||
FW_ASSERT(FW_NUM_ARRAY_ELEMENTS(this->m_contexts) == this->getNum_RateGroupMemberOut_OutputPorts(),
|
||||
FW_NUM_ARRAY_ELEMENTS(this->m_contexts),
|
||||
this->getNum_RateGroupMemberOut_OutputPorts());
|
||||
static_cast<FwAssertArgType>(FW_NUM_ARRAY_ELEMENTS(this->m_contexts)),
|
||||
static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
|
||||
|
||||
this->m_numContexts = numContexts;
|
||||
// copy context values
|
||||
|
||||
@ -62,7 +62,7 @@ namespace Svc {
|
||||
this->m_maxSize = maxFileSize;
|
||||
this->m_sizeOfSize = sizeOfSize;
|
||||
|
||||
FW_ASSERT(sizeOfSize <= sizeof(FwSizeType), sizeOfSize);
|
||||
FW_ASSERT(sizeOfSize <= sizeof(FwSizeType), static_cast<FwAssertArgType>(sizeOfSize));
|
||||
FW_ASSERT(m_maxSize > sizeOfSize, static_cast<FwAssertArgType>(m_maxSize));
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ void BufferRepeater ::configure(BufferRepeater::BufferRepeaterFailureOption allo
|
||||
bool BufferRepeater ::check_allocation(FwIndexType index,
|
||||
const Fw::Buffer& new_allocation,
|
||||
const Fw::Buffer& incoming_buffer) {
|
||||
FW_ASSERT(index < NUM_PORTOUT_OUTPUT_PORTS, index);
|
||||
FW_ASSERT(index < NUM_PORTOUT_OUTPUT_PORTS, static_cast<FwAssertArgType>(index));
|
||||
bool is_valid = (new_allocation.getData() != nullptr) && (new_allocation.getSize() >= incoming_buffer.getSize());
|
||||
|
||||
// Respond to invalid buffer allocation
|
||||
|
||||
@ -105,7 +105,7 @@ void ComQueue::configure(QueueConfigurationTable queueConfig,
|
||||
// Get current queue's allocation size and safety check the values
|
||||
FwSizeType allocationSize = this->m_prioritizedList[i].depth * this->m_prioritizedList[i].msgSize;
|
||||
FW_ASSERT(this->m_prioritizedList[i].index < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_queues)),
|
||||
this->m_prioritizedList[i].index);
|
||||
static_cast<FwAssertArgType>(this->m_prioritizedList[i].index));
|
||||
FW_ASSERT(
|
||||
(allocationSize + allocationOffset) <= totalAllocation,
|
||||
static_cast<FwAssertArgType>(allocationSize),
|
||||
@ -132,14 +132,15 @@ void ComQueue::configure(QueueConfigurationTable queueConfig,
|
||||
|
||||
void ComQueue::comQueueIn_handler(const FwIndexType portNum, Fw::ComBuffer& data, U32 context) {
|
||||
// Ensure that the port number of comQueueIn is consistent with the expectation
|
||||
FW_ASSERT(portNum >= 0 && portNum < COM_PORT_COUNT, portNum);
|
||||
FW_ASSERT(portNum >= 0 && portNum < COM_PORT_COUNT, static_cast<FwAssertArgType>(portNum));
|
||||
(void)this->enqueue(portNum, QueueType::COM_QUEUE, reinterpret_cast<const U8*>(&data), sizeof(Fw::ComBuffer));
|
||||
}
|
||||
|
||||
void ComQueue::buffQueueIn_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {
|
||||
const FwIndexType queueNum = portNum + COM_PORT_COUNT;
|
||||
FW_ASSERT(std::numeric_limits<FwIndexType>::max() - COM_PORT_COUNT > portNum);
|
||||
const FwIndexType queueNum = static_cast<FwIndexType>(portNum + COM_PORT_COUNT);
|
||||
// Ensure that the port number of buffQueueIn is consistent with the expectation
|
||||
FW_ASSERT(portNum >= 0 && portNum < BUFFER_PORT_COUNT, portNum);
|
||||
FW_ASSERT(portNum >= 0 && portNum < BUFFER_PORT_COUNT, static_cast<FwAssertArgType>(portNum));
|
||||
FW_ASSERT(queueNum < TOTAL_PORT_COUNT);
|
||||
bool status =
|
||||
this->enqueue(queueNum, QueueType::BUFFER_QUEUE, reinterpret_cast<const U8*>(&fwBuffer), sizeof(Fw::Buffer));
|
||||
@ -156,7 +157,7 @@ void ComQueue::comStatusIn_handler(const FwIndexType portNum, Fw::Success& condi
|
||||
this->m_state = READY;
|
||||
this->processQueue();
|
||||
// A message may or may not be sent. Thus, READY or WAITING are acceptable final states.
|
||||
FW_ASSERT((this->m_state == WAITING || this->m_state == READY), this->m_state);
|
||||
FW_ASSERT((this->m_state == WAITING || this->m_state == READY), static_cast<FwAssertArgType>(this->m_state));
|
||||
} else {
|
||||
this->m_state = WAITING;
|
||||
}
|
||||
@ -164,7 +165,7 @@ void ComQueue::comStatusIn_handler(const FwIndexType portNum, Fw::Success& condi
|
||||
// Both READY and unknown states should not be possible at this point. To receive a status message we must be
|
||||
// one of the WAITING or RETRY states.
|
||||
default:
|
||||
FW_ASSERT(0, this->m_state);
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(this->m_state));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -192,7 +193,7 @@ void ComQueue::run_handler(const FwIndexType portNum, U32 context) {
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ComQueue::buffQueueIn_overflowHook(FwIndexType portNum, Fw::Buffer& fwBuffer) {
|
||||
FW_ASSERT(portNum >= 0 && portNum < BUFFER_PORT_COUNT, portNum);
|
||||
FW_ASSERT(portNum >= 0 && portNum < BUFFER_PORT_COUNT, static_cast<FwAssertArgType>(portNum));
|
||||
this->deallocate_out(portNum, fwBuffer);
|
||||
}
|
||||
|
||||
@ -204,13 +205,15 @@ bool ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8
|
||||
// Enqueue the given message onto the matching queue. When no space is available then emit the queue overflow event,
|
||||
// set the appropriate throttle, and move on. Will assert if passed a message for a depth 0 queue.
|
||||
const FwSizeType expectedSize = (queueType == QueueType::COM_QUEUE) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer);
|
||||
const FwIndexType portNum = queueNum - ((queueType == QueueType::COM_QUEUE) ? 0 : COM_PORT_COUNT);
|
||||
FW_ASSERT((queueType == QueueType::COM_QUEUE) || (queueNum >= COM_PORT_COUNT),
|
||||
static_cast<FwAssertArgType>(queueType), static_cast<FwAssertArgType>(queueNum));
|
||||
const FwIndexType portNum = static_cast<FwIndexType>(queueNum - ((queueType == QueueType::COM_QUEUE) ? 0 : COM_PORT_COUNT));
|
||||
bool rvStatus = true;
|
||||
FW_ASSERT(
|
||||
expectedSize == size,
|
||||
static_cast<FwAssertArgType>(size),
|
||||
static_cast<FwAssertArgType>(expectedSize));
|
||||
FW_ASSERT(portNum >= 0, portNum);
|
||||
FW_ASSERT(portNum >= 0, static_cast<FwAssertArgType>(portNum));
|
||||
Fw::SerializeStatus status = this->m_queues[queueNum].enqueue(data, size);
|
||||
if (status == Fw::FW_SERIALIZE_NO_ROOM_LEFT) {
|
||||
if (!this->m_throttle[queueNum]) {
|
||||
|
||||
@ -14,7 +14,8 @@
|
||||
#include <new> // placement new
|
||||
|
||||
namespace Svc {
|
||||
|
||||
static_assert(DP_MAX_DIRECTORIES > 0, "Configuration DP_MAX_DIRECTORIES must be positive");
|
||||
static_assert(DP_MAX_FILES > 0, "Configuration DP_MAX_FILES must be positive");
|
||||
// ----------------------------------------------------------------------
|
||||
// Component construction and destruction
|
||||
// ----------------------------------------------------------------------
|
||||
@ -321,7 +322,7 @@ namespace Svc {
|
||||
void DpCatalog::appendFileState(const DpStateEntry& entry) {
|
||||
FW_ASSERT(this->m_stateFileData);
|
||||
FW_ASSERT(entry.dir < static_cast<FwIndexType>(this->m_numDirectories),
|
||||
entry.dir,
|
||||
static_cast<FwAssertArgType>(entry.dir),
|
||||
static_cast<FwAssertArgType>(this->m_numDirectories)
|
||||
);
|
||||
|
||||
@ -459,7 +460,7 @@ namespace Svc {
|
||||
static_cast<FwAssertArgType>(this->m_numDpSlots - totalFiles));
|
||||
|
||||
// extract metadata for each file
|
||||
for (FwNativeUIntType file = 0; file < filesRead; file++) {
|
||||
for (FwSizeType file = 0; file < filesRead; file++) {
|
||||
|
||||
// only consider files with the DP extension
|
||||
|
||||
|
||||
@ -204,7 +204,7 @@ namespace Svc {
|
||||
size = dataSize;
|
||||
stat = dpFile.write(dpData,size);
|
||||
if (stat != Os::File::Status::OP_OK) {
|
||||
printf("Error writing DP file data %s: status: %" PRI_FwNativeIntType "\n",fileName.toChar(),stat);
|
||||
printf("Error writing DP file data %s: status: %" PRI_FwEnumStoreType "\n",fileName.toChar(),static_cast<FwEnumStoreType>(stat));
|
||||
return;
|
||||
}
|
||||
if (static_cast<FwSizeType>(size) != dataSize) {
|
||||
|
||||
@ -61,7 +61,7 @@ namespace Svc {
|
||||
static_cast<FwSizeType>(fileQueueDepth),
|
||||
static_cast<FwSizeType>(sizeof(struct FileEntry))
|
||||
);
|
||||
FW_ASSERT(stat == Os::Queue::OP_OK, stat);
|
||||
FW_ASSERT(stat == Os::Queue::OP_OK, static_cast<FwAssertArgType>(stat));
|
||||
}
|
||||
|
||||
void FileDownlink ::
|
||||
@ -191,7 +191,8 @@ namespace Svc {
|
||||
return;
|
||||
}
|
||||
//Non-ignored buffers cannot be returned in "DOWNLINK" and "IDLE" state. Only in "WAIT", "CANCEL" state.
|
||||
FW_ASSERT(this->m_mode.get() == Mode::WAIT || this->m_mode.get() == Mode::CANCEL, this->m_mode.get());
|
||||
FW_ASSERT(this->m_mode.get() == Mode::WAIT || this->m_mode.get() == Mode::CANCEL,
|
||||
static_cast<FwAssertArgType>(this->m_mode.get()));
|
||||
//If the last packet has been sent (and is returning now) then finish the file
|
||||
if (this->m_lastCompletedType == Fw::FilePacket::T_END ||
|
||||
this->m_lastCompletedType == Fw::FilePacket::T_CANCEL) {
|
||||
@ -494,8 +495,9 @@ namespace Svc {
|
||||
void FileDownlink ::
|
||||
downlinkPacket()
|
||||
{
|
||||
FW_ASSERT(this->m_lastCompletedType != Fw::FilePacket::T_NONE, this->m_lastCompletedType);
|
||||
FW_ASSERT(this->m_mode.get() == Mode::CANCEL || this->m_mode.get() == Mode::DOWNLINK, this->m_mode.get());
|
||||
FW_ASSERT(this->m_lastCompletedType != Fw::FilePacket::T_NONE, static_cast<FwAssertArgType>(this->m_lastCompletedType));
|
||||
FW_ASSERT(this->m_mode.get() == Mode::CANCEL || this->m_mode.get() == Mode::DOWNLINK,
|
||||
static_cast<FwAssertArgType>(this->m_mode.get()));
|
||||
//If canceled mode and currently downlinking data then send a cancel packet
|
||||
if (this->m_mode.get() == Mode::CANCEL && this->m_lastCompletedType == Fw::FilePacket::T_START) {
|
||||
this->sendCancelPacket();
|
||||
@ -540,7 +542,7 @@ namespace Svc {
|
||||
getBuffer(Fw::Buffer& buffer, PacketType type)
|
||||
{
|
||||
//Check type is correct
|
||||
FW_ASSERT(type < COUNT_PACKET_TYPE && type >= 0, type);
|
||||
FW_ASSERT(type < COUNT_PACKET_TYPE && type >= 0, static_cast<FwAssertArgType>(type));
|
||||
// Wrap the buffer around our indexed memory.
|
||||
buffer.setData(this->m_memoryStore[type]);
|
||||
buffer.setSize(FILEDOWNLINK_INTERNAL_BUFFER_SIZE);
|
||||
|
||||
@ -16,8 +16,8 @@ constexpr U32 CIRCULAR_BUFFER_TEST_SIZE = 2048;
|
||||
//! \note The frame is generated with random data of random size
|
||||
//! \return The size of the generated frame
|
||||
FwSizeType generate_random_fprime_frame(Types::CircularBuffer& circular_buffer) {
|
||||
constexpr FwIndexType FRAME_HEADER_SIZE = 8;
|
||||
constexpr FwIndexType FRAME_FOOTER_SIZE = 4;
|
||||
constexpr FwSizeType FRAME_HEADER_SIZE = 8;
|
||||
constexpr FwSizeType FRAME_FOOTER_SIZE = 4;
|
||||
// Generate random packet size (1-1024 bytes; because 0 would trigger undefined behavior warnings)
|
||||
// 1024 is max length as per FrameAccumulator/FrameDetector/FprimeFrameDetector @ LengthToken::MaximumLength
|
||||
U32 packet_size = STest::Random::lowerUpper(1, 1024);
|
||||
@ -46,15 +46,15 @@ FwSizeType generate_random_fprime_frame(Types::CircularBuffer& circular_buffer)
|
||||
FwSizeType fprime_frame_size = FRAME_HEADER_SIZE + packet_size + FRAME_FOOTER_SIZE;
|
||||
U8 fprime_frame[fprime_frame_size];
|
||||
// Copy header, packet_data, and CRC into the full frame
|
||||
for (FwIndexType i = 0; i < static_cast<FwIndexType>(FRAME_HEADER_SIZE); i++) {
|
||||
for (FwSizeType i = 0; i < static_cast<FwSizeType>(FRAME_HEADER_SIZE); i++) {
|
||||
fprime_frame[i] = frame_header[i];
|
||||
}
|
||||
for (FwIndexType i = 0; i < static_cast<FwIndexType>(packet_size); i++) {
|
||||
for (FwSizeType i = 0; i < static_cast<FwSizeType>(packet_size); i++) {
|
||||
fprime_frame[i + FRAME_HEADER_SIZE] = packet_data[i];
|
||||
}
|
||||
for (FwIndexType i = 0; i < static_cast<FwIndexType>(FRAME_FOOTER_SIZE); i++) {
|
||||
for (FwSizeType i = 0; i < static_cast<FwSizeType>(FRAME_FOOTER_SIZE); i++) {
|
||||
// crc is a U32; unpack into 4 bytes (shift by 24->-16->8->0 bits, mask with 0xFF)
|
||||
fprime_frame[i + FRAME_HEADER_SIZE + static_cast<FwIndexType>(packet_size)] =
|
||||
fprime_frame[i + FRAME_HEADER_SIZE + static_cast<FwSizeType>(packet_size)] =
|
||||
static_cast<U8>((crc_result.asBigEndianU32() >> (8 * (3 - i))) & 0xFF);
|
||||
}
|
||||
// Serialize frame into circular buffer
|
||||
@ -62,7 +62,7 @@ FwSizeType generate_random_fprime_frame(Types::CircularBuffer& circular_buffer)
|
||||
|
||||
// Uncomment for debugging
|
||||
// printf("Serialized %llu bytes:\n", fprime_frame_size);
|
||||
// for (FwIndexType i = 0; i < static_cast<FwIndexType>(fprime_frame_size); i++) {
|
||||
// for (FwSizeType i = 0; i < static_cast<FwSizeType>(fprime_frame_size); i++) {
|
||||
// printf("%02X ", fprime_frame[i]);
|
||||
// }
|
||||
return fprime_frame_size;
|
||||
|
||||
@ -25,10 +25,12 @@ PassiveRateGroup::~PassiveRateGroup() {}
|
||||
|
||||
void PassiveRateGroup::configure(U32 contexts[], FwIndexType numContexts) {
|
||||
FW_ASSERT(contexts);
|
||||
FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(),numContexts,this->getNum_RateGroupMemberOut_OutputPorts());
|
||||
FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(),
|
||||
static_cast<FwAssertArgType>(numContexts),
|
||||
static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
|
||||
FW_ASSERT(FW_NUM_ARRAY_ELEMENTS(this->m_contexts) == this->getNum_RateGroupMemberOut_OutputPorts(),
|
||||
FW_NUM_ARRAY_ELEMENTS(this->m_contexts),
|
||||
this->getNum_RateGroupMemberOut_OutputPorts());
|
||||
static_cast<FwAssertArgType>(FW_NUM_ARRAY_ELEMENTS(this->m_contexts)),
|
||||
static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
|
||||
|
||||
this->m_numContexts = numContexts;
|
||||
// copy context values
|
||||
|
||||
@ -33,11 +33,11 @@ void SeqDispatcher::runSequence(FwIndexType sequencerIdx,
|
||||
// this function is only designed for internal usage
|
||||
// we can guarantee it cannot be called with input that would fail
|
||||
FW_ASSERT(sequencerIdx >= 0 && sequencerIdx < SeqDispatcherSequencerPorts,
|
||||
sequencerIdx);
|
||||
static_cast<FwAssertArgType>(sequencerIdx));
|
||||
FW_ASSERT(this->isConnected_seqRunOut_OutputPort(sequencerIdx));
|
||||
FW_ASSERT(this->m_entryTable[sequencerIdx].state ==
|
||||
SeqDispatcher_CmdSequencerState::AVAILABLE,
|
||||
this->m_entryTable[sequencerIdx].state);
|
||||
static_cast<FwAssertArgType>(this->m_entryTable[sequencerIdx].state));
|
||||
|
||||
if (block == Fw::Wait::NO_WAIT) {
|
||||
this->m_entryTable[sequencerIdx].state =
|
||||
@ -61,7 +61,8 @@ void SeqDispatcher::seqStartIn_handler(
|
||||
FwIndexType portNum, //!< The port number
|
||||
const Fw::StringBase& fileName //!< The sequence file name
|
||||
) {
|
||||
FW_ASSERT(portNum >= 0 && portNum < SeqDispatcherSequencerPorts, portNum);
|
||||
FW_ASSERT(portNum >= 0 && portNum < SeqDispatcherSequencerPorts,
|
||||
static_cast<FwAssertArgType>(portNum));
|
||||
if (this->m_entryTable[portNum].state ==
|
||||
SeqDispatcher_CmdSequencerState::RUNNING_SEQUENCE_BLOCK ||
|
||||
this->m_entryTable[portNum].state ==
|
||||
@ -96,7 +97,8 @@ void SeqDispatcher::seqDoneIn_handler(
|
||||
U32 cmdSeq, //!< Command Sequence
|
||||
const Fw::CmdResponse& response //!< The command response argument
|
||||
) {
|
||||
FW_ASSERT(portNum >= 0 && portNum < SeqDispatcherSequencerPorts, portNum);
|
||||
FW_ASSERT(portNum >= 0 && portNum < SeqDispatcherSequencerPorts,
|
||||
static_cast<FwAssertArgType>(portNum));
|
||||
if (this->m_entryTable[portNum].state !=
|
||||
SeqDispatcher_CmdSequencerState::RUNNING_SEQUENCE_BLOCK &&
|
||||
this->m_entryTable[portNum].state !=
|
||||
|
||||
@ -38,7 +38,7 @@ StaticMemoryComponentImpl ::~StaticMemoryComponentImpl() {}
|
||||
|
||||
void StaticMemoryComponentImpl ::bufferDeallocate_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {
|
||||
FW_ASSERT(portNum < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(m_static_memory)));
|
||||
FW_ASSERT(m_allocated[portNum], portNum); // It is also an error to deallocate before returning
|
||||
FW_ASSERT(m_allocated[portNum], static_cast<FwAssertArgType>(portNum)); // It is also an error to deallocate before returning
|
||||
// Check the memory returned is within the region
|
||||
FW_ASSERT(fwBuffer.getData() >= m_static_memory[portNum]);
|
||||
FW_ASSERT(
|
||||
@ -51,7 +51,7 @@ void StaticMemoryComponentImpl ::bufferDeallocate_handler(const FwIndexType port
|
||||
Fw::Buffer StaticMemoryComponentImpl ::bufferAllocate_handler(const FwIndexType portNum, Fw::Buffer::SizeType size) {
|
||||
FW_ASSERT(portNum < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(m_static_memory)));
|
||||
FW_ASSERT(size <= sizeof(m_static_memory[portNum])); // It is a topology error to ask for too much from this component
|
||||
FW_ASSERT(not m_allocated[portNum], portNum); // It is also an error to allocate again before returning
|
||||
FW_ASSERT(not m_allocated[portNum], static_cast<FwAssertArgType>(portNum)); // It is also an error to allocate again before returning
|
||||
m_allocated[portNum] = true;
|
||||
Fw::Buffer buffer(m_static_memory[portNum], sizeof(m_static_memory[0]));
|
||||
return buffer;
|
||||
|
||||
@ -48,23 +48,23 @@ typedef int PlatformIntType;
|
||||
typedef unsigned int PlatformUIntType;
|
||||
#define PRI_PlatformUIntType "u"
|
||||
|
||||
typedef PlatformIntType PlatformIndexType;
|
||||
#define PRI_PlatformIndexType PRI_PlatformIntType
|
||||
typedef int16_t PlatformIndexType;
|
||||
#define PRI_PlatformIndexType PRIi16
|
||||
|
||||
typedef int64_t PlatformSignedSizeType;
|
||||
#define PRI_PlatformSignedSizeType PRId64
|
||||
#define PRI_PlatformSignedSizeType PRIi64
|
||||
|
||||
typedef uint64_t PlatformSizeType;
|
||||
#define PRI_PlatformSizeType PRIu64
|
||||
|
||||
typedef PlatformIntType PlatformAssertArgType;
|
||||
#define PRI_PlatformAssertArgType PRI_PlatformIntType
|
||||
typedef int32_t PlatformAssertArgType;
|
||||
#define PRI_PlatformAssertArgType PRIi32
|
||||
|
||||
typedef PlatformIntType PlatformTaskPriorityType;
|
||||
#define PRI_PlatformTaskPriorityType PRI_PlatformIntType
|
||||
typedef uint8_t PlatformTaskPriorityType;
|
||||
#define PRI_PlatformTaskPriorityType PRIu8
|
||||
|
||||
typedef PlatformIntType PlatformQueuePriorityType;
|
||||
#define PRI_PlatformQueuePriorityType PRI_PlatformIntType
|
||||
typedef uint8_t PlatformQueuePriorityType;
|
||||
#define PRI_PlatformQueuePriorityType PRIu8
|
||||
|
||||
// Linux/Darwin definitions for pointer have various sizes across platforms
|
||||
// and since these definitions need to be consistent we must ask the size.
|
||||
|
||||
@ -13,8 +13,8 @@ namespace Svc {
|
||||
// data products can be stored. The array passed
|
||||
// to the initializer for DpCatalog cannot exceed
|
||||
// this size.
|
||||
static const FwSizeType DP_MAX_DIRECTORIES = 2;
|
||||
static const FwSizeType DP_MAX_FILES = 1000;
|
||||
static const FwIndexType DP_MAX_DIRECTORIES = 2;
|
||||
static const FwIndexType DP_MAX_FILES = 127;
|
||||
}
|
||||
|
||||
#endif /* SVC_DPCATALOG_CONFIG_HPP_ */
|
||||
|
||||
@ -39,14 +39,6 @@ typedef PlatformSizeType FwSizeType;
|
||||
typedef PlatformAssertArgType FwAssertArgType;
|
||||
#define PRI_FwAssertArgType PRI_PlatformAssertArgType
|
||||
|
||||
// The type of a machine integer. Ordinarily this should be int.
|
||||
typedef PlatformIntType FwNativeIntType;
|
||||
#define PRI_FwNativeIntType PRI_PlatformIntType
|
||||
|
||||
// The type of a machine unsigned integer. Ordinarily this should be unsigned int.
|
||||
typedef PlatformUIntType FwNativeUIntType;
|
||||
#define PRI_FwNativeUIntType PRI_PlatformUIntType
|
||||
|
||||
// Task priority type
|
||||
typedef PlatformTaskPriorityType FwTaskPriorityType;
|
||||
#define PRI_FwTaskPriorityType PRI_PlatformTaskPriorityType
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user