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.
This commit is contained in:
Sebastian Huber
2020-03-23 15:44:41 +01:00
parent 3fd4889157
commit d05a900a5b
4 changed files with 99 additions and 12 deletions

View File

@@ -1961,7 +1961,7 @@ if TEST_sptls02
sp_tests += sptls02 sp_tests += sptls02
sp_screens += sptls02/sptls02.scn sp_screens += sptls02/sptls02.scn
sp_docs += sptls02/sptls02.doc 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) \ sptls02_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_sptls02) \
$(support_includes) $(support_includes)
endif endif

View File

@@ -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 * Redistribution and use in source and binary forms, with or without
* Dornierstr. 4 * modification, are permitted provided that the following conditions
* 82178 Puchheim * are met:
* Germany * 1. Redistributions of source code must retain the above copyright
* <rtems@embedded-brains.de> * 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 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* found in the file LICENSE in this distribution or at * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* http://www.rtems.org/license/LICENSE. * 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 #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include "sptls02.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <rtems.h> #include <rtems.h>
#include <rtems/libcsupport.h> #include <rtems/libcsupport.h>
#include "tmacros.h" #include <tmacros.h>
const char rtems_test_name[] = "SPTLS 2"; const char rtems_test_name[] = "SPTLS 2";
@@ -34,8 +49,14 @@ static thread_local long i0;
alignas(512) static thread_local long a512; alignas(512) static thread_local long a512;
int seven()
{
return 7;
}
static void clobber() static void clobber()
{ {
extern_int = 0xdead0007;
i123 = 0xdead0001; i123 = 0xdead0001;
a256 = 0xdead0002; a256 = 0xdead0002;
i0 = 0xdead0003; i0 = 0xdead0003;
@@ -144,6 +165,7 @@ static thread_local A a3(mc + 3);
static void checkTLSValues() static void checkTLSValues()
{ {
rtems_test_assert(extern_int == 7);
rtems_test_assert(i123 == 123); rtems_test_assert(i123 == 123);
rtems_test_assert(a256 == 256); rtems_test_assert(a256 == 256);
rtems_test_assert((a256 & 255) == 0); rtems_test_assert((a256 & 255) == 0);

View File

@@ -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

View File

@@ -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();