Skip to content

Commit

Permalink
Merge branch 'devel' into fpp/overflow-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch authored Sep 4, 2024
2 parents dcd0e50 + 672538d commit 36ec8c3
Show file tree
Hide file tree
Showing 20 changed files with 215 additions and 143 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/build-test-rpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- '.github/ISSUE_TEMPLATE/**'
env:
RPI_TOOLCHAIN_DIR: /tmp/rpi-toolchain
DICTIONARY_PATH: build-artifacts/raspberrypi/RPI/dict/RPITopologyAppDictionary.xml
DICTIONARY_PATH: build-artifacts/raspberrypi/RPI/dict/RPITopologyDictionary.json
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
RPI:
Expand Down Expand Up @@ -55,12 +55,23 @@ jobs:
runs-on: self-hosted
needs: RPI
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: 'requirements.txt'
- name: "Setup environment"
run: |
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- name: RPI Build Download
uses: actions/download-artifact@v3
with:
name: rpi-build
- name: RPI Integration Tests
run: chmod +x RPI/build-artifacts/raspberrypi/RPI/bin/RPI; /bin/bash ci/tests/RPI-Ints.bash
run: |
chmod +x RPI/build-artifacts/raspberrypi/RPI/bin/RPI
. venv/bin/activate
/bin/bash ci/tests/RPI-Ints.bash
# Archive the outputs
- name: 'Archive Logs'
uses: actions/upload-artifact@v3
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/ext-raspberry-led-blinker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ jobs:
runs-on: self-hosted
needs: cross-compilation
steps:
- name: "Checkout F´ Repository"
uses: actions/checkout@v4
with:
sparse-checkout: 'requirements.txt'
- name: "Setup environment"
run: |
python -m venv venv
. venv/bin/activate
pip install fprime-gds
pip install -r requirements.txt
- name: "Artifacts Download"
uses: actions/download-artifact@v3
with:
Expand All @@ -86,7 +90,7 @@ jobs:
chmod +x ./build-artifacts/raspberrypi/LedBlinker/bin/LedBlinker
fprime-gds --ip-client -d ./build-artifacts/raspberrypi/LedBlinker --logs ./ci-logs &
sleep 10
pytest --dictionary ./build-artifacts/raspberrypi/LedBlinker/dict/LedBlinkerTopologyAppDictionary.xml ./int/led_integration_tests.py
pytest --dictionary ./build-artifacts/raspberrypi/LedBlinker/dict/LedBlinkerTopologyDictionary.json ./int/led_integration_tests.py
- name: 'Archive logs'
uses: actions/upload-artifact@v3
if: always()
Expand Down
5 changes: 3 additions & 2 deletions Os/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ File::Status File::open(const CHAR* filepath, File::Mode requested_mode, File::O
if (status == File::Status::OP_OK) {
this->m_mode = requested_mode;
this->m_path = filepath;
// Reset any open CRC calculations
this->m_crc = File::INITIAL_CRC;
}
// Reset any open CRC calculations
this->m_crc = File::INITIAL_CRC;

return status;
}

Expand Down
1 change: 1 addition & 0 deletions Os/Posix/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void PosixConsole::writeMessage(const CHAR *message, const FwSizeType size) {
FwSizeType capped_size = (size <= std::numeric_limits<size_t>::max()) ? size : std::numeric_limits<size_t>::max();
if (message != nullptr) {
(void)::fwrite(message, sizeof(CHAR), static_cast<size_t>(capped_size), this->m_handle.m_file_descriptor);
(void)::fflush(this->m_handle.m_file_descriptor);
}
}

Expand Down
38 changes: 35 additions & 3 deletions Os/test/ut/file/FileRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// \title Os/test/ut/file/MyRules.cpp
// \brief rule implementations for common testing
// ======================================================================

#include <cstdio>
#include "RulesHeaders.hpp"
#include "STest/Pick/Pick.hpp"
extern "C" {
Expand All @@ -20,8 +20,8 @@ Os::File::Status Os::Test::File::Tester::shadow_open(const std::string &path, Os
this->m_independent_crc = Os::File::INITIAL_CRC;
} else {
this->m_current_path.clear();
this->m_mode = Os::File::Mode::OPEN_NO_MODE;
}

return status;
}

