Skip to content

Commit

Permalink
✅ (tests): on device - add deep sleep core buffered serial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Nov 25, 2022
1 parent f0b10fe commit 67f2ac5
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/functional/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ endfunction()
add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/boost_ut)

add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/core_imu)
add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/deep_sleep_core_buffered_serial)
add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/deep_sleep_log_kit)
add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/deep_sleep_mbed_hal)
add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/file_manager)
Expand Down
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
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// 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();

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();

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);
};
};

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();

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);
};
};
};
};
};

0 comments on commit 67f2ac5

Please sign in to comment.