-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ (tests): on device - add deep sleep core buffered serial tests
- Loading branch information
Showing
3 changed files
with
123 additions
and
0 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
16 changes: 16 additions & 0 deletions
16
tests/functional/tests/deep_sleep_core_buffered_serial/CMakeLists.txt
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,16 @@ | ||
# Leka - LekaOS | ||
# Copyright 2022 APF France handicap | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
register_functional_test( | ||
TARGET | ||
functional_ut_deep_sleep_core_buffered_serial | ||
|
||
INCLUDE_DIRECTORIES | ||
|
||
SOURCES | ||
suite_core_buffered_serial.cpp | ||
|
||
LINK_LIBRARIES | ||
CoreBufferedSerial | ||
) |
106 changes: 106 additions & 0 deletions
106
tests/functional/tests/deep_sleep_core_buffered_serial/suite_core_buffered_serial.cpp
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,106 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <cstddef> | ||
|
||
#include "CoreBufferedSerial.h" | ||
#include "tests/config.h" | ||
#include "tests/utils.h" | ||
#include "tests/utils_sleep.h" | ||
|
||
using namespace leka; | ||
using namespace boost::ut; | ||
using namespace std::chrono; | ||
using namespace boost::ut::bdd; | ||
|
||
suite suite_core_buffered_serial = [] { | ||
scenario("default configuration") = [] { | ||
given("serial is in default configuration") = [] { | ||
auto serial = CoreBufferedSerial(RFID_UART_TX, RFID_UART_RX, 57600); | ||
|
||
expect(neq(&serial, nullptr)); | ||
|
||
when("I do nothing") = [] { | ||
then("I expect deep sleep TO NOT BE possible") = [] { | ||
auto status = utils::sleep::system_deep_sleep_check(); | ||
|
||
expect(not status.can_deep_sleep); | ||
expect(not status.test_check_ok); | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
scenario("disable input") = [] { | ||
given("serial is in default configuration") = [] { | ||
auto serial = CoreBufferedSerial(RFID_UART_TX, RFID_UART_RX, 57600); | ||
|
||
expect(neq(&serial, nullptr)); | ||
|
||
when("I disable input") = [&] { | ||
serial.disable_input(); | ||
rtos::ThisThread::sleep_for(5ms); | ||
|
||
then("I expect deep sleep TO BE possible") = [] { | ||
auto status = utils::sleep::system_deep_sleep_check(); | ||
|
||
expect(status.can_deep_sleep); | ||
expect(status.test_check_ok); | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
scenario("default, disable, enable, disable input") = [] { | ||
given("serial is in default configuration") = [] { | ||
auto serial = CoreBufferedSerial(RFID_UART_TX, RFID_UART_RX, 57600); | ||
|
||
expect(neq(&serial, nullptr)); | ||
|
||
when("I do nothing") = [] { | ||
then("I expect deep sleep TO NOT BE possible") = [] { | ||
auto status = utils::sleep::system_deep_sleep_check(); | ||
|
||
expect(not status.can_deep_sleep); | ||
expect(not status.test_check_ok); | ||
}; | ||
}; | ||
|
||
when("I disable input") = [&] { | ||
serial.disable_input(); | ||
rtos::ThisThread::sleep_for(5ms); | ||
|
||
then("I expect deep sleep TO BE possible") = [] { | ||
auto status = utils::sleep::system_deep_sleep_check(); | ||
|
||
expect(status.can_deep_sleep); | ||
expect(status.test_check_ok); | ||
}; | ||
}; | ||
|
||
when("I enable input") = [&] { | ||
serial.enable_input(); | ||
|
||
then("I expect deep sleep TO NOT BE possible") = [] { | ||
auto status = utils::sleep::system_deep_sleep_check(); | ||
|
||
expect(not status.can_deep_sleep); | ||
expect(not status.test_check_ok); | ||
}; | ||
}; | ||
|
||
when("I disable input") = [&] { | ||
serial.disable_input(); | ||
rtos::ThisThread::sleep_for(5ms); | ||
|
||
then("I expect deep sleep TO BE possible") = [] { | ||
auto status = utils::sleep::system_deep_sleep_check(); | ||
|
||
expect(status.can_deep_sleep); | ||
expect(status.test_check_ok); | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; |