Hw Watchdog UnitTest cases

-Added the unit test case for testing Hw watchdog
    -Added the supported stubs files
pull/10645/head
Rajkumar Kanagaraj 2019-01-23 12:40:06 +00:00 committed by Filip Jagodzinski
parent 3ea9521408
commit eb98c38226
6 changed files with 255 additions and 0 deletions

View File

@ -92,6 +92,7 @@ set(unittest-includes-base
"${PROJECT_SOURCE_DIR}/target_h/events" "${PROJECT_SOURCE_DIR}/target_h/events"
"${PROJECT_SOURCE_DIR}/target_h/events/equeue" "${PROJECT_SOURCE_DIR}/target_h/events/equeue"
"${PROJECT_SOURCE_DIR}/target_h/platform" "${PROJECT_SOURCE_DIR}/target_h/platform"
"${PROJECT_SOURCE_DIR}/target_h/drivers"
"${PROJECT_SOURCE_DIR}/stubs" "${PROJECT_SOURCE_DIR}/stubs"
"${PROJECT_SOURCE_DIR}/.." "${PROJECT_SOURCE_DIR}/.."
"${PROJECT_SOURCE_DIR}/../features" "${PROJECT_SOURCE_DIR}/../features"

View File

@ -0,0 +1,53 @@
/* mbed Microcontroller Library
* Copyright (c) 2018 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#ifdef DEVICE_WATCHDOG
#include "Watchdog.h"
namespace mbed
{
Watchdog *Watchdog::first;
void Watchdog::start()
{
}
void Watchdog::kick()
{
}
void Watchdog::stop()
{
}
void Watchdog::is_alive()
{
}
Watchdog::~Watchdog()
{
}
} // namespace mbed
#endif // DEVICE_WATCHDOG

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2018, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "mbed_watchdog_mgr.h"
using namespace mbed;
extern bool testcase;
// AStyle ignored as the definition is not clear due to preprocessor usage
// *INDENT-OFF*
// AStyle ignored as the definition is not clear due to preprocessor usage
// *INDENT-OFF*
class TestMbedWatchdogMgr : public testing::Test {
protected:
void SetUp()
{
}
void TearDown()
{
}
};
// *INDENT-ON*
TEST_F(TestMbedWatchdogMgr, test_mbed_watchdog_mgr_start_pass)
{
EXPECT_TRUE(mbed_wdog_manager_start());
}
TEST_F(TestMbedWatchdogMgr, test_mbed_watchdog_mgr_start_fail)
{
EXPECT_FALSE(mbed_wdog_manager_start());
}
TEST_F(TestMbedWatchdogMgr, test_mbed_watchdog_mgr_stop_pass)
{
EXPECT_TRUE(mbed_wdog_manager_stop());
}
TEST_F(TestMbedWatchdogMgr, test_mbed_watchdog_mgr_stop_fail)
{
EXPECT_FALSE(mbed_wdog_manager_stop());
}
TEST_F(TestMbedWatchdogMgr, test_mbed_wdog_manager_get_max_timeout)
{
EXPECT_EQ(0xFFFFFFFF,mbed_wdog_manager_get_max_timeout());
}
TEST_F(TestMbedWatchdogMgr, mbed_wdog_manager_get_reload_value)
{
EXPECT_EQ(500,mbed_wdog_manager_get_reload_value());
}

View File

@ -0,0 +1,29 @@
####################
# UNIT TESTS
####################
set(TEST_SUITE_NAME "mbed_watchdog_mgr")
# Add test specific include paths
set(unittest-includes ${unittest-includes}
.
../hal
)
# Source files
set(unittest-sources
../platform/mbed_watchdog_mgr.cpp
)
# Test files
set(unittest-test-sources
platform/mbed_watchdog_mgr/test_mbed_watchdog_mgr.cpp
platform/mbed_watchdog_mgr/Watchdog.cpp
stubs/mbed_assert_stub.c
stubs/mbed_critical_stub.c
stubs/watchdog_api_stub.c
)
# defines
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEVICE_WATCHDOG -DHW_WATCHDOG_TIMEOUT=500")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEVICE_WATCHDOG -DHW_WATCHDOG_TIMEOUT=500")

View File

@ -0,0 +1,48 @@
/* mbed Microcontroller Library
* Copyright (c) 2017 ARM Limited
*
* 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.
*/
#include "watchdog_api.h"
#if DEVICE_WATCHDOG
watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
{
return WATCHDOG_STATUS_OK;
}
void hal_watchdog_kick(void)
{
}
watchdog_status_t hal_watchdog_stop(void)
{
return WATCHDOG_STATUS_OK;
}
uint32_t hal_watchdog_get_reload_value(void)
{
return (500);
}
watchdog_features_t hal_watchdog_get_platform_features(void)
{
watchdog_features_t features;
features.max_timeout = 0xFFFFFFFF;
return features;
}
#endif // DEVICE_WATCHDOG

View File

@ -0,0 +1,54 @@
/* mbed Microcontroller Library
* Copyright (c) 2015 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#ifndef MBED_LOWPOWERTICKER_H
#define MBED_LOWPOWERTICKER_H
#include "hal/ticker_api.h"
#include "Callback.h"
namespace mbed {
/** \addtogroup drivers */
/** mock Low Power Ticker
*
*/
class LowPowerTicker {
public:
LowPowerTicker()
{
}
virtual ~LowPowerTicker()
{
}
void attach_us(Callback<void()> func, us_timestamp_t t)
{
}
void detach()
{
}
};
} // namespace mbed
#endif