-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add integration_test.flash_tested (#293)
* Add cucumber submodule * Add integration_test/test * .github/workflows/ci.yml: Checkout submodules * Update amp-embedded-infra-lib * Update amp-embedded-infra-lib: fix: infra/util/Endian: fix comparison against C++ version * Update amp-cucumber-cpp-runner-poc * .github/workflows/ci.yml: Remove Visual Studio 2019 and gcc 7 from tested compilers since they can't handle C++20 * Do some work on integration tests * Various fixes * Fix compilation * Run clang-format * Update .github/workflows/ci.yml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update devcontainer * Exclude gherkin libraries from all target * feat!: update MessageCommunication to Sesame * integration_test/test/FixtureEcho: Adapt for Sesame * CMakeLists: Don't set EXCLUDE_FROM_ALL on gherkin targets because otherwise they fail to install * integration_test/logic/Gpio: Differentiate between GpioTester and GpioTested's GpioChanged * integration_test/tested,tester/Main: Add tracing infrastructure * chore: add integration test board pcb (cherry picked from commit f20dc01) * integration_test/logic/Gpio: Fix order of RequestSend and setting sending * integration_test: Use UartStmDuplexDma * CMakeLists: Update amp-embedded-infralib * integration_test/{tester,tested}/Main: Add missing include * integration_test/{tester,tested}: Add tracing on ECHO calls * integration_test/test: Update and fix * Update amp-cucumber-cpp-runner-poc * Update amp-cucumber-cpp-runner * Change amp-cucumber-cpp-runner-poc to amp-cucumber-cpp-runner * Update amp-cucumber-cpp-runner * CMakeLists: Rename amp-cucumber-cpp-runner-poc to amp-cucumber-cpp-runner * launch.json: Set gdbPath to gdb-multiarch * Apply clang-format * Update amp-embedded-infralib, reset colour in GlobalTracer * integration_test: Reset tested before starting a scenario * Update amp-cucumber-cpp-runner * integration_test/test: Run tests and EventDispatcher from single thread * Remove integration_test/test/FixtureSystemChanges * Move EventDispatcherThreadAware to amp-embedded-infra-lib * integration_test: Add UART test * integration_test/test/Hooks: Get serial port to use from command line arguments * integration_test/test/FixtureEcho: Support Unix serial ports * Extract FixtureEchoSerial from FixtureEcho * integration_test/test/FixtureEcho: Refactor FixtureEchoSerial * integration_test/test/FixtureEcho: Add EchoClientWebSocket * Add integration_test/test/features/uart_duplex_dma.feature * Update amp-cucumber-cpp-runner * Rename integration_test.test to integration_test.runner * integration_test/tested: Add main for stm32wb55 * integration_test/runner/FixtureEcho: Add EchoClientTcp * integration_test: Adjust for DMA refactoring (cherry picked from commit 14689d2) * .github/workflows/ci.yml: fix merge mistake * CMakeLists: Only build integration_test when building amp-hal-st standalone * test: add integration_test.flash_tested * integration_test/flash_tested/Flash: Reduce lambda context size * Enable running tests on GitHub * Update amp-embedded-infra-lib * integration_test/logic/Tester: Add Ping * Fix merge conflict * Process review comments * Update amp-embedded-infra-lib * Update amp-cucumber-cpp-runner * Update amp-cucumber-cpp-runner * Update amp-cucumber-cpp-runner * Move Flash into integration_test/logic * Update amp-cucumber-cpp-runner * Use EXPECT_TRUE around infra::WaitUntilDone and infra::WaitFor * Disable compilation for stm32wb because it doesn't have Port::F * Update amp-cucumber-cpp-runner * Update .github/workflows/ci.yml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Temporarily add amp-embedded-infra-lib as submodule * Add integration_test/flasher * Use submodule amp-embedded-infra-lib * Fix merge mistakes * Update for merge --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Ron <45816308+rjaegers@users.noreply.github.com>
- Loading branch information
1 parent
bdd2507
commit ed21738
Showing
34 changed files
with
948 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
add_executable(integration_test.flasher) | ||
emil_build_for(integration_test.flasher HOST All) | ||
|
||
target_sources(integration_test.flasher PRIVATE | ||
Main.cpp | ||
) | ||
|
||
target_link_libraries(integration_test.flasher PRIVATE | ||
args | ||
integration_test.logic | ||
hal.generic | ||
services.network_instantiations | ||
) | ||
|
||
if (EMIL_BUILD_WIN) | ||
target_link_libraries(integration_test.flasher PRIVATE hal.windows) | ||
endif() | ||
|
||
if (EMIL_BUILD_UNIX OR EMIL_BUILD_DARWIN) | ||
target_link_libraries(integration_test.flasher PRIVATE hal.unix) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#include "args.hxx" | ||
#include "generated/echo/Testing.pb.hpp" | ||
#include "generated/echo/TracingFlash.pb.hpp" | ||
#include "generated/echo/TracingTesting.pb.hpp" | ||
#include "hal/generic/FileSystemGeneric.hpp" | ||
#include "hal/generic/TimerServiceGeneric.hpp" | ||
#include "integration_test/logic/Flash.hpp" | ||
#include "services/network_instantiations/EchoInstantiation.hpp" | ||
#include "services/network_instantiations/NetworkAdapter.hpp" | ||
#include "services/tracer/GlobalTracer.hpp" | ||
#include "services/tracer/TracerOnIoOutputInfrastructure.hpp" | ||
|
||
namespace | ||
{ | ||
const std::array<uint32_t, 12> stm32f767SectorSizes{ { 32 * 1024, | ||
32 * 1024, | ||
32 * 1024, | ||
32 * 1024, | ||
128 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024 } }; | ||
} | ||
|
||
class FirmwareSender | ||
{ | ||
public: | ||
FirmwareSender(const std::vector<uint8_t>& firmware, services::Echo& echo) | ||
: firmware(firmware) | ||
, flash(echo, infra::MakeRange(stm32f767SectorSizes)) | ||
, tester(echo) | ||
{ | ||
tester.RequestSend([this]() | ||
{ | ||
tester.SetTestedMode(testing::TestedMode::reset); | ||
tester.RequestSend([this]() | ||
{ | ||
tester.SetTestedMode(testing::TestedMode::programming); | ||
|
||
services::GlobalTracer().Trace() << "Erasing chip..."; | ||
flash.EraseAll([this]() | ||
{ | ||
services::GlobalTracer().Trace() << "Writing firmware..."; | ||
flash.WriteBuffer(infra::MakeRange(this->firmware), 0, [this]() | ||
{ | ||
services::GlobalTracer().Trace() << "Uploading done"; | ||
done = true; | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
bool Done() const | ||
{ | ||
return done; | ||
} | ||
|
||
private: | ||
std::vector<uint8_t> firmware; | ||
application::FlashProxy flash; | ||
testing::TesterProxy tester; | ||
bool done = false; | ||
|
||
infra::TimerSingleShot timeoutTimer{ std::chrono::minutes(2), [this]() | ||
{ | ||
done = true; | ||
} }; | ||
}; | ||
|
||
struct FlashTracer | ||
{ | ||
FlashTracer(services::TracingEchoOnStreams& echoTracer) | ||
: testerTracer(echoTracer) | ||
, testerObserverTracer(echoTracer) | ||
, flashTracer(echoTracer) | ||
, flashResultTracer(echoTracer) | ||
{} | ||
|
||
testing::TesterTracer testerTracer; | ||
testing::TesterObserverTracer testerObserverTracer; | ||
flash::FlashTracer flashTracer; | ||
flash::FlashResultTracer flashResultTracer; | ||
}; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
args::ArgumentParser parser("Flasher"); | ||
args::Group positionals(parser, "Positional arguments:"); | ||
args::Positional<std::string> targetArgument(positionals, "target", "COM port or hostname", args::Options::Required); | ||
args::Positional<std::string> firmwareArgument(positionals, "firmware", "Binary firmware with which the target attached to Postmaster is upgraded"); | ||
args::HelpFlag help(parser, "help", "display this help menu.", { 'h', "help" }); | ||
|
||
try | ||
{ | ||
parser.ParseCLI(argc, argv); | ||
|
||
static hal::TimerServiceGeneric timerService; | ||
static main_::TracerOnIoOutputInfrastructure tracer; | ||
static main_::NetworkAdapter network; | ||
static hal::FileSystemGeneric fileSystem; | ||
|
||
auto firmware = firmwareArgument ? fileSystem.ReadBinaryFile(args::get(firmwareArgument)) : std::vector<uint8_t>{}; | ||
auto [echo, echoTracer] = application::OpenTracingEcho(args::get(targetArgument), network.ConnectionFactoryWithNameResolver(), tracer.tracer); | ||
|
||
FlashTracer flashTracer(*echoTracer); | ||
FirmwareSender sender(firmware, *echo); | ||
|
||
network.ExecuteUntil([&]() | ||
{ | ||
return sender.Done(); | ||
}); | ||
} | ||
catch (const args::Help&) | ||
{ | ||
std::cout << parser; | ||
return 1; | ||
} | ||
catch (const std::exception& ex) | ||
{ | ||
std::cout << ex.what() << std::endl; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.