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

104 lines
3.2 KiB
C
Raw Normal View History

2019-06-26 08:33:48 +00:00
/*
* Copyright (c) 2018-2019 Arm Limited and affiliates.
2018-11-19 16:55:27 +00:00
* 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 set of unique timeout values,
* when @a config.timeout_ms is set to each of these values (T),
* then, for every value T, @a hal_watchdog_init() returns @a WATCHDOG_STATUS_OK
* and @a hal_watchdog_get_reload_value() returns a reload value R
* and T <= R < 2 * T.
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 T 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 a reload value R
* and T <= R < 2 * T.
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
/** @}*/