Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Os/Posix/test/ut/PosixConsoleTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
TEST(OffNominal, SwitchStream) {
Os::Posix::Console::PosixConsole posix_console;
ASSERT_DEATH(posix_console.setOutputStream(static_cast<Os::Posix::Console::PosixConsole::Stream>(3)), "Posix/|\\Console.cpp:33");
ASSERT_DEATH(posix_console.setOutputStream(static_cast<Os::Posix::Console::PosixConsole::Stream>(3)), "Posix/|\\Console.cpp:33"); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional death test

Check warning on line 23 in Os/Posix/test/ut/PosixConsoleTests.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`optin` is not a recognized word. (unrecognized-spelling)

Check warning on line 23 in Os/Posix/test/ut/PosixConsoleTests.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`NOLINT` is not a recognized word. (unrecognized-spelling)
}

int main(int argc, char** argv) {
Expand Down
6 changes: 5 additions & 1 deletion Os/Posix/test/ut/PosixDirectoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Fw/Types/String.hpp"

#include <fcntl.h> // for ::open()
#include <unistd.h> // for ::close()

namespace Os {
namespace Test {
Expand All @@ -35,7 +36,10 @@ void setUp(Os::Test::Directory::Tester* tester) {
tester->m_filenames.push_back(FILENAME_PREFIX + std::to_string(i));
}
for (auto filename : tester->m_filenames) {
::open((tester->m_path + "/" + filename).c_str(), O_CREAT);
int fd = ::open((tester->m_path + "/" + filename).c_str(), O_CREAT | O_WRONLY, 0644);
if (fd >= 0) {
::close(fd);
}
}
}

Expand Down
36 changes: 19 additions & 17 deletions Os/test/ut/queue/QueueRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@

#include "CommonTests.hpp"
#include "Fw/Types/String.hpp"
#include <memory>


struct PickedMessage {
FwSizeType size;
FwQueuePriorityType priority;
U8* sent;
std::unique_ptr<U8[]> sent;
U8 received[QUEUE_MESSAGE_SIZE_UPPER_BOUND];

// Constructor
PickedMessage() : size(0), priority(0), sent(nullptr) {}

// Get raw pointer for API compatibility
U8* get_sent() const { return sent.get(); }
};

PickedMessage pick_message(FwSizeType max_size) {
Expand All @@ -21,7 +28,7 @@ PickedMessage pick_message(FwSizeType max_size) {
// 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];
message.sent.reset(new U8[message.size]);
for (FwSizeType i = 0; i < message.size; i++) {
message.sent[i] = STest::Random::lowerUpper(0, std::numeric_limits<U8>::max());
}
Expand Down Expand Up @@ -83,9 +90,8 @@ void Os::Test::Queue::Tester::SendNotFull::action(Os::Test::Queue::Tester& state
// Prevent lock-up
ASSERT_LT(state.queue.getMessagesAvailable(), state.queue.getDepth());
ASSERT_FALSE(state.is_shadow_full());
QueueInterface::Status status = state.shadow_send(pick.sent, pick.size, pick.priority, blocking);
QueueInterface::Status test_status = state.queue.send(pick.sent, pick.size, pick.priority, blocking);
delete[] pick.sent; // Clean-up
QueueInterface::Status status = state.shadow_send(pick.get_sent(), pick.size, pick.priority, blocking);
QueueInterface::Status test_status = state.queue.send(pick.get_sent(), pick.size, pick.priority, blocking);
ASSERT_EQ(status, QueueInterface::Status::OP_OK);
ASSERT_EQ(test_status, status);
if (this->m_end_check) {
Expand All @@ -108,10 +114,9 @@ bool Os::Test::Queue::Tester::SendFullNoBlock::precondition(const Os::Test::Queu
void Os::Test::Queue::Tester::SendFullNoBlock::action(Os::Test::Queue::Tester& state //!< The test state
) {
PickedMessage pick = pick_message(state.shadow.messageSize);
QueueInterface::Status status = state.shadow_send(pick.sent, pick.size, pick.priority, QueueInterface::NONBLOCKING);
QueueInterface::Status status = state.shadow_send(pick.get_sent(), pick.size, pick.priority, QueueInterface::NONBLOCKING);
QueueInterface::Status test_status =
state.queue.send(pick.sent, pick.size, pick.priority, QueueInterface::NONBLOCKING);
delete[] pick.sent;
state.queue.send(pick.get_sent(), pick.size, pick.priority, QueueInterface::NONBLOCKING);

ASSERT_EQ(status, QueueInterface::Status::FULL);
ASSERT_EQ(test_status, status);
Expand Down Expand Up @@ -201,19 +206,17 @@ void Os::Test::Queue::Tester::Overflow::action(Os::Test::Queue::Tester& state /
while (not state.is_shadow_full()) {
PickedMessage pick = pick_message(state.shadow.messageSize);
QueueInterface::Status status =
state.shadow_send(pick.sent, pick.size, pick.priority, QueueInterface::BlockingType::NONBLOCKING);
state.shadow_send(pick.get_sent(), pick.size, pick.priority, QueueInterface::BlockingType::NONBLOCKING);
QueueInterface::Status test_status =
state.queue.send(pick.sent, pick.size, pick.priority, QueueInterface::BlockingType::NONBLOCKING);
delete[] pick.sent;
state.queue.send(pick.get_sent(), pick.size, pick.priority, QueueInterface::BlockingType::NONBLOCKING);
ASSERT_EQ(status, QueueInterface::Status::OP_OK);
ASSERT_EQ(status, test_status);
}
PickedMessage pick = pick_message(state.shadow.messageSize);
QueueInterface::Status status =
state.shadow_send(pick.sent, pick.size, pick.priority, QueueInterface::BlockingType::NONBLOCKING);
state.shadow_send(pick.get_sent(), pick.size, pick.priority, QueueInterface::BlockingType::NONBLOCKING);
QueueInterface::Status test_status =
state.queue.send(pick.sent, pick.size, pick.priority, QueueInterface::BlockingType::NONBLOCKING);
delete[] pick.sent;
state.queue.send(pick.get_sent(), pick.size, pick.priority, QueueInterface::BlockingType::NONBLOCKING);
ASSERT_EQ(status, QueueInterface::Status::FULL);
ASSERT_EQ(status, test_status);
state.shadow_check();
Expand Down Expand Up @@ -282,16 +285,15 @@ void Os::Test::Queue::Tester::SendBlock::action(Os::Test::Queue::Tester& state
PickedMessage pick = pick_message(state.shadow.messageSize);
this->notify_other("SendUnblock");
QueueInterface::Status status =
state.shadow_send(pick.sent, pick.size, pick.priority, QueueInterface::BlockingType::BLOCKING);
state.shadow_send(pick.get_sent(), pick.size, pick.priority, QueueInterface::BlockingType::BLOCKING);
getLock().unlock();
QueueInterface::Status test_status =
state.queue.send(pick.sent, pick.size, pick.priority, QueueInterface::BlockingType::BLOCKING);
state.queue.send(pick.get_sent(), pick.size, pick.priority, QueueInterface::BlockingType::BLOCKING);
getLock().lock();
// Condition should be set after block
ASSERT_TRUE(this->getCondition());
// Unblock the shadow queue send
state.shadow_send_unblock();
delete[] pick.sent;

ASSERT_EQ(status, QueueInterface::Status::OP_OK);
ASSERT_EQ(test_status, status);
Expand Down
2 changes: 1 addition & 1 deletion Svc/ActiveTextLogger/ActiveTextLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

// Format the string here, so that it is done in the task context
// of the caller. Format doc borrowed from PassiveTextLogger.
const char *severityString = "UNKNOWN";
const char *severityString;
switch (severity.e) {
case Fw::LogSeverity::FATAL:
severityString = "FATAL";
Expand Down
2 changes: 1 addition & 1 deletion Svc/BufferManager/test/ut/BufferManagerTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ namespace Svc {
for (U16 b=0; b<BIN1_NUM_BUFFERS; b++) {
U16 entry;
while (true) {
entry = rand() % BIN1_NUM_BUFFERS;
entry = arc4random() % BIN1_NUM_BUFFERS;
if (not returned[entry]) {
returned[entry] = true;
break;
Expand Down
4 changes: 2 additions & 2 deletions Svc/CmdSequencer/test/ut/SequenceFiles/BadDescriptorFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
Fw::Time t(TimeBase::TB_WORKSTATION_TIME, 0, 0);
// Force an invalid record descriptor
FPrime::Records::Descriptor descriptor =
static_cast<FPrime::Records::Descriptor>(10);
static_cast<FPrime::Records::Descriptor>(10); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional test

Check warning on line 54 in Svc/CmdSequencer/test/ut/SequenceFiles/BadDescriptorFile.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`optin` is not a recognized word. (unrecognized-spelling)

Check warning on line 54 in Svc/CmdSequencer/test/ut/SequenceFiles/BadDescriptorFile.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`NOLINT` is not a recognized word. (unrecognized-spelling)
FPrime::Records::serialize(
descriptor,
t,
Expand All @@ -73,7 +73,7 @@
for (U32 i = 0; i < this->n; ++i) {
// Force an invalid time flag
const AMPCSSequence::Record::TimeFlag::t timeFlag =
static_cast<AMPCSSequence::Record::TimeFlag::t>(10);
static_cast<AMPCSSequence::Record::TimeFlag::t>(10); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional test

Check warning on line 76 in Svc/CmdSequencer/test/ut/SequenceFiles/BadDescriptorFile.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`optin` is not a recognized word. (unrecognized-spelling)

Check warning on line 76 in Svc/CmdSequencer/test/ut/SequenceFiles/BadDescriptorFile.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`NOLINT` is not a recognized word. (unrecognized-spelling)
const AMPCSSequence::Record::Time::t time = 0;
const AMPCSSequence::Record::Opcode::t opcode = i;
const U32 argument = i + 1;
Expand Down
20 changes: 10 additions & 10 deletions Svc/DpCatalog/test/ut/DpCatalogTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,16 @@ namespace Svc {

// fill the input entries with random priorities
for (FwIndexType entry = 0; entry < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(inputs)); entry++) {
U32 randVal = rand()%NUM_ENTRIES;
U32 randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_priority(randVal);
randVal = rand()%NUM_ENTRIES;
randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_id(randVal);
randVal = rand()%NUM_ENTRIES;
randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_tSec(randVal);
inputs[entry].record.set_tSub(1500);
inputs[entry].record.set_size(100);
// randomly set if it is transmitted or not
randVal = rand()%2;
randVal = arc4random()%2;
if (randVal == 0) {
inputs[entry].record.set_state(Fw::DpState::UNTRANSMITTED);
// only put untransmitted products in list, since the catalog algorithm only returns untransmitted product IDs
Expand Down Expand Up @@ -622,7 +622,7 @@ namespace Svc {

// fill the input entries with random priorities
for (FwIndexType entry = 0; entry < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(inputs)); entry++) {
U32 randVal = rand()%NUM_ENTRIES;
U32 randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_priority(randVal);
inputs[entry].record.set_id(entry);
inputs[entry].record.set_state(Fw::DpState::UNTRANSMITTED);
Expand Down Expand Up @@ -675,7 +675,7 @@ namespace Svc {

// fill the input entries with random priorities
for (FwIndexType entry = 0; entry < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(inputs)); entry++) {
U32 randVal = rand()%NUM_ENTRIES;
U32 randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_priority(100);
inputs[entry].record.set_id(entry);
inputs[entry].record.set_state(Fw::DpState::UNTRANSMITTED);
Expand Down Expand Up @@ -730,7 +730,7 @@ namespace Svc {

// fill the input entries with random priorities
for (FwIndexType entry = 0; entry < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(inputs)); entry++) {
U32 randVal = rand()%NUM_ENTRIES;
U32 randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_priority(100);
inputs[entry].record.set_id(randVal);
inputs[entry].record.set_state(Fw::DpState::UNTRANSMITTED);
Expand Down Expand Up @@ -783,12 +783,12 @@ namespace Svc {

// fill the input entries with random priorities
for (FwIndexType entry = 0; entry < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(inputs)); entry++) {
U32 randVal = rand()%NUM_ENTRIES;
U32 randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_priority(randVal);
randVal = rand()%NUM_ENTRIES;
randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_id(randVal);
inputs[entry].record.set_state(Fw::DpState::UNTRANSMITTED);
randVal = rand()%NUM_ENTRIES;
randVal = arc4random()%NUM_ENTRIES;
inputs[entry].record.set_tSec(randVal);
inputs[entry].record.set_tSub(1500);
inputs[entry].record.set_size(100);
Expand Down
8 changes: 4 additions & 4 deletions Svc/EventManager/test/ut/EventManagerTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,28 +145,28 @@
U32 cmdSeq = 21;
this->clearHistory();
FilterSeverity reportFilterLevel = FilterSeverity::WARNING_HI;
Enabled filterEnabled(static_cast<Enabled::t>(10));
Enabled filterEnabled(static_cast<Enabled::t>(10)); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional invalid test

Check warning on line 148 in Svc/EventManager/test/ut/EventManagerTester.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`optin` is not a recognized word. (unrecognized-spelling)

Check warning on line 148 in Svc/EventManager/test/ut/EventManagerTester.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`NOLINT` is not a recognized word. (unrecognized-spelling)
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, reportFilterLevel, filterEnabled);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
this->clearHistory();
reportFilterLevel = FilterSeverity::WARNING_HI;
filterEnabled.e = static_cast<Enabled::t>(-2);
filterEnabled.e = static_cast<Enabled::t>(-2); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional invalid test

Check warning on line 154 in Svc/EventManager/test/ut/EventManagerTester.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`optin` is not a recognized word. (unrecognized-spelling)

Check warning on line 154 in Svc/EventManager/test/ut/EventManagerTester.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`NOLINT` is not a recognized word. (unrecognized-spelling)
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, reportFilterLevel, filterEnabled);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
FilterSeverity eventLevel;
this->clearHistory();
Enabled reportEnable = Enabled::ENABLED;
eventLevel.e = static_cast<FilterSeverity::t>(-1);
eventLevel.e = static_cast<FilterSeverity::t>(-1); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional invalid test
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, eventLevel, reportEnable);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);

this->clearHistory();

reportEnable = Enabled::ENABLED;
eventLevel.e = static_cast<FilterSeverity::t>(100);
eventLevel.e = static_cast<FilterSeverity::t>(100); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional invalid test
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, eventLevel, reportEnable);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ConsoleTextLoggerImpl::~ConsoleTextLoggerImpl() {}

void ConsoleTextLoggerImpl::TextLogger_handler(FwIndexType portNum, FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity& severity, Fw::TextLogString &text) {
const char *severityString = "UNKNOWN";
const char *severityString;
switch (severity.e) {
case Fw::LogSeverity::FATAL:
severityString = "FATAL";
Expand Down
4 changes: 2 additions & 2 deletions Utils/test/ut/RateLimiterTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace Utils {
Fw::Time nextTriggerTime(0, 0);
srand(0x30931842);
for (U32 iter = 0; iter < numIter; iter++) {
curTime.add(0, (rand() % 5 + 1) * 100000);
curTime.add(0, (arc4random() % 5 + 1) * 100000);
bool shouldTrigger = (cycles == 0) || (curTime >= nextTriggerTime);
bool triggered = limiter.trigger(curTime);
ASSERT_EQ(shouldTrigger, triggered) << " for cycles " << cycles << " at " << curTime.getSeconds() << "." << curTime.getUSeconds();
Expand Down Expand Up @@ -129,7 +129,7 @@ namespace Utils {
Fw::Time nextTriggerTime(0, 0);
srand(0x28E1ACC2);
for (U32 iter = 0; iter < numIter; iter++) {
curTime.add(0, (rand() % 5 + 1) * 100000);
curTime.add(0, (arc4random() % 5 + 1) * 100000);
bool shouldTrigger = ((iter-lastTriggerIter) % counterCycles == 0) || (curTime >= nextTriggerTime);
bool triggered = limiter.trigger(curTime);
ASSERT_EQ(shouldTrigger, triggered) << " for cycles " << counterCycles << "/" << timeCycles << " at " << iter << "/" << curTime.getSeconds() << "." << curTime.getUSeconds();
Expand Down
Loading