From 525748f6a941a50c1098de3eb8ba94fc818990b5 Mon Sep 17 00:00:00 2001 From: Marvin Ouma Date: Sat, 16 Nov 2024 09:49:32 +0300 Subject: [PATCH] tests: posix: common: separate posix thread safe to standalone test posix.common contains testsuites that can be separated into smaller groups of tests. This change moves grp, pwd into a singular testsuite at tests/posix/thread_safe_sunctions app directory. Signed-off-by: Marvin Ouma --- .../thread_safe_functions/CMakeLists.txt | 9 +++++++ tests/posix/thread_safe_functions/prj.conf | 5 ++++ .../src/grp.c | 4 +-- tests/posix/thread_safe_functions/src/main.c | 9 +++++++ .../src/pwd.c | 4 +-- .../posix/thread_safe_functions/testcase.yaml | 25 +++++++++++++++++++ 6 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 tests/posix/thread_safe_functions/CMakeLists.txt create mode 100644 tests/posix/thread_safe_functions/prj.conf rename tests/posix/{common => thread_safe_functions}/src/grp.c (78%) create mode 100644 tests/posix/thread_safe_functions/src/main.c rename tests/posix/{common => thread_safe_functions}/src/pwd.c (78%) create mode 100644 tests/posix/thread_safe_functions/testcase.yaml diff --git a/tests/posix/thread_safe_functions/CMakeLists.txt b/tests/posix/thread_safe_functions/CMakeLists.txt new file mode 100644 index 000000000000..9ae5eb7ad1e4 --- /dev/null +++ b/tests/posix/thread_safe_functions/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(posix_thread_safe_functions) + +FILE(GLOB app_sources src/*.c) + +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/posix/thread_safe_functions/prj.conf b/tests/posix/thread_safe_functions/prj.conf new file mode 100644 index 000000000000..e265e5d75a5a --- /dev/null +++ b/tests/posix/thread_safe_functions/prj.conf @@ -0,0 +1,5 @@ +CONFIG_POSIX_API=y +CONFIG_ZTEST=y + +CONFIG_POSIX_AEP_CHOICE_BASE=y +CONFIG_POSIX_THREAD_SAFE_FUNCTIONS=y diff --git a/tests/posix/common/src/grp.c b/tests/posix/thread_safe_functions/src/grp.c similarity index 78% rename from tests/posix/common/src/grp.c rename to tests/posix/thread_safe_functions/src/grp.c index 1fce1433bff8..784f7025663b 100644 --- a/tests/posix/common/src/grp.c +++ b/tests/posix/thread_safe_functions/src/grp.c @@ -9,10 +9,8 @@ #include -ZTEST(grp, test_grp_stubs) +ZTEST(posix_thread_safe_functions, test_grp_stubs) { zassert_equal(getgrnam_r(NULL, NULL, NULL, 42, NULL), ENOSYS); zassert_equal(getgrgid_r(42, NULL, NULL, 42, NULL), ENOSYS); } - -ZTEST_SUITE(grp, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/posix/thread_safe_functions/src/main.c b/tests/posix/thread_safe_functions/src/main.c new file mode 100644 index 000000000000..44a9e553c1f9 --- /dev/null +++ b/tests/posix/thread_safe_functions/src/main.c @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2024 Marvin Ouma + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +ZTEST_SUITE(posix_thread_safe_functions, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/posix/common/src/pwd.c b/tests/posix/thread_safe_functions/src/pwd.c similarity index 78% rename from tests/posix/common/src/pwd.c rename to tests/posix/thread_safe_functions/src/pwd.c index dd473569f0d3..c40cd66f3839 100644 --- a/tests/posix/common/src/pwd.c +++ b/tests/posix/thread_safe_functions/src/pwd.c @@ -9,10 +9,8 @@ #include -ZTEST(pwd, test_pwd_stubs) +ZTEST(posix_thread_safe_functions, test_pwd_stubs) { zassert_equal(getpwnam_r(NULL, NULL, NULL, 42, NULL), ENOSYS); zassert_equal(getpwuid_r(42, NULL, NULL, 42, NULL), ENOSYS); } - -ZTEST_SUITE(pwd, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/posix/thread_safe_functions/testcase.yaml b/tests/posix/thread_safe_functions/testcase.yaml new file mode 100644 index 000000000000..5712bac8a17b --- /dev/null +++ b/tests/posix/thread_safe_functions/testcase.yaml @@ -0,0 +1,25 @@ +common: + filter: not CONFIG_NATIVE_LIBC + tags: + - posix + - thread_safe_functions + # 1 tier0 platform per supported architecture + platform_key: + - arch + - simulation + min_flash: 64 + min_ram: 32 +tests: + portability.posix.thread_safe_functions: {} + portability.posix.thread_safe_functions.minimal: + extra_configs: + - CONFIG_MINIMAL_LIBC=y + portability.posix.thread_safe_functions.newlib: + filter: TOOLCHAIN_HAS_NEWLIB == 1 + extra_configs: + - CONFIG_NEWLIB_LIBC=y + portability.posix.thread_safe_functions.picolibc: + tags: picolibc + filter: CONFIG_PICOLIBC_SUPPORTED + extra_configs: + - CONFIG_PICOLIBC=y