Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 #include <stdio.h>
nexpaq 0:6c56fb4bc5f0 2 #include <stdint.h>
nexpaq 0:6c56fb4bc5f0 3
nexpaq 0:6c56fb4bc5f0 4 #include "toolchain.h"
nexpaq 0:6c56fb4bc5f0 5 #include "greentea-client/test_env.h"
nexpaq 0:6c56fb4bc5f0 6 #include "unity.h"
nexpaq 0:6c56fb4bc5f0 7 #include "utest.h"
nexpaq 0:6c56fb4bc5f0 8
nexpaq 0:6c56fb4bc5f0 9 using namespace utest::v1;
nexpaq 0:6c56fb4bc5f0 10
nexpaq 0:6c56fb4bc5f0 11
nexpaq 0:6c56fb4bc5f0 12 // Test functions declared as C functions to avoid issues with name mangling
nexpaq 0:6c56fb4bc5f0 13 extern "C" {
nexpaq 0:6c56fb4bc5f0 14 int testPacked();
nexpaq 0:6c56fb4bc5f0 15 int testAlign();
nexpaq 0:6c56fb4bc5f0 16 int testUnused();
nexpaq 0:6c56fb4bc5f0 17 int testWeak();
nexpaq 0:6c56fb4bc5f0 18 int testPure();
nexpaq 0:6c56fb4bc5f0 19 int testForceInline();
nexpaq 0:6c56fb4bc5f0 20 int testNoReturn();
nexpaq 0:6c56fb4bc5f0 21 int testUnreachable();
nexpaq 0:6c56fb4bc5f0 22 int testDeprecated();
nexpaq 0:6c56fb4bc5f0 23 }
nexpaq 0:6c56fb4bc5f0 24
nexpaq 0:6c56fb4bc5f0 25
nexpaq 0:6c56fb4bc5f0 26 // Test wrapper and test cases for utest
nexpaq 0:6c56fb4bc5f0 27 template <int (*F)()>
nexpaq 0:6c56fb4bc5f0 28 void test_wrapper() {
nexpaq 0:6c56fb4bc5f0 29 TEST_ASSERT_UNLESS(F());
nexpaq 0:6c56fb4bc5f0 30 }
nexpaq 0:6c56fb4bc5f0 31
nexpaq 0:6c56fb4bc5f0 32 utest::v1::status_t test_setup(const size_t number_of_cases) {
nexpaq 0:6c56fb4bc5f0 33 GREENTEA_SETUP(5, "default_auto");
nexpaq 0:6c56fb4bc5f0 34 return verbose_test_setup_handler(number_of_cases);
nexpaq 0:6c56fb4bc5f0 35 }
nexpaq 0:6c56fb4bc5f0 36
nexpaq 0:6c56fb4bc5f0 37 Case cases[] = {
nexpaq 0:6c56fb4bc5f0 38 Case("Testing PACKED attribute", test_wrapper<testPacked>),
nexpaq 0:6c56fb4bc5f0 39 Case("Testing ALIGN attribute", test_wrapper<testAlign>),
nexpaq 0:6c56fb4bc5f0 40 Case("Testing UNUSED attribute", test_wrapper<testUnused>),
nexpaq 0:6c56fb4bc5f0 41 Case("Testing WEAK attribute", test_wrapper<testWeak>),
nexpaq 0:6c56fb4bc5f0 42 Case("Testing PURE attribute", test_wrapper<testPure>),
nexpaq 0:6c56fb4bc5f0 43 Case("Testing FORCEINLINE attribute", test_wrapper<testForceInline>),
nexpaq 0:6c56fb4bc5f0 44 Case("Testing NORETURN attribute", test_wrapper<testNoReturn>),
nexpaq 0:6c56fb4bc5f0 45 Case("Testing UNREACHABLE attribute", test_wrapper<testUnreachable>),
nexpaq 0:6c56fb4bc5f0 46 Case("Testing DEPRECATED attribute", test_wrapper<testDeprecated>),
nexpaq 0:6c56fb4bc5f0 47 };
nexpaq 0:6c56fb4bc5f0 48
nexpaq 0:6c56fb4bc5f0 49 Specification specification(test_setup, cases);
nexpaq 0:6c56fb4bc5f0 50
nexpaq 0:6c56fb4bc5f0 51 int main() {
nexpaq 0:6c56fb4bc5f0 52 return !Harness::run(specification);
nexpaq 0:6c56fb4bc5f0 53 }