-
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.
✅ (tests): on device - add deep sleep core pwm tests
- Loading branch information
Showing
3 changed files
with
226 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
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_pwm | ||
|
||
INCLUDE_DIRECTORIES | ||
|
||
SOURCES | ||
suite_core_pwm.cpp | ||
|
||
LINK_LIBRARIES | ||
CorePwm | ||
) |
209 changes: 209 additions & 0 deletions
209
tests/functional/tests/deep_sleep_core_pwm/suite_core_pwm.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,209 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <cstddef> | ||
|
||
#include "CorePwm.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_pwm = [] { | ||
scenario("write") = [] { | ||
given("pwm is in default configuration") = [] { | ||
auto pwm = CorePwm(MOTOR_LEFT_PWM); | ||
|
||
expect(neq(&pwm, 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("pwm is running at 100%") = [&] { | ||
pwm.write(1.0); | ||
|
||
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("pwm is running at 50%") = [&] { | ||
pwm.write(0.5); | ||
|
||
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("pwm is running at 0%") = [&] { | ||
pwm.write(0.0); | ||
|
||
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("suspend, resume") = [] { | ||
given("pwm is in default configuration") = [] { | ||
auto pwm = CorePwm(MOTOR_LEFT_PWM); | ||
|
||
expect(neq(&pwm, 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("pwm is suspended") = [&] { | ||
pwm.suspend(); | ||
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("pwm is resumed") = [&] { | ||
pwm.resume(); | ||
|
||
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("write 100%, suspend, resume") = [] { | ||
given("pwm is in default configuration") = [] { | ||
auto pwm = CorePwm(MOTOR_LEFT_PWM); | ||
|
||
expect(neq(&pwm, 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("pwm is running at 100%") = [&] { | ||
pwm.write(1.0); | ||
|
||
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("pwm is suspended") = [&] { | ||
pwm.suspend(); | ||
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("pwm is resumed") = [&] { | ||
pwm.resume(); | ||
|
||
then("I expect deep sleep TO BE NOT possible") = [] { | ||
auto status = utils::sleep::system_deep_sleep_check(); | ||
|
||
expect(not status.can_deep_sleep); | ||
expect(not status.test_check_ok); | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
scenario("suspend, write 0%, resume") = [] { | ||
given("pwm is in default configuration") = [] { | ||
auto pwm = CorePwm(MOTOR_LEFT_PWM); | ||
|
||
expect(neq(&pwm, 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("pwm is running at 0%") = [&] { | ||
pwm.write(0.0); | ||
|
||
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("pwm is suspended") = [&] { | ||
pwm.suspend(); | ||
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("pwm is resumed") = [&] { | ||
pwm.resume(); | ||
|
||
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); | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; |