mbed-os/TESTS/mbedmicro-mbed/attributes/attributes.c

154 lines
2.3 KiB
C
Raw Normal View History

#include "mbed_toolchain.h"
Adding test frameworks and test sources This commit adds the following test frameworks: - `greentea-client` (https://github.com/ARMmbed/greentea-client) - This framework provides a key-value api for communicating with the greentea test tool (https://github.com/ARMmbed/greentea) - `unity` (https://github.com/ARMmbed/unity) - This framework provides test assert macros that can be used when writing test cases - `utest` (https://github.com/ARMmbed/utest) - This framework allows you to execute a series of test cases with reporting that works with the greentea test tool (https://github.com/ARMmbed/greentea) The following changes were made when bringing these frameworks into the tree: - References to `mbed_drivers/mbed.h` within utest's tests were migrated to `mbed.h` - The yotta file `module.json` was removed from `greentea-client` and `unity` - `coverage.json` was also removed from `greentea-client` - `.gitignore` and `.gitattributes` were removed from `greentea-client` - Apache 2.0 license files were removed from `greentea-client` This also brings in a number of tests that have been newly written or ported from various sources: - `TESTS/integration` - Very basic tests, used to check if testing frameworks are working correctly - `TESTS/mbed_drivers` (Thanks @PrzemekWirkus!) - TESTS ported from mbed OS 3.0 (https://github.com/ARMmbed/mbed-drivers) - `TESTS/mbedmicro-mbed` (Thanks @PrzemekWirkus!) - Tests that weren't covered by `TESTS/mbed_drivers` that currently live in `libraries/tests/mbed` - `TESTS/mbedmicro-rtos-mbed` (Thanks @PrzemekWirkus!) - Ported tests that currently live in `libraries/tests/rtos/mbed` - `TESTS/storage_abstraction` (Thanks @rgrover!) - Tests for the storage_abstraction hal
2016-07-19 18:39:53 +00:00
#include <stdio.h>
#include <stdint.h>
MBED_PACKED(struct) TestAttrPackedStruct1 {
char a;
int x;
};
typedef MBED_PACKED(struct) {
char a;
int x;
} TestAttrPackedStruct2;
int testPacked() {
int failed = 0;
if (sizeof(struct TestAttrPackedStruct1) != sizeof(int) + sizeof(char)) {
failed++;
}
if (sizeof(TestAttrPackedStruct2) != sizeof(int) + sizeof(char)) {
failed++;
}
return failed;
}
MBED_ALIGN(8) char a;
MBED_ALIGN(8) char b;
MBED_ALIGN(16) char c;
MBED_ALIGN(8) char d;
MBED_ALIGN(16) char e;
int testAlign() {
int failed = 0;
if(((uintptr_t)&a) & 0x7){
failed++;
}
if(((uintptr_t)&b) & 0x7){
failed++;
}
if(((uintptr_t)&c) & 0xf){
failed++;
}
if(((uintptr_t)&d) & 0x7){
failed++;
}
if(((uintptr_t)&e) & 0xf){
failed++;
}
return failed;
}
int testUnused1(MBED_UNUSED int arg) {
return 0;
}
int testUnused() {
return testUnused1(0);
}
int testWeak1();
int testWeak2();
MBED_WEAK int testWeak1() {
return 1;
}
int testWeak2() {
return 0;
}
int testWeak() {
return testWeak1() | testWeak2();
}
MBED_PURE int testPure1() {
return 0;
}
int testPure() {
return testPure1();
}
MBED_FORCEINLINE int testForceInline1() {
return 0;
}
int testForceInline() {
return testForceInline1();
}
MBED_NORETURN int testNoReturn1() {
while (1) {}
}
int testNoReturn() {
if (0) {
testNoReturn1();
}
return 0;
}
int testUnreachable1(int i) {
switch (i) {
case 0:
return 0;
}
MBED_UNREACHABLE;
}
int testUnreachable() {
return testUnreachable1(0);
}
MBED_DEPRECATED("this message should not be displayed")
void testDeprecatedUnused();
void testDeprecatedUnused() { }
MBED_DEPRECATED("this message should be displayed")
int testDeprecatedUsed();
int testDeprecatedUsed() {
return 0;
}
MBED_DEPRECATED_SINCE("mbed-os-3.14", "this message should not be displayed")
void testDeprecatedSinceUnused();
void testDeprecatedSinceUnused() { }
MBED_DEPRECATED_SINCE("mbed-os-3.14", "this message should be displayed")
int testDeprecatedSinceUsed();
int testDeprecatedSinceUsed() {
return 0;
}
Adding test frameworks and test sources This commit adds the following test frameworks: - `greentea-client` (https://github.com/ARMmbed/greentea-client) - This framework provides a key-value api for communicating with the greentea test tool (https://github.com/ARMmbed/greentea) - `unity` (https://github.com/ARMmbed/unity) - This framework provides test assert macros that can be used when writing test cases - `utest` (https://github.com/ARMmbed/utest) - This framework allows you to execute a series of test cases with reporting that works with the greentea test tool (https://github.com/ARMmbed/greentea) The following changes were made when bringing these frameworks into the tree: - References to `mbed_drivers/mbed.h` within utest's tests were migrated to `mbed.h` - The yotta file `module.json` was removed from `greentea-client` and `unity` - `coverage.json` was also removed from `greentea-client` - `.gitignore` and `.gitattributes` were removed from `greentea-client` - Apache 2.0 license files were removed from `greentea-client` This also brings in a number of tests that have been newly written or ported from various sources: - `TESTS/integration` - Very basic tests, used to check if testing frameworks are working correctly - `TESTS/mbed_drivers` (Thanks @PrzemekWirkus!) - TESTS ported from mbed OS 3.0 (https://github.com/ARMmbed/mbed-drivers) - `TESTS/mbedmicro-mbed` (Thanks @PrzemekWirkus!) - Tests that weren't covered by `TESTS/mbed_drivers` that currently live in `libraries/tests/mbed` - `TESTS/mbedmicro-rtos-mbed` (Thanks @PrzemekWirkus!) - Ported tests that currently live in `libraries/tests/rtos/mbed` - `TESTS/storage_abstraction` (Thanks @rgrover!) - Tests for the storage_abstraction hal
2016-07-19 18:39:53 +00:00
int testDeprecated() {
return testDeprecatedUsed() + testDeprecatedSinceUsed();
Adding test frameworks and test sources This commit adds the following test frameworks: - `greentea-client` (https://github.com/ARMmbed/greentea-client) - This framework provides a key-value api for communicating with the greentea test tool (https://github.com/ARMmbed/greentea) - `unity` (https://github.com/ARMmbed/unity) - This framework provides test assert macros that can be used when writing test cases - `utest` (https://github.com/ARMmbed/utest) - This framework allows you to execute a series of test cases with reporting that works with the greentea test tool (https://github.com/ARMmbed/greentea) The following changes were made when bringing these frameworks into the tree: - References to `mbed_drivers/mbed.h` within utest's tests were migrated to `mbed.h` - The yotta file `module.json` was removed from `greentea-client` and `unity` - `coverage.json` was also removed from `greentea-client` - `.gitignore` and `.gitattributes` were removed from `greentea-client` - Apache 2.0 license files were removed from `greentea-client` This also brings in a number of tests that have been newly written or ported from various sources: - `TESTS/integration` - Very basic tests, used to check if testing frameworks are working correctly - `TESTS/mbed_drivers` (Thanks @PrzemekWirkus!) - TESTS ported from mbed OS 3.0 (https://github.com/ARMmbed/mbed-drivers) - `TESTS/mbedmicro-mbed` (Thanks @PrzemekWirkus!) - Tests that weren't covered by `TESTS/mbed_drivers` that currently live in `libraries/tests/mbed` - `TESTS/mbedmicro-rtos-mbed` (Thanks @PrzemekWirkus!) - Ported tests that currently live in `libraries/tests/rtos/mbed` - `TESTS/storage_abstraction` (Thanks @rgrover!) - Tests for the storage_abstraction hal
2016-07-19 18:39:53 +00:00
}