mbed-os/TESTS/mbed_hal/watchdog/watchdog_api_tests.h

114 lines
3.5 KiB
C
Raw Normal View History

/* Mbed Microcontroller Library
2018-11-19 16:55:27 +00:00
* Copyright (c) 2018 ARM Limited
* SPDX-License-Identifier: Apache-2.0
2017-11-23 15:18:46 +00:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @addtogroup hal_watchdog_tests
* @{
*/
#ifndef MBED_HAL_WATCHDOG_API_TESTS_H
#define MBED_HAL_WATCHDOG_API_TESTS_H
#if DEVICE_WATCHDOG
/** Test max_timeout validity
2017-11-23 15:18:46 +00:00
*
2018-11-29 13:48:02 +00:00
* Given a device supporting Watchdog HAL API,
* when @a hal_watchdog_get_platform_features() is called,
* then max_timeout member of returned watchdog_features_t struct is greater than 1.
2017-11-23 15:18:46 +00:00
*/
void test_max_timeout_is_valid();
2018-11-29 13:48:02 +00:00
/** Test Watchdog features if a stopped Watchdog can be started again
2017-11-23 15:18:46 +00:00
*
2018-11-29 13:48:02 +00:00
* Given a device supporting Watchdog HAL API,
* when the device supports the @a disable_watchdog feature,
* then the device also supports @a update_config feature.
2017-11-23 15:18:46 +00:00
*/
void test_restart_is_possible();
2018-11-29 13:48:02 +00:00
/** Test Watchdog stop
*
* Given a device without a support for the @a disable_watchdog feature,
* when @a hal_watchdog_stop() is called,
* then WATCHDOG_STATUS_NOT_SUPPORTED is returned.
*
* Otherwise, given the device with @a disable_watchdog feature support:
*
2018-11-29 13:48:02 +00:00
* Given the Watchdog is *NOT* running,
* when @a hal_watchdog_stop() is called,
* then WATCHDOG_STATUS_OK is returned.
*
2018-11-29 13:48:02 +00:00
* Given the Watchdog is running,
* when @a hal_watchdog_stop() is called before the timeout expires,
* then WATCHDOG_STATUS_OK is returned and the device is not restarted.
*
2018-11-29 13:48:02 +00:00
* Given the Watchdog is *NOT* running (it has already been stopped),
* when @a hal_watchdog_stop() is called,
* then WATCHDOG_STATUS_OK is returned.
2017-11-23 15:18:46 +00:00
*/
void test_stop();
2018-11-29 13:48:02 +00:00
/** Test Watchdog init multiple times
*
* Given @a max_timeout value returned by @a hal_watchdog_get_platform_features():
*
* Given @a config.timeout_ms is set to WDG_TIMEOUT_MS,
* when @a hal_watchdog_init() is called,
* then @a WATCHDOG_STATUS_OK is returned
* and @a hal_watchdog_get_reload_value() returns WDG_TIMEOUT_MS.
*
* Given @a config.timeout_ms is set to max_timeout-delta,
* when @a hal_watchdog_init() is called,
* then @a WATCHDOG_STATUS_OK is returned
* and @a hal_watchdog_get_reload_value() returns max_timeout-delta.
*
* Given @a config.timeout_ms is set to max_timeout,
* when @a hal_watchdog_init() is called,
* then @a WATCHDOG_STATUS_OK is returned
* and @a hal_watchdog_get_reload_value() returns max_timeout.
2017-11-23 15:18:46 +00:00
*/
void test_update_config();
2018-11-29 13:48:02 +00:00
/** Test Watchdog init with a valid config
2017-11-23 15:18:46 +00:00
*
* Given @a config.timeout_ms is set to X ms,
2018-11-29 13:48:02 +00:00
* which is within supported Watchdog timeout range,
* when @a hal_watchdog_init() is called,
* then @a WATCHDOG_STATUS_OK is returned
* and @a hal_watchdog_get_reload_value() returns X.
2017-11-23 15:18:46 +00:00
*/
template<uint32_t timeout_ms>
void test_init();
2018-11-29 13:48:02 +00:00
/** Test Watchdog init with a max_timeout
2017-11-23 15:18:46 +00:00
*
* Given @a config.timeout_ms is set to max_timeout,
* which is a value returned by @a hal_watchdog_get_platform_features(),
* when @a hal_watchdog_init() is called,
* then @a WATCHDOG_STATUS_OK is returned
* and @a hal_watchdog_get_reload_value() returns max_timeout.
2017-11-23 15:18:46 +00:00
*/
void test_init_max_timeout();
#endif
#endif
/** @}*/