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

feat: add Cucumber integration tests #221

Merged
merged 79 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
79 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
dc6fc1d
Merge branch 'main' into feature/echo-sesame
magi-arun May 28, 2024
e28fdc0
Merge remote-tracking branch 'origin/main' into feature/echo-sesame
richardapeters Jul 25, 2024
17dc50e
Update amp-embedded-infra-lib
richardapeters Jul 25, 2024
9f2b1fe
Merge branch 'feature/echo-sesame' into feature/cucumber
richardapeters Jul 25, 2024
d33922c
Remove amp-cucumber-cpp-runner as submodule, use FetchContent instead
richardapeters Jul 25, 2024
42ef739
Use different version of amp-cucumber-cpp-runner
richardapeters Jul 25, 2024
a71c0ab
Merge branch 'main' into feature/cucumber
richardapeters Jul 25, 2024
20b15f2
Merge remote-tracking branch 'origin/main' into feature/cucumber
richardapeters Jul 25, 2024
c0851c9
integration_test/tested/CMakeLists: Disable stm32wb55 for now
richardapeters Jul 25, 2024
aa7bbd4
Merge remote-tracking branch 'origin/main' into feature/cucumber
EkelmansPh Aug 29, 2024
01e9374
chore: resolve some PR comments
EkelmansPh Aug 29, 2024
97292e6
Add EXPECT_TRUE to WaitFor and WaitUntil invocations
richardapeters Aug 29, 2024
97094e8
Update amp-devcontainer-cpp and amp-cucumber-cpp-runner
richardapeters Aug 30, 2024
e94ef83
Merge branch 'main' into feature/cucumber
richardapeters Aug 30, 2024
2e97074
Merge branch 'main' into feature/cucumber
richardapeters Sep 2, 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
21 changes: 15 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, windows-2019, macos-latest]
os: [windows-latest, macos-latest]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
Expand Down Expand Up @@ -73,12 +73,19 @@ jobs:
strategy:
matrix:
configuration: ["RelWithDebInfo"]
gcc: [ "10.3-2021.10" ]
target: ["stm32wb55", "stm32g070", "stm32g431", "stm32f407", "stm32f429", "stm32f746", "stm32f767", "stm32wba52"]
gcc: ["10.3-2021.10"]
target:
[
"stm32wb55",
"stm32wba52",
"stm32g070",
"stm32g431",
"stm32f407",
"stm32f429",
"stm32f746",
"stm32f767"
]
include:
- gcc: "7-2018-q2"
configuration: "RelWithDebInfo"
target: "stm32f767"
- gcc: "8-2019-q3"
configuration: "RelWithDebInfo"
target: "stm32f767"
Expand All @@ -87,6 +94,8 @@ jobs:
target: "stm32f767"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- name: Install GNU Arm Embedded Toolchain ${{ matrix.gcc }}
uses: carlosperate/arm-none-eabi-gcc-action@62a654ee770a4f3bd5aa8775d6d790aacb372b8f # v1.9.0
with:
Expand Down
Empty file added .gitmodules
richardapeters marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endif()

project(hal_st LANGUAGES C CXX ASM VERSION 3.0.0) # x-release-please-version

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED On)

