Skip to content

Commit 712e605

Browse files
committed
tests: newlib: thread_safety: Add internal lock and userspace tests
This commit adds the tests for the newlib retargetable locking interface, as well as the tests for the internal lock functions that are supposed to internally invoke the retargetable locking interface. All of these tests must pass when the toolchain newlib is compiled with the `retargetable-locking` and `multithread` options, which are required to ensure that the newlib is thread-safe, enabled. If the toolchain newlib is compiled with either of these options disabled, this test will fail. This commit also adds the userspace testcases to ensure that the newlib is thread-safe in the user mode. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 82e2bc1 commit 712e605

File tree

8 files changed

+668
-91
lines changed

8 files changed

+668
-91
lines changed

tests/lib/newlib/thread_safety/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,14 @@ cmake_minimum_required(VERSION 3.13.1)
44
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
55
project(newlib_thread_safety)
66

7-
FILE(GLOB app_sources src/*.c)
8-
target_sources(app PRIVATE ${app_sources})
7+
target_sources(app PRIVATE src/main.c)
8+
9+
target_sources_ifdef(
10+
CONFIG_NEWLIB_THREAD_SAFETY_TEST_LOCKS
11+
app PRIVATE src/locks.c
12+
)
13+
14+
target_sources_ifdef(
15+
CONFIG_NEWLIB_THREAD_SAFETY_TEST_STRESS
16+
app PRIVATE src/stress.c
17+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2021 Stephanos Ioannidis <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config NEWLIB_THREAD_SAFETY_TEST_LOCKS
5+
bool "Test: Locks"
6+
default y
7+
8+
config NEWLIB_THREAD_SAFETY_TEST_STRESS
9+
bool "Test: Stress"
10+
11+
source "Kconfig"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
CONFIG_ZTEST=y
22
CONFIG_NEWLIB_LIBC=y
3+
CONFIG_NEWLIB_LIBC_NANO=n
34
CONFIG_TIMESLICE_SIZE=1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CONFIG_ZTEST=y
2+
CONFIG_NEWLIB_LIBC=y
3+
CONFIG_NEWLIB_LIBC_NANO=n
4+
CONFIG_TIMESLICE_SIZE=1
5+
6+
CONFIG_TEST_USERSPACE=y
7+
CONFIG_MAX_THREAD_BYTES=10
8+
CONFIG_HEAP_MEM_POOL_SIZE=2048

0 commit comments

Comments
 (0)