Expand Down Expand Up @@ -127,6 +127,8 @@ void Os::Test::File::Tester::assert_valid_mode_status(Os::File::Status &status)
void Os::Test::File::Tester::assert_file_consistent() {
// Ensure file mode
ASSERT_EQ(this->m_mode, this->m_file.m_mode);
// Ensure CRC match
ASSERT_EQ(this->m_file.m_crc, this->m_independent_crc);
if (this->m_file.m_path == nullptr) {
ASSERT_EQ(this->m_current_path, std::string(""));
} else {
Expand Down Expand Up @@ -256,6 +258,7 @@ bool Os::Test::File::Tester::OpenBaseRule::precondition(const Os::Test::File::Te

void Os::Test::File::Tester::OpenBaseRule::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
// Initial variables used for this test
std::shared_ptr<const std::string> filename = state.get_filename(this->m_random);

Expand Down Expand Up @@ -344,6 +347,7 @@ bool Os::Test::File::Tester::CloseFile::precondition(const Os::Test::File::Teste

void Os::Test::File::Tester::CloseFile::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
// Make sure test state and file state synchronized
state.assert_file_consistent();
state.assert_file_opened(state.m_current_path);
Expand Down Expand Up @@ -375,6 +379,7 @@ bool Os::Test::File::Tester::Read::precondition(
void Os::Test::File::Tester::Read::action(
Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
U8 buffer[FILE_DATA_MAXIMUM];
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
Expand Down Expand Up @@ -411,6 +416,7 @@ bool Os::Test::File::Tester::Write::precondition(
void Os::Test::File::Tester::Write::action(
Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
U8 buffer[FILE_DATA_MAXIMUM];
state.assert_file_consistent();
FwSignedSizeType size_desired = static_cast<FwSignedSizeType>(STest::Pick::lowerUpper(0, FILE_DATA_MAXIMUM));
Expand Down Expand Up @@ -448,6 +454,7 @@ bool Os::Test::File::Tester::Seek::precondition(
void Os::Test::File::Tester::Seek::action(
Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
FwSignedSizeType seek_offset = 0;
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
Expand Down Expand Up @@ -486,6 +493,7 @@ bool Os::Test::File::Tester::Preallocate::precondition(
void Os::Test::File::Tester::Preallocate::action(
Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
FwSignedSizeType offset = static_cast<FwSignedSizeType>(STest::Pick::lowerUpper(0, FILE_DATA_MAXIMUM));
Expand Down Expand Up @@ -519,6 +527,7 @@ bool Os::Test::File::Tester::Flush::precondition(
void Os::Test::File::Tester::Flush::action(
Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
Os::File::Status status = state.m_file.flush();
Expand Down Expand Up @@ -549,6 +558,7 @@ bool Os::Test::File::Tester::OpenInvalidModes::precondition(const Os::Test::File

void Os::Test::File::Tester::OpenInvalidModes::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
// Check initial file state
Expand Down Expand Up @@ -580,6 +590,7 @@ bool Os::Test::File::Tester::PreallocateWithoutOpen::precondition(

void Os::Test::File::Tester::PreallocateWithoutOpen::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
// Check initial file state
state.assert_file_closed();
Expand All @@ -606,6 +617,7 @@ bool Os::Test::File::Tester::SeekWithoutOpen::precondition(const Os::Test::File:

void Os::Test::File::Tester::SeekWithoutOpen::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
// Check initial file state
state.assert_file_closed();
Expand All @@ -632,6 +644,7 @@ bool Os::Test::File::Tester::SeekInvalidSize::precondition(const Os::Test::File:

void Os::Test::File::Tester::SeekInvalidSize::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
// Open file of given filename
Expand Down Expand Up @@ -662,6 +675,7 @@ bool Os::Test::File::Tester::FlushInvalidModes::precondition(const Os::Test::Fil

void Os::Test::File::Tester::FlushInvalidModes::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
ASSERT_TRUE(Os::File::Mode::OPEN_NO_MODE == state.m_file.m_mode || Os::File::Mode::OPEN_READ == state.m_file.m_mode);
Expand Down Expand Up @@ -689,6 +703,7 @@ bool Os::Test::File::Tester::ReadInvalidModes::precondition(const Os::Test::File

void Os::Test::File::Tester::ReadInvalidModes::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
U8 buffer[10];
FwSignedSizeType size = sizeof buffer;
state.assert_file_consistent();
Expand Down Expand Up @@ -720,6 +735,7 @@ bool Os::Test::File::Tester::WriteInvalidModes::precondition(const Os::Test::Fil

void Os::Test::File::Tester::WriteInvalidModes::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
U8 buffer[10];
FwSignedSizeType size = sizeof buffer;
state.assert_file_consistent();
Expand Down Expand Up @@ -756,6 +772,7 @@ Os::Test::File::Tester::OpenIllegalPath::OpenIllegalPath() : Os::Test::File::Tes

void Os::Test::File::Tester::OpenIllegalPath::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
Os::File::Mode random_mode =
static_cast<Os::File::Mode>(STest::Pick::lowerUpper(Os::File::Mode::OPEN_READ,
Expand All @@ -777,6 +794,7 @@ Os::Test::File::Tester::OpenIllegalMode::OpenIllegalMode() : Os::Test::File::Tes

void Os::Test::File::Tester::OpenIllegalMode::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
std::shared_ptr<const std::string> random_filename = state.get_filename(true);
U32 mode = STest::Pick::lowerUpper(0, 1);
Expand All @@ -799,6 +817,7 @@ Os::Test::File::Tester::PreallocateIllegalOffset::PreallocateIllegalOffset()

void Os::Test::File::Tester::PreallocateIllegalOffset::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FwSignedSizeType length = static_cast<FwSignedSizeType>(STest::Pick::any());
FwSignedSizeType invalid_offset =
Expand All @@ -818,6 +837,7 @@ Os::Test::File::Tester::PreallocateIllegalLength::PreallocateIllegalLength()

void Os::Test::File::Tester::PreallocateIllegalLength::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FwSignedSizeType offset = static_cast<FwSignedSizeType>(STest::Pick::any());
FwSignedSizeType invalid_length =
Expand All @@ -836,6 +856,7 @@ Os::Test::File::Tester::SeekIllegal::SeekIllegal() : Os::Test::File::Tester::Ass

void Os::Test::File::Tester::SeekIllegal::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
ASSERT_DEATH_IF_SUPPORTED(state.m_file.seek(-1, Os::File::SeekType::ABSOLUTE), Os::Test::File::Tester::ASSERT_IN_FILE_CPP);
state.assert_file_consistent();
Expand All @@ -851,6 +872,7 @@ Os::Test::File::Tester::ReadIllegalBuffer::ReadIllegalBuffer()

void Os::Test::File::Tester::ReadIllegalBuffer::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FwSignedSizeType size = static_cast<FwSignedSizeType>(STest::Pick::any());
bool random_wait = static_cast<bool>(STest::Pick::lowerUpper(0, 1));
Expand All @@ -869,6 +891,7 @@ Os::Test::File::Tester::ReadIllegalSize::ReadIllegalSize() : Os::Test::File::Tes

void Os::Test::File::Tester::ReadIllegalSize::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
U8 buffer[10] = {};
state.assert_file_consistent();
FwSignedSizeType invalid_size = -1 * static_cast<FwSignedSizeType>(STest::Pick::lowerUpper(0, std::numeric_limits<U32>::max()));
Expand All @@ -890,6 +913,7 @@ Os::Test::File::Tester::WriteIllegalBuffer::WriteIllegalBuffer()

void Os::Test::File::Tester::WriteIllegalBuffer::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FwSignedSizeType size = static_cast<FwSignedSizeType>(STest::Pick::any());
bool random_wait = static_cast<bool>(STest::Pick::lowerUpper(0, 1));
Expand All @@ -908,6 +932,7 @@ Os::Test::File::Tester::WriteIllegalSize::WriteIllegalSize() : Os::Test::File::T

void Os::Test::File::Tester::WriteIllegalSize::action(Os::Test::File::Tester &state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
U8 buffer[10] = {};
state.assert_file_consistent();
FwSignedSizeType invalid_size = -1 * static_cast<FwSignedSizeType>(STest::Pick::lowerUpper(0, std::numeric_limits<U32>::max()));
Expand Down Expand Up @@ -935,6 +960,7 @@ bool Os::Test::File::Tester::CopyAssignment::precondition(const Os::Test::File::

void Os::Test::File::Tester::CopyAssignment::action(Os::Test::File::Tester& state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
Os::File temp = state.m_file;
state.assert_file_consistent(); // Prevents optimization
Expand All @@ -959,6 +985,7 @@ bool Os::Test::File::Tester::CopyConstruction::precondition(const Os::Test::File

void Os::Test::File::Tester::CopyConstruction::action(Os::Test::File::Tester& state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
Os::File temp(state.m_file);
state.assert_file_consistent(); // Interim check to ensure original file did not change
Expand All @@ -984,6 +1011,7 @@ bool Os::Test::File::Tester::FullCrc::precondition(
void Os::Test::File::Tester::FullCrc::action(
Os::Test::File::Tester& state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
U32 crc = 1;
U32 shadow_crc = 2;
state.assert_file_consistent();
Expand Down Expand Up @@ -1013,6 +1041,7 @@ bool Os::Test::File::Tester::IncrementalCrc::precondition(
void Os::Test::File::Tester::IncrementalCrc::action(
Os::Test::File::Tester& state //!< The test state
){
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FwSignedSizeType size_desired = static_cast<FwSignedSizeType>(STest::Pick::lowerUpper(0, FW_FILE_CHUNK_SIZE));
FwSignedSizeType shadow_size = size_desired;
Expand Down Expand Up @@ -1041,10 +1070,11 @@ bool Os::Test::File::Tester::FinalizeCrc::precondition(
void Os::Test::File::Tester::FinalizeCrc::action(
Os::Test::File::Tester& state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
U32 crc = 1;
U32 shadow_crc = 2;
state.assert_file_consistent();
Os::File::Status status = state.m_file.finalizeCrc(crc);
Os::File::Status status = state.m_file.finalizeCrc(crc);
state.shadow_finalize(shadow_crc);
ASSERT_EQ(status, Os::File::Status::OP_OK);
ASSERT_EQ(crc, shadow_crc);
Expand All @@ -1069,6 +1099,7 @@ bool Os::Test::File::Tester::FullCrcInvalidModes::precondition(
void Os::Test::File::Tester::FullCrcInvalidModes::action(
Os::Test::File::Tester& state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
ASSERT_TRUE(Os::File::Mode::OPEN_READ != state.m_file.m_mode);
Expand Down Expand Up @@ -1102,6 +1133,7 @@ bool Os::Test::File::Tester::IncrementalCrcInvalidModes::precondition(
void Os::Test::File::Tester::IncrementalCrcInvalidModes::action(
Os::Test::File::Tester& state //!< The test state
) {
printf("--> Rule: %s \n", this->getName());
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
ASSERT_TRUE(Os::File::Mode::OPEN_READ != state.m_file.m_mode);
Expand Down
2 changes: 1 addition & 1 deletion RPI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ home network where the pi and the user's computer are connected to the same netw

```
cd fprime/RPI
fprime-gds -n --dictionary ./build-artifacts/raspberrypi/dict/RPITopologyAppDictionary.xml
fprime-gds -n --dictionary ./build-artifacts/raspberrypi/dict/RPITopologyDictionary.json
```
The ground station should now appear in the user's default browser. Should the user wish to terminate the ground system, return to that terminal
and press CTRL-C to shut it down. Please allow it a few moments to finalize and exit. The user may then kill the browser tab displaying the GUI.
Expand Down
18 changes: 9 additions & 9 deletions RPI/Top/RPITopologyDefs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ namespace RPI {

// Health ping entries
namespace PingEntries {
namespace rateGroup10HzComp { enum { WARN = 3, FATAL = 5 }; }
namespace rateGroup1HzComp { enum { WARN = 3, FATAL = 5 }; }
namespace cmdDisp { enum { WARN = 3, FATAL = 5 }; }
namespace cmdSeq { enum { WARN = 3, FATAL = 5 }; }
namespace chanTlm { enum { WARN = 3, FATAL = 5 }; }
namespace eventLogger { enum { WARN = 3, FATAL = 5 }; }
namespace prmDb { enum { WARN = 3, FATAL = 5 }; }
namespace fileDownlink { enum { WARN = 3, FATAL = 5 }; }
namespace fileUplink { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_rateGroup10HzComp { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_rateGroup1HzComp { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_cmdDisp { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_cmdSeq { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_chanTlm { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_eventLogger { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_prmDb { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_fileDownlink { enum { WARN = 3, FATAL = 5 }; }
namespace RPI_fileUplink { enum { WARN = 3, FATAL = 5 }; }
}

}
Expand Down
Loading

0 comments on commit 36ec8c3

Please sign in to comment.