Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
marcozecchini 0:9fca2b23d0ba 1 /* mbed Microcontroller Library
marcozecchini 0:9fca2b23d0ba 2 * Copyright (c) 2017 ARM Limited
marcozecchini 0:9fca2b23d0ba 3 *
marcozecchini 0:9fca2b23d0ba 4 * Licensed under the Apache License, Version 2.0 (the "License");
marcozecchini 0:9fca2b23d0ba 5 * you may not use this file except in compliance with the License.
marcozecchini 0:9fca2b23d0ba 6 * You may obtain a copy of the License at
marcozecchini 0:9fca2b23d0ba 7 *
marcozecchini 0:9fca2b23d0ba 8 * http://www.apache.org/licenses/LICENSE-2.0
marcozecchini 0:9fca2b23d0ba 9 *
marcozecchini 0:9fca2b23d0ba 10 * Unless required by applicable law or agreed to in writing, software
marcozecchini 0:9fca2b23d0ba 11 * distributed under the License is distributed on an "AS IS" BASIS,
marcozecchini 0:9fca2b23d0ba 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
marcozecchini 0:9fca2b23d0ba 13 * See the License for the specific language governing permissions and
marcozecchini 0:9fca2b23d0ba 14 * limitations under the License.
marcozecchini 0:9fca2b23d0ba 15 */
marcozecchini 0:9fca2b23d0ba 16 #include <stdio.h>
marcozecchini 0:9fca2b23d0ba 17 #include <stdint.h>
marcozecchini 0:9fca2b23d0ba 18
marcozecchini 0:9fca2b23d0ba 19 #include "mbed_toolchain.h"
marcozecchini 0:9fca2b23d0ba 20 #include "greentea-client/test_env.h"
marcozecchini 0:9fca2b23d0ba 21 #include "unity.h"
marcozecchini 0:9fca2b23d0ba 22 #include "utest.h"
marcozecchini 0:9fca2b23d0ba 23
marcozecchini 0:9fca2b23d0ba 24 using namespace utest::v1;
marcozecchini 0:9fca2b23d0ba 25
marcozecchini 0:9fca2b23d0ba 26
marcozecchini 0:9fca2b23d0ba 27 // Test functions declared as C functions to avoid issues with name mangling
marcozecchini 0:9fca2b23d0ba 28 extern "C" {
marcozecchini 0:9fca2b23d0ba 29 int testPacked();
marcozecchini 0:9fca2b23d0ba 30 int testAlign();
marcozecchini 0:9fca2b23d0ba 31 int testUnused();
marcozecchini 0:9fca2b23d0ba 32 int testWeak();
marcozecchini 0:9fca2b23d0ba 33 int testPure();
marcozecchini 0:9fca2b23d0ba 34 int testForceInline();
marcozecchini 0:9fca2b23d0ba 35 int testNoReturn();
marcozecchini 0:9fca2b23d0ba 36 int testUnreachable();
marcozecchini 0:9fca2b23d0ba 37 int testDeprecated();
marcozecchini 0:9fca2b23d0ba 38 }
marcozecchini 0:9fca2b23d0ba 39
marcozecchini 0:9fca2b23d0ba 40
marcozecchini 0:9fca2b23d0ba 41 // Test wrapper and test cases for utest
marcozecchini 0:9fca2b23d0ba 42 template <int (*F)()>
marcozecchini 0:9fca2b23d0ba 43 void test_wrapper() {
marcozecchini 0:9fca2b23d0ba 44 TEST_ASSERT_UNLESS(F());
marcozecchini 0:9fca2b23d0ba 45 }
marcozecchini 0:9fca2b23d0ba 46
marcozecchini 0:9fca2b23d0ba 47 utest::v1::status_t test_setup(const size_t number_of_cases) {
marcozecchini 0:9fca2b23d0ba 48 GREENTEA_SETUP(5, "default_auto");
marcozecchini 0:9fca2b23d0ba 49 return verbose_test_setup_handler(number_of_cases);
marcozecchini 0:9fca2b23d0ba 50 }
marcozecchini 0:9fca2b23d0ba 51
marcozecchini 0:9fca2b23d0ba 52 Case cases[] = {
marcozecchini 0:9fca2b23d0ba 53 Case("Testing PACKED attribute", test_wrapper<testPacked>),
marcozecchini 0:9fca2b23d0ba 54 Case("Testing ALIGN attribute", test_wrapper<testAlign>),
marcozecchini 0:9fca2b23d0ba 55 Case("Testing UNUSED attribute", test_wrapper<testUnused>),
marcozecchini 0:9fca2b23d0ba 56 Case("Testing WEAK attribute", test_wrapper<testWeak>),
marcozecchini 0:9fca2b23d0ba 57 Case("Testing PURE attribute", test_wrapper<testPure>),
marcozecchini 0:9fca2b23d0ba 58 Case("Testing FORCEINLINE attribute", test_wrapper<testForceInline>),
marcozecchini 0:9fca2b23d0ba 59 Case("Testing NORETURN attribute", test_wrapper<testNoReturn>),
marcozecchini 0:9fca2b23d0ba 60 Case("Testing UNREACHABLE attribute", test_wrapper<testUnreachable>),
marcozecchini 0:9fca2b23d0ba 61 Case("Testing DEPRECATED attribute", test_wrapper<testDeprecated>),
marcozecchini 0:9fca2b23d0ba 62 };
marcozecchini 0:9fca2b23d0ba 63
marcozecchini 0:9fca2b23d0ba 64 Specification specification(test_setup, cases);
marcozecchini 0:9fca2b23d0ba 65
marcozecchini 0:9fca2b23d0ba 66 int main() {
marcozecchini 0:9fca2b23d0ba 67 return !Harness::run(specification);
marcozecchini 0:9fca2b23d0ba 68 }