Import Mbed OS hard-float snapshot
This commit is contained in:
208
TESTS/mbedmicro-mbed/attributes/attributes.c
Normal file
208
TESTS/mbedmicro-mbed/attributes/attributes.c
Normal file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "mbed_toolchain.h"
|
||||
|
||||
#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 testFallthrough1(int i)
|
||||
{
|
||||
switch (i) {
|
||||
case 1:
|
||||
case 2:
|
||||
i *= 2;
|
||||
MBED_FALLTHROUGH;
|
||||
default:
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
int testFallthrough()
|
||||
{
|
||||
return testFallthrough1(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;
|
||||
}
|
||||
|
||||
int testDeprecated()
|
||||
{
|
||||
return testDeprecatedUsed() + testDeprecatedSinceUsed();
|
||||
}
|
||||
|
||||
74
TESTS/mbedmicro-mbed/attributes/main.cpp
Normal file
74
TESTS/mbedmicro-mbed/attributes/main.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mbed_toolchain.h"
|
||||
#include "greentea-client/test_env.h"
|
||||
#include "unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
|
||||
// Test functions declared as C functions to avoid issues with name mangling
|
||||
extern "C" {
|
||||
int testPacked();
|
||||
int testAlign();
|
||||
int testUnused();
|
||||
int testWeak();
|
||||
int testPure();
|
||||
int testForceInline();
|
||||
int testNoReturn();
|
||||
int testFallthrough();
|
||||
int testUnreachable();
|
||||
int testDeprecated();
|
||||
}
|
||||
|
||||
|
||||
// Test wrapper and test cases for utest
|
||||
template <int (*F)()>
|
||||
void test_wrapper()
|
||||
{
|
||||
TEST_ASSERT_UNLESS(F());
|
||||
}
|
||||
|
||||
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||
{
|
||||
GREENTEA_SETUP(5, "default_auto");
|
||||
return verbose_test_setup_handler(number_of_cases);
|
||||
}
|
||||
|
||||
Case cases[] = {
|
||||
Case("Testing PACKED attribute", test_wrapper<testPacked>),
|
||||
Case("Testing ALIGN attribute", test_wrapper<testAlign>),
|
||||
Case("Testing UNUSED attribute", test_wrapper<testUnused>),
|
||||
Case("Testing WEAK attribute", test_wrapper<testWeak>),
|
||||
Case("Testing PURE attribute", test_wrapper<testPure>),
|
||||
Case("Testing FORCEINLINE attribute", test_wrapper<testForceInline>),
|
||||
Case("Testing NORETURN attribute", test_wrapper<testNoReturn>),
|
||||
Case("Testing FALLTHROUGH attribute", test_wrapper<testFallthrough>),
|
||||
Case("Testing UNREACHABLE attribute", test_wrapper<testUnreachable>),
|
||||
Case("Testing DEPRECATED attribute", test_wrapper<testDeprecated>),
|
||||
};
|
||||
|
||||
Specification specification(test_setup, cases);
|
||||
|
||||
int main()
|
||||
{
|
||||
return !Harness::run(specification);
|
||||
}
|
||||
29
TESTS/mbedmicro-mbed/attributes/weak.c
Normal file
29
TESTS/mbedmicro-mbed/attributes/weak.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "mbed_toolchain.h"
|
||||
|
||||
int testWeak1()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MBED_WEAK int testWeak2()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user