BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2016 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #if !DEVICE_LOWPOWERTIMER
00018 #error [NOT_SUPPORTED] Low power timer not supported for this target
00019 #endif
00020 
00021 #include "mbed.h"
00022 #include "greentea-client/test_env.h"
00023 #include "utest/utest.h"
00024 #include "unity/unity.h"
00025 #include "../timeout/timeout_tests.h"
00026 
00027 using namespace utest::v1;
00028 
00029 utest::v1::status_t greentea_failure_handler(const Case * const source, const failure_t reason)
00030 {
00031     greentea_case_failure_abort_handler(source, reason);
00032     return STATUS_CONTINUE;
00033 }
00034 
00035 Case cases[] = {
00036     Case("Callback called once (attach)", test_single_call<AttachTester<LowPowerTimeout> >),
00037     Case("Callback called once (attach_us)", test_single_call<AttachUSTester<LowPowerTimeout> >),
00038 
00039     Case("Callback not called when cancelled (attach)", test_cancel<AttachTester<LowPowerTimeout> >),
00040     Case("Callback not called when cancelled (attach_us)", test_cancel<AttachUSTester<LowPowerTimeout> >),
00041 
00042     Case("Callback override (attach)", test_override<AttachTester<LowPowerTimeout> >),
00043     Case("Callback override (attach_us)", test_override<AttachUSTester<LowPowerTimeout> >),
00044 
00045     Case("Multiple timeouts running in parallel (attach)", test_multiple<AttachTester<LowPowerTimeout> >),
00046     Case("Multiple timeouts running in parallel (attach_us)", test_multiple<AttachUSTester<LowPowerTimeout> >),
00047 
00048     Case("Zero delay (attach)", test_no_wait<AttachTester<LowPowerTimeout> >),
00049     Case("Zero delay (attach_us)", test_no_wait<AttachUSTester<LowPowerTimeout> >),
00050 
00051     Case("10 ms delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 10000, SHORT_DELTA_US>,
00052             greentea_failure_handler),
00053     Case("10 ms delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 10000, SHORT_DELTA_US>,
00054             greentea_failure_handler),
00055 
00056     Case("1 s delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
00057             greentea_failure_handler),
00058     Case("1 s delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
00059             greentea_failure_handler),
00060 
00061     Case("5 s delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 5000000, LONG_DELTA_US>,
00062             greentea_failure_handler),
00063     Case("5 s delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 5000000, LONG_DELTA_US>,
00064             greentea_failure_handler),
00065 
00066 #if DEVICE_SLEEP
00067     Case("1 s delay during sleep (attach)", test_sleep<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
00068             greentea_failure_handler),
00069     Case("1 s delay during sleep (attach_us)", test_sleep<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
00070             greentea_failure_handler),
00071 
00072     Case("1 s delay during deepsleep (attach)", test_deepsleep<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
00073             greentea_failure_handler),
00074     Case("1 s delay during deepsleep (attach_us)", test_deepsleep<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
00075             greentea_failure_handler),
00076 #endif
00077 
00078     Case("Timing drift (attach)", test_drift<AttachTester<LowPowerTimeout> >),
00079     Case("Timing drift (attach_us)", test_drift<AttachUSTester<LowPowerTimeout> >),
00080 };
00081 
00082 utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
00083 {
00084     GREENTEA_SETUP(240, "timing_drift_auto");
00085     return greentea_test_setup_handler(number_of_cases);
00086 }
00087 
00088 Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
00089 
00090 int main()
00091 {
00092     Harness::run(specification);
00093 }