Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2017 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 #include <stdio.h>
00017 #include <stdint.h>
00018 
00019 #include "mbed_toolchain.h"
00020 #include "greentea-client/test_env.h"
00021 #include "unity.h"
00022 #include "utest.h"
00023 
00024 using namespace utest::v1;
00025 
00026 
00027 // Test functions declared as C functions to avoid issues with name mangling
00028 extern "C" {
00029     int testPacked();
00030     int testAlign();
00031     int testUnused();
00032     int testWeak();
00033     int testPure();
00034     int testForceInline();
00035     int testNoReturn();
00036     int testUnreachable();
00037     int testDeprecated();
00038 }
00039 
00040 
00041 // Test wrapper and test cases for utest
00042 template <int (*F)()>
00043 void test_wrapper() {
00044     TEST_ASSERT_UNLESS(F());
00045 }
00046 
00047 utest::v1::status_t test_setup(const size_t number_of_cases) {
00048     GREENTEA_SETUP(5, "default_auto");
00049     return verbose_test_setup_handler(number_of_cases);
00050 }
00051 
00052 Case cases[] = {
00053     Case("Testing PACKED attribute",        test_wrapper<testPacked>),
00054     Case("Testing ALIGN attribute",         test_wrapper<testAlign>),
00055     Case("Testing UNUSED attribute",        test_wrapper<testUnused>),
00056     Case("Testing WEAK attribute",          test_wrapper<testWeak>),
00057     Case("Testing PURE attribute",          test_wrapper<testPure>),
00058     Case("Testing FORCEINLINE attribute",   test_wrapper<testForceInline>),
00059     Case("Testing NORETURN attribute",      test_wrapper<testNoReturn>),
00060     Case("Testing UNREACHABLE attribute",   test_wrapper<testUnreachable>),
00061     Case("Testing DEPRECATED attribute",    test_wrapper<testDeprecated>),
00062 };
00063 
00064 Specification specification(test_setup, cases);
00065 
00066 int main() {
00067     return !Harness::run(specification);
00068 }