Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add integration_test.flash_tested #293

Open
wants to merge 92 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
5ef4bc6
Add cucumber submodule
richardapeters Nov 23, 2023
e018d20
Add integration_test/test
richardapeters Nov 23, 2023
2fa388f
.github/workflows/ci.yml: Checkout submodules
richardapeters Nov 23, 2023
703758a
Update amp-embedded-infra-lib
richardapeters Nov 23, 2023
6b56845
Update amp-embedded-infra-lib: fix: infra/util/Endian: fix comparison…
richardapeters Nov 23, 2023
710f06f
Update amp-cucumber-cpp-runner-poc
richardapeters Nov 23, 2023
7612ec6
.github/workflows/ci.yml: Remove Visual Studio 2019 and gcc 7 from te…
richardapeters Nov 25, 2023
e7b437f
Do some work on integration tests
richardapeters Nov 27, 2023
1e23606
Various fixes
richardapeters Nov 30, 2023
84fe55d
Fix compilation
richardapeters Dec 2, 2023
b2135d9
Run clang-format
richardapeters Dec 2, 2023
077fc22
Update .github/workflows/ci.yml
richardapeters Dec 2, 2023
15f7ce5
Merge branch 'feature/cucumber' of https://github.com/philips-softwar…
richardapeters Dec 2, 2023
0f5f86a
Update devcontainer
richardapeters Dec 2, 2023
89999ff
Exclude gherkin libraries from all target
richardapeters Dec 3, 2023
7f54233
feat!: update MessageCommunication to Sesame
richardapeters Dec 28, 2023
c01cab9
Merge branch 'main' into feature/cucumber
richardapeters Dec 31, 2023
99e0cc0
Merge remote-tracking branch 'origin/feature/sesame' into feature/cuc…
richardapeters Dec 31, 2023
40140fd
integration_test/test/FixtureEcho: Adapt for Sesame
richardapeters Dec 31, 2023
7947ed4
CMakeLists: Don't set EXCLUDE_FROM_ALL on gherkin targets because oth…
richardapeters Dec 31, 2023
e592f22
integration_test/logic/Gpio: Differentiate between GpioTester and Gpi…
richardapeters Dec 31, 2023
9bc2e4a
integration_test/tested,tester/Main: Add tracing infrastructure
richardapeters Dec 31, 2023
3956d8f
chore: add integration test board pcb
richardapeters Nov 23, 2023
a56f450
integration_test/logic/Gpio: Fix order of RequestSend and setting sen…
richardapeters Jan 1, 2024
83f2daf
integration_test: Use UartStmDuplexDma
richardapeters Jan 1, 2024
e85a88e
CMakeLists: Update amp-embedded-infralib
richardapeters Jan 4, 2024
6cb70d8
Merge remote-tracking branch 'origin/main' into feature/cucumber
richardapeters Jan 4, 2024
22454a0
integration_test/{tester,tested}/Main: Add missing include
richardapeters Jan 4, 2024
27f2f90
integration_test/{tester,tested}: Add tracing on ECHO calls
richardapeters Jan 4, 2024
7ad0b79
integration_test/test: Update and fix
richardapeters Jan 4, 2024
066dd9e
Update amp-cucumber-cpp-runner-poc
richardapeters Jan 4, 2024
3382c9c
Merge commit '066dd9e0f1dbbe479401e93164eeef4526bcb7a2' into feature/…
richardapeters Jan 4, 2024
5656774
Update amp-cucumber-cpp-runner
richardapeters Jan 4, 2024
a7f79e0
Change amp-cucumber-cpp-runner-poc to amp-cucumber-cpp-runner
richardapeters Jan 4, 2024
bb582c5
Update amp-cucumber-cpp-runner
richardapeters Jan 4, 2024
2b3b436
CMakeLists: Rename amp-cucumber-cpp-runner-poc to amp-cucumber-cpp-ru…
richardapeters Jan 4, 2024
0a39688
launch.json: Set gdbPath to gdb-multiarch
richardapeters Jan 4, 2024
3fb6d1f
Apply clang-format
richardapeters Jan 4, 2024
3bb9c93
Update amp-embedded-infralib, reset colour in GlobalTracer
richardapeters Jan 6, 2024
aed23bb
integration_test: Reset tested before starting a scenario
richardapeters Jan 11, 2024
4271b6c
Update amp-cucumber-cpp-runner
richardapeters Jan 11, 2024
f136c67
integration_test/test: Run tests and EventDispatcher from single thread
richardapeters Jan 13, 2024
d98af9e
Remove integration_test/test/FixtureSystemChanges
richardapeters Jan 13, 2024
85e3bbe
Merge remote-tracking branch 'origin/main' into feature/cucumber
richardapeters Jan 13, 2024
b36226b
Move EventDispatcherThreadAware to amp-embedded-infra-lib
richardapeters Jan 13, 2024
3df6094
integration_test: Add UART test
richardapeters Jan 15, 2024
9dfd095
integration_test/test/Hooks: Get serial port to use from command line…
richardapeters Jan 17, 2024
cf63ce4
integration_test/test/FixtureEcho: Support Unix serial ports
richardapeters Jan 17, 2024
81c9305
Extract FixtureEchoSerial from FixtureEcho
richardapeters Jan 17, 2024
8ab6b56
integration_test/test/FixtureEcho: Refactor FixtureEchoSerial
richardapeters Jan 18, 2024
6913ee3
integration_test/test/FixtureEcho: Add EchoClientWebSocket
richardapeters Jan 20, 2024
4882511
Add integration_test/test/features/uart_duplex_dma.feature
richardapeters Jan 20, 2024
a225a91
Update amp-cucumber-cpp-runner
richardapeters Jan 20, 2024
b5f9440
Rename integration_test.test to integration_test.runner
richardapeters Jan 20, 2024
3aa8977
integration_test/tested: Add main for stm32wb55
richardapeters Jan 26, 2024
8cd8116
Merge remote-tracking branch 'origin/main' into feature/cucumber
richardapeters Jan 30, 2024
5594a45
Merge remote-tracking branch 'origin/main' into feature/sesame
richardapeters Feb 1, 2024
5b6746a
integration_test/runner/FixtureEcho: Add EchoClientTcp
richardapeters Feb 3, 2024
83785ec
Merge branch 'main' into feature/cucumber
richardapeters Feb 24, 2024
e035480
integration_test: Adjust for DMA refactoring
richardapeters Jan 30, 2024
700e942
.github/workflows/ci.yml: fix merge mistake
richardapeters Feb 24, 2024
d5bb1ec
CMakeLists: Only build integration_test when building amp-hal-st stan…
richardapeters Feb 29, 2024
fc8269e
Merge branch 'main' into feature/cucumber
rjaegers Feb 29, 2024
dcef943
Merge remote-tracking branch 'origin/main' into feature/sesame
richardapeters Mar 28, 2024
75efdbf
test: add integration_test.flash_tested
richardapeters Apr 11, 2024
6a3fdf3
integration_test/flash_tested/Flash: Reduce lambda context size
richardapeters Apr 12, 2024
bb4dab5
Enable running tests on GitHub
richardapeters Apr 12, 2024
5f7bfed
Update amp-embedded-infra-lib
richardapeters Jun 6, 2024
0b64f2c
integration_test/logic/Tester: Add Ping
richardapeters Jun 6, 2024
cec2d01
Merge remote-tracking branch 'origin/main' into feature/flash-tested
richardapeters Jun 6, 2024
b78e83f
Merge remote-tracking branch 'origin/main' into feature/sesame
richardapeters Jun 6, 2024
eb47856
Merge branch 'feature/sesame' into feature/flash-tested
richardapeters Jun 6, 2024
9517edb
Merge remote-tracking branch 'origin/feature/cucumber' into feature/f…
richardapeters Jun 6, 2024
c624001
Fix merge conflict
richardapeters Jun 6, 2024
6fc47e1
Process review comments
richardapeters Jun 6, 2024
863496d
Update amp-embedded-infra-lib
richardapeters Jun 6, 2024
6e9fdf7
Update amp-cucumber-cpp-runner
richardapeters Jun 6, 2024
fe8d4f2
Update amp-cucumber-cpp-runner
richardapeters Jun 6, 2024
fdc7248
Update amp-cucumber-cpp-runner
richardapeters Jun 6, 2024
2fbc9c3
Merge branch 'main' into feature/flash-tested
richardapeters Jun 7, 2024
a3ac27b
Move Flash into integration_test/logic
richardapeters Jul 4, 2024
965e886
Update amp-cucumber-cpp-runner
richardapeters Jul 4, 2024
4f0c605
Use EXPECT_TRUE around infra::WaitUntilDone and infra::WaitFor
richardapeters Jul 4, 2024
4c0a86a
Merge remote-tracking branch 'origin/main' into feature/flash-tested
richardapeters Jul 4, 2024
c39bbbd
Disable compilation for stm32wb because it doesn't have Port::F
richardapeters Jul 5, 2024
7d561fe
Update amp-cucumber-cpp-runner
richardapeters Jul 5, 2024
de793a2
Update .github/workflows/ci.yml
richardapeters Jul 5, 2024
33eece1
Temporarily add amp-embedded-infra-lib as submodule
richardapeters Jul 18, 2024
2d3e5af
Add integration_test/flasher
richardapeters Jul 22, 2024
870e000
Use submodule amp-embedded-infra-lib
richardapeters Jul 25, 2024
5d1fd13
Merge remote-tracking branch 'origin/main' into feature/flash-tested
richardapeters Sep 11, 2024
e8fe18d
Fix merge mistakes
richardapeters Sep 11, 2024
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
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()

