From d05a900a5b58c17a896dc449e6ed7bca5430ff01 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 23 Mar 2020 15:44:41 +0100 Subject: sptests/sptls02: Add test case Add a test case which requires the use of __tls_guard() and __tls_init(). Change license to BSD-2-Clause. --- testsuites/sptests/Makefile.am | 2 +- testsuites/sptests/sptls02/init.cc | 44 +++++++++++++++++++++++++++--------- testsuites/sptests/sptls02/sptls02.h | 35 ++++++++++++++++++++++++++++ testsuites/sptests/sptls02/var.cc | 30 ++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 testsuites/sptests/sptls02/sptls02.h create mode 100644 testsuites/sptests/sptls02/var.cc diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 071ce13216..62bb1aa685 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1961,7 +1961,7 @@ if TEST_sptls02 sp_tests += sptls02 sp_screens += sptls02/sptls02.scn sp_docs += sptls02/sptls02.doc -sptls02_SOURCES = sptls02/init.cc +sptls02_SOURCES = sptls02/init.cc sptls02/var.cc sptls02_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_sptls02) \ $(support_includes) endif diff --git a/testsuites/sptests/sptls02/init.cc b/testsuites/sptests/sptls02/init.cc index 1cbefc6fcc..712358f978 100644 --- a/testsuites/sptests/sptls02/init.cc +++ b/testsuites/sptests/sptls02/init.cc @@ -1,28 +1,43 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H - #include "config.h" +#include "config.h" #endif +#include "sptls02.h" + #include #include #include #include -#include "tmacros.h" +#include const char rtems_test_name[] = "SPTLS 2"; @@ -34,8 +49,14 @@ static thread_local long i0; alignas(512) static thread_local long a512; +int seven() +{ + return 7; +} + static void clobber() { + extern_int = 0xdead0007; i123 = 0xdead0001; a256 = 0xdead0002; i0 = 0xdead0003; @@ -144,6 +165,7 @@ static thread_local A a3(mc + 3); static void checkTLSValues() { + rtems_test_assert(extern_int == 7); rtems_test_assert(i123 == 123); rtems_test_assert(a256 == 256); rtems_test_assert((a256 & 255) == 0); diff --git a/testsuites/sptests/sptls02/sptls02.h b/testsuites/sptests/sptls02/sptls02.h new file mode 100644 index 0000000000..b89750915d --- /dev/null +++ b/testsuites/sptests/sptls02/sptls02.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SPTLS02_H +#define SPTLS02_H + +extern thread_local int extern_int; + +int seven(); + +#endif // SPTLS02_H diff --git a/testsuites/sptests/sptls02/var.cc b/testsuites/sptests/sptls02/var.cc new file mode 100644 index 0000000000..ca885deb62 --- /dev/null +++ b/testsuites/sptests/sptls02/var.cc @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sptls02.h" + +thread_local int extern_int = seven(); -- cgit v1.2.3