set_directory_properties(PROPERTY USE_FOLDERS ON)
Expand All @@ -40,10 +40,24 @@ else()
set(HALST_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
endif()

if (EMIL_HOST_BUILD)
include(FetchContent)

FetchContent_Declare(
cucumber-cpp-runner
GIT_REPOSITORY https://github.com/philips-software/amp-cucumber-cpp-runner.git
GIT_TAG 7a25c498de47eaa53692b583c75ea6a0c4ac807d # unreleased
richardapeters marked this conversation as resolved.
Show resolved Hide resolved
)

FetchContent_MakeAvailable(cucumber-cpp-runner)
endif()

add_subdirectory(st)
add_subdirectory(hal_st)
add_subdirectory(hal_st_lwip)
add_subdirectory(integration_test)
if (HALST_STANDALONE)
add_subdirectory(integration_test)
endif()
add_subdirectory(services)
add_subdirectory(examples)

Expand Down
11 changes: 5 additions & 6 deletions hal_st/stm32fxxx/DefaultClockNucleoF767ZI.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include DEVICE_HEADER
#include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp"


/* The system Clock is configured as follows:
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 216000000
Expand Down Expand Up @@ -32,11 +31,11 @@ void ConfigureDefaultClockNucleo767ZI()
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 4; // Divides the 8MHz HSI to 2MHz
RCC_OscInitStruct.PLL.PLLN = 216; // Multiplies the 2MHz to 432MHz
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // Divides the 432MHz to 216MHz for SYSCLK
RCC_OscInitStruct.PLL.PLLQ = 9; // Divides the 432MHz to 48MHz for USB and SDMMC and RNG
RCC_OscInitStruct.PLL.PLLR = 7; // Divides the 432MHz to 62MHz for DSI (No clue what a good frequency would be here...)
RCC_OscInitStruct.PLL.PLLM = 4; // Divides the 8MHz HSI to 2MHz
RCC_OscInitStruct.PLL.PLLN = 216; // Multiplies the 2MHz to 432MHz
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // Divides the 432MHz to 216MHz for SYSCLK
RCC_OscInitStruct.PLL.PLLQ = 9; // Divides the 432MHz to 48MHz for USB and SDMMC and RNG
RCC_OscInitStruct.PLL.PLLR = 7; // Divides the 432MHz to 62MHz for DSI (No clue what a good frequency would be here...)
HAL_RCC_OscConfig(&RCC_OscInitStruct);

HAL_PWREx_EnableOverDrive();
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(tested)
add_subdirectory(tester)
add_subdirectory(runner)
2 changes: 2 additions & 0 deletions integration_test/logic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ target_sources(integration_test.logic PRIVATE
Tested.hpp
Tester.cpp
Tester.hpp
Uart.cpp
Uart.hpp
)

target_link_libraries(integration_test.logic PUBLIC
Expand Down
26 changes: 17 additions & 9 deletions integration_test/logic/Gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,50 @@ namespace application
in.DisableInterrupt();
}

void GpioBase::SetGpio(bool state, uint32_t pin)
void GpioBase::SetGpio(bool state)
{
out.Set(state);
}

void GpioBase::InChanged()
{
if (!sending)
if (!std::exchange(sending, true))
RequestSend([this]()
{
sending = false;
TestedGpioChanged(in.Get(), 0);
GpioChanged(in.Get());
});

sending = true;
}

GpioTester::GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin)
: GpioBase(echo, inPin, outPin)
, testing::GpioTester(echo)
{}

void GpioTester::SetGpio(bool state, uint32_t pin)
void GpioTester::SetGpio(bool state)
{
GpioBase::SetGpio(state, pin);
GpioBase::SetGpio(state);
MethodDone();
}

void GpioTester::GpioChanged(bool state)
{
TesterGpioChanged(state);
}

GpioTested::GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin)
: GpioBase(echo, inPin, outPin)
, testing::GpioTested(echo)
{}

void GpioTested::SetGpio(bool state, uint32_t pin)
void GpioTested::SetGpio(bool state)
{
GpioBase::SetGpio(state, pin);
GpioBase::SetGpio(state);
MethodDone();
}

void GpioTested::GpioChanged(bool state)
{
TestedGpioChanged(state);
}
}
15 changes: 12 additions & 3 deletions integration_test/logic/Gpio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ namespace application
GpioBase(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin);
~GpioBase();

void SetGpio(bool state, uint32_t pin);
void SetGpio(bool state);

protected:
virtual void GpioChanged(bool state) = 0;

private:
void InChanged();
Expand All @@ -32,7 +35,10 @@ namespace application
GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin);

// Implementation of GpioTester
void SetGpio(bool state, uint32_t pin) override;
void SetGpio(bool state) override;

protected:
virtual void GpioChanged(bool state) override;
};

class GpioTested
Expand All @@ -43,7 +49,10 @@ namespace application
GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin);

// Implementation of GpioTested
void SetGpio(bool state, uint32_t pin) override;
void SetGpio(bool state) override;

protected:
virtual void GpioChanged(bool state) override;
};
}

Expand Down
5 changes: 5 additions & 0 deletions integration_test/logic/Peripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ namespace application
return false;
});
}

void Peripherals::Reset()
{
currentPeripheral = nullptr;
}
}
21 changes: 11 additions & 10 deletions integration_test/logic/Peripheral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,38 @@ namespace application
virtual services::Echo& GetEcho() const = 0;

void EnablePeripheral(testing::Peripheral type);
void Reset();

private:
infra::SharedPtr<void> currentPeripheral;
};

template<class Constructed>
class Perpipheral
template<class Constructed, class... Args>
class Peripheral
: public PeripheralBase
{
public:
Perpipheral(Peripherals& subject, testing::Peripheral type);
Peripheral(Peripherals& subject, testing::Peripheral type, Args&&... args);

infra::SharedPtr<void> Construct() override;

private:
services::Echo& echo;
std::tuple<services::Echo&, Args...> args;
infra::SharedOptional<Constructed> constructed;
};

//// Implementation ////

template<class Constructed>
Perpipheral<Constructed>::Perpipheral(Peripherals& subject, testing::Peripheral type)
template<class Constructed, class... Args>
Peripheral<Constructed, Args...>::Peripheral(Peripherals& subject, testing::Peripheral type, Args&&... args)
: PeripheralBase(subject, type)
, echo(subject.GetEcho())
, args(subject.GetEcho(), std::forward<Args>(args)...)
{}

template<class Constructed>
infra::SharedPtr<void> Perpipheral<Constructed>::Construct()
template<class Constructed, class... Args>
infra::SharedPtr<void> Peripheral<Constructed, Args...>::Construct()
{
return constructed.Emplace(echo);
return std::apply(&infra::SharedOptional<Constructed>::template Emplace<services::Echo&, Args...>, std::tuple_cat(std::tuple<infra::SharedOptional<Constructed>&>(constructed), args));
}
}

Expand Down
10 changes: 10 additions & 0 deletions integration_test/logic/Tested.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ namespace application
{
Tested::Tested(services::Echo& echo)
: testing::Tested(echo)
, testedObserver(echo)
{}

void Tested::Ping()
{
testedObserver.RequestSend([this]()
{
testedObserver.Pong();
MethodDone();
});
}

void Tested::EnablePeripheral(testing::Peripheral type)
{
Peripherals::EnablePeripheral(type);
Expand Down
25 changes: 25 additions & 0 deletions integration_test/logic/Tested.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,35 @@ namespace application
Tested(services::Echo& echo);

// Implementation of Tested
void Ping() override;
void EnablePeripheral(testing::Peripheral type) override;

// Implementation of Peripherals
services::Echo& GetEcho() const override;

private:
testing::TestedObserverProxy testedObserver;
};

class TestedObserver
: public testing::TestedObserver
{
public:
using testing::TestedObserver::TestedObserver;

void Pong() override
{
pongReceived = true;
MethodDone();
}

bool ReceivedPong()
{
return std::exchange(pongReceived, false);
}

private:
bool pongReceived = false;
};
}

Expand Down
8 changes: 6 additions & 2 deletions integration_test/logic/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

namespace application
{
Tester::Tester(services::Echo& echo, hal::GpioPin& resetTesterPin)
Tester::Tester(services::Echo& echo, hal::GpioPin& resetTesterPin, services::EchoOnSesame& echoToTested)
: testing::Tester(echo)
, echoToTested(echoToTested)
, resetTester(resetTesterPin, true)
{}

void Tester::Reset()
{
resetTester.Set(false);

resetTimer.Start(std::chrono::milliseconds(3000), [this]()
Peripherals::Reset();
echoToTested.Reset();

resetTimer.Start(std::chrono::milliseconds(10), [this]()
{
resetTester.Set(true);
MethodDone();
Expand Down
6 changes: 3 additions & 3 deletions integration_test/logic/Tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "hal/interfaces/Gpio.hpp"
#include "infra/timer/Timer.hpp"
#include "integration_test/logic/Peripheral.hpp"
#include "services/util/EchoOnSesame.hpp"

namespace application
{
Expand All @@ -13,7 +14,7 @@ namespace application
, public Peripherals
{
public:
Tester(services::Echo& echo, hal::GpioPin& resetTesterPin);
Tester(services::Echo& echo, hal::GpioPin& resetTesterPin, services::EchoOnSesame& echoToTested);

// Implementation of Tester
void Reset() override;
Expand All @@ -23,10 +24,9 @@ namespace application
services::Echo& GetEcho() const override;

private:
services::EchoOnSesame& echoToTested;
hal::OutputPin resetTester;
infra::TimerSingleShot resetTimer;

infra::SharedPtr<void> currentPeripheral;
};
}

Expand Down
Loading
Loading