option(CMAKE_COMPILE_WARNING_AS_ERROR "Enable warnings-as-error" ON)
option(HALST_BUILD_TESTS "Enable building the tests" Off)
option(HALST_INCLUDE_DEFAULT_INIT "Include default initialization code; turn off when providing custom initialization" ON)
option(HALST_BUILD_EXAMPLES "Enable build of the examples" OFF)
option(HALST_BUILD_EXAMPLES_FREERTOS "Enable build of the FreeRTOS example" OFF)
set(HALST_XML_GPIO "" CACHE STRING "XML GPIO table")
set(HALST_XML_STM32 "" CACHE STRING "XML STM32 table")

if (HALST_BUILD_TESTS)
richardapeters marked this conversation as resolved.
Show resolved Hide resolved
# CTest cannot be included before the first project() statement, but Embedded Infastructure
richardapeters marked this conversation as resolved.
Show resolved Hide resolved
# Library needs to see that test utilities need to be built.
set(BUILD_TESTING On)
endif()

if (HALST_STANDALONE)
set(EMIL_INCLUDE_FREERTOS ${HALST_BUILD_EXAMPLES_FREERTOS})

Expand Down Expand Up @@ -40,6 +47,11 @@ else()
set(HALST_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
endif()

if (HALST_BUILD_TESTS)
include(CTest)
emil_enable_testing()
endif()

add_subdirectory(st)
add_subdirectory(hal_st)
add_subdirectory(hal_st_lwip)
Expand Down
9 changes: 6 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"inherits": "defaults",
"cacheVariables": {
"CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel",
"EMIL_BUILD_ECHO_COMPILERS": true
"EMIL_BUILD_ECHO_COMPILERS": true,
"HALST_BUILD_TESTS": true
},
"generator": "Ninja Multi-Config"
},
Expand All @@ -26,15 +27,17 @@
"displayName": "Configuration for Host Tooling and Tests, Single Config Generator, Debug",
"inherits": "defaults",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
"CMAKE_BUILD_TYPE": "Debug",
"HALST_BUILD_TESTS": true
}
},
{
"name": "host-single-MinSizeRel",
"displayName": "Configuration for Host Tooling and Tests, Single Config Generator, MinSizeRel",
"inherits": "defaults",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel"
"CMAKE_BUILD_TYPE": "MinSizeRel",
"HALST_BUILD_TESTS": true
}
},
{
Expand Down
1 change: 1 addition & 0 deletions integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(logic)
add_subdirectory(flash_tested)
add_subdirectory(tested)
add_subdirectory(tester)
19 changes: 19 additions & 0 deletions integration_test/flash_tested/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_library(integration_test.flash_tested ${HALST_EXCLUDE_FROM_ALL})

target_include_directories(integration_test.flash_tested PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../..>"
)

protocol_buffer_echo_cpp(integration_test.flash_tested Flash.proto)

target_sources(integration_test.flash_tested PRIVATE
Flash.cpp
Flash.hpp
)

target_link_libraries(integration_test.flash_tested PUBLIC
services.util
protobuf.echo
)

add_subdirectory(test)
149 changes: 149 additions & 0 deletions integration_test/flash_tested/Flash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#include "integration_test/flash_tested/Flash.hpp"
#include <utility>

namespace application
{
Flash::Flash(services::Echo& echo, hal::Flash& flash)
: flash::Flash(echo)
, flashResult(echo)
, flash(flash)
{}

void Flash::Read(uint32_t address, uint32_t size)
{
flash.ReadBuffer(infra::Head(infra::MakeRange(buffer), size), address, [this, size]()
{
flashResult.RequestSend([this, size]()
{
flashResult.ReadDone(infra::Head(infra::MakeRange(buffer), size));
MethodDone();
});
});
}

void Flash::Write(uint32_t address, infra::ConstByteRange contents)
{
flash.WriteBuffer(contents, address, [this]()
{
flashResult.RequestSend([this]()
{
flashResult.WriteDone();
MethodDone();
});
});
}

void Flash::EraseSectors(uint32_t sector, uint32_t numberOfSectors)
{
flash.EraseSectors(sector, sector + numberOfSectors, [this]()
{
flashResult.RequestSend([this]()
{
flashResult.EraseSectorsDone();
MethodDone();
});
});
}

FlashProxy::FlashProxy(services::Echo& echo)
: flash::FlashResult(echo)
, proxy(echo)
{}

void FlashProxy::WriteBuffer(infra::ConstByteRange buffer, uint32_t address, infra::Function<void()> onDone)
{
writingBuffer = buffer;
this->onDone = onDone;

if (!writingBuffer.empty())
proxy.RequestSend([this, address]()
{
++transferBuffers;
auto size = std::min(writingBuffer.size(), std::tuple_size<std::remove_reference_t<decltype(std::declval<flash::WriteRequest>().contents.Storage())>>::value);
proxy.Write(address, infra::Head(writingBuffer, size));
WriteBuffer(infra::DiscardHead(writingBuffer, size), address + size, this->onDone.Clone());
});
}

void FlashProxy::ReadBuffer(infra::ByteRange buffer, uint32_t address, infra::Function<void()> onDone)
{
readingBuffer = buffer;
this->onDone = onDone;

ReadPartialBuffer(address, 0);
}

void FlashProxy::EraseSectors(uint32_t beginIndex, uint32_t endIndex, infra::Function<void()> onDone)
{
this->onDone = onDone;
x = endIndex;

proxy.RequestSend([this, beginIndex]()
{
proxy.EraseSectors(beginIndex, x - beginIndex);
});
}

void FlashProxy::ReadDone(infra::ConstByteRange contents)
{
infra::Copy(contents, infra::Head(readingBuffer, contents.size()));
readingBuffer = infra::DiscardHead(readingBuffer, contents.size());

--transferBuffers;
if (transferBuffers == 0 && readingBuffer.empty())
onDone();
}

void FlashProxy::WriteDone()
{
--transferBuffers;
if (transferBuffers == 0 && writingBuffer.empty())
onDone();
}

void FlashProxy::EraseSectorsDone()
{
onDone();
}

void FlashProxy::ReadPartialBuffer(uint32_t address, uint32_t start)
{
if (readingBuffer.size() - start > 0)
{
x = start;
proxy.RequestSend([this, address]()
{
++transferBuffers;
auto size = std::min<uint32_t>(readingBuffer.size() - x, std::tuple_size<std::remove_reference_t<decltype(std::declval<flash::WriteRequest>().contents.Storage())>>::value);
proxy.Read(address + x, size);
ReadPartialBuffer(address, x + size);
});
}
}

FlashHomogeneousProxy::FlashHomogeneousProxy(services::Echo& echo, uint32_t numberOfSectors, uint32_t sizeOfEachSector)
: FlashProxy(echo)
, numberOfSectors(numberOfSectors)
, sizeOfEachSector(sizeOfEachSector)
{}

uint32_t FlashHomogeneousProxy::NumberOfSectors() const
{
return numberOfSectors;
}

uint32_t FlashHomogeneousProxy::SizeOfSector(uint32_t sectorIndex) const
{
return sizeOfEachSector;
}

uint32_t FlashHomogeneousProxy::SectorOfAddress(uint32_t address) const
{
return address / sizeOfEachSector;
}

uint32_t FlashHomogeneousProxy::AddressOfSector(uint32_t sectorIndex) const
{
return sectorIndex * sizeOfEachSector;
}
}
74 changes: 74 additions & 0 deletions integration_test/flash_tested/Flash.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#ifndef HAL_ST_INTEGRATION_TEST_FLASH_HPP
#define HAL_ST_INTEGRATION_TEST_FLASH_HPP

#include "generated/echo/Flash.pb.hpp"
#include "hal/interfaces/FlashHomogeneous.hpp"
#include "infra/util/AutoResetFunction.hpp"

namespace application
{
class Flash
: public flash::Flash
{
public:
Flash(services::Echo& echo, hal::Flash& flash);

// Implementation of flash::Flash
void Read(uint32_t address, uint32_t size) override;
void Write(uint32_t address, infra::ConstByteRange contents) override;
void EraseSectors(uint32_t sector, uint32_t numberOfSectors) override;

private:
flash::FlashResultProxy flashResult;
hal::Flash& flash;

std::array<uint8_t, std::tuple_size<std::remove_reference_t<decltype(std::declval<flash::WriteRequest>().contents.Storage())>>::value> buffer;
richardapeters marked this conversation as resolved.
Show resolved Hide resolved
};

class FlashProxy
: public hal::Flash
, private flash::FlashResult
{
public:
FlashProxy(services::Echo& echo);

// Implementation of hal::Flash
void WriteBuffer(infra::ConstByteRange buffer, uint32_t address, infra::Function<void()> onDone) override;
void ReadBuffer(infra::ByteRange buffer, uint32_t address, infra::Function<void()> onDone) override;
void EraseSectors(uint32_t beginIndex, uint32_t endIndex, infra::Function<void()> onDone) override;

private:
// Implementation of flash::FlashResult
void ReadDone(infra::ConstByteRange contents) override;
void WriteDone() override;
void EraseSectorsDone() override;

void ReadPartialBuffer(uint32_t address, uint32_t start);

private:
flash::FlashProxy proxy;
infra::AutoResetFunction<void()> onDone;
infra::ConstByteRange writingBuffer;
infra::ByteRange readingBuffer;
uint32_t transferBuffers = 0;
uint32_t x;
richardapeters marked this conversation as resolved.
Show resolved Hide resolved
};

class FlashHomogeneousProxy
: public FlashProxy
{
public:
FlashHomogeneousProxy(services::Echo& echo, uint32_t numberOfSectors, uint32_t sizeOfEachSector);

uint32_t NumberOfSectors() const override;
uint32_t SizeOfSector(uint32_t sectorIndex) const override;
uint32_t SectorOfAddress(uint32_t address) const override;
uint32_t AddressOfSector(uint32_t sectorIndex) const override;

private:
uint32_t numberOfSectors;
uint32_t sizeOfEachSector;
};
}

#endif
46 changes: 46 additions & 0 deletions integration_test/flash_tested/Flash.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
syntax = "proto3";

import "EchoAttributes.proto";

package flash;

message ReadRequest
{
uint32 address = 1;
uint32 size = 2;
}

message ReadResponse
{
bytes contents = 1 [(bytes_size) = 512];
}

message WriteRequest
{
uint32 address = 1;
bytes contents = 2 [(bytes_size) = 512];
}

message EraseSectorsRequest
{
uint32 sector = 1;
uint32 number_of_sectors = 2;
}

service Flash
{
option (service_id) = 6;

rpc Read(ReadRequest) returns (Nothing) { option (method_id) = 1; }
rpc Write(WriteRequest) returns (Nothing) { option (method_id) = 2; }
rpc EraseSectors(EraseSectorsRequest) returns (Nothing) { option (method_id) = 3; }
}

service FlashResult
{
option (service_id) = 7;

rpc ReadDone(ReadResponse) returns (Nothing) { option (method_id) = 1; }
rpc WriteDone(Nothing) returns (Nothing) { option (method_id) = 2; }
rpc EraseSectorsDone(Nothing) returns (Nothing) { option (method_id) = 3; }
}
13 changes: 13 additions & 0 deletions integration_test/flash_tested/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add_executable(integration_test.flash_tested.test)
emil_build_for(integration_test.flash_tested.test BOOL HALST_BUILD_TESTS)
emil_add_test(integration_test.flash_tested.test)

target_link_libraries(integration_test.flash_tested.test PUBLIC
gmock_main
integration_test.flash_tested
protobuf.test_doubles
)

target_sources(integration_test.flash_tested.test PRIVATE
TestFlash.cpp
)
Loading
